constraints

UIAlertController (ActionSheet) - Unable to simultaneously satisfy constraints [duplicate]

Deadly 提交于 2019-12-10 15:16:25
问题 This question already has answers here : Swift default AlertViewController breaking constraints (3 answers) Closed 8 months ago . I'm getting this warning every time an UIAlertController action sheet is presented in a simulated phone. The code is nothing fancy. let action1 = UIAlertAction(title: "Action 1", style: .default) { _ in } let action2 = UIAlertAction(title: "Action 2", style: .default) { _ in } let cancel = UIAlertAction(title: "Cancel", style: .cancel, handler: nil) let alert =

Set UIImageView AspectRatio constraint programmatically in swift 3

霸气de小男生 提交于 2019-12-10 14:45:49
问题 I have an UIImageView in storyboard which AspectRatio is 1:1, that I want to change to 2:1 programmatically in ViewController in some cases. I create reference of that constraint in ViewController but unable to set the constraint. 回答1: You can change constraint programmatically in swift 3 let aspectRatioConstraint = NSLayoutConstraint(item: self.YourImageObj,attribute: .height,relatedBy: .equal,toItem: self.YourImageObj,attribute: .width,multiplier: (2.0 / 1.0),constant: 0) self.YourImageObj

Extract constraints form Doctrine 2 entity in symfony 2

痴心易碎 提交于 2019-12-10 14:41:12
问题 To keep the field level constraints at a central place (not replicate it in each form), I added the constraints in the entity. Like below (lets say its one of the fields of a user entity): /** * @var string * * @ORM\Column(name="email", type="string", length=255, nullable=false) * * @Constraints\NotBlank( * groups={"register", "edit"}, * message="email cannot be blank." * ) * @Constraints\Email( * groups={"register", "edit"}, * message="Please enter a valid email address." * ) * * @Expose *

Rails: Oracle constraint violation

拈花ヽ惹草 提交于 2019-12-10 14:33:48
问题 I'm doing maintenance work on a Rails site that I inherited; it's driven by an Oracle database, and I've got access to both development and production installations of the site (each with its own Oracle DB). I'm running into an Oracle error when trying to insert data on the production site, but not the dev site: ActiveRecord::StatementInvalid (OCIError: ORA-00001: unique constraint (DATABASE_NAME.PK_REGISTRATION_OWNERSHIP) violated: INSERT INTO registration_ownerships (updated_at, company

PostgreSQL unique value acreoss multiple columns

ⅰ亾dé卋堺 提交于 2019-12-10 14:13:35
问题 I have PostgreSQL table id ColA ColB ------------------ 1 'a' 'b' 2 'c' 'd' I want to make values in ColA and ColB to be unique across both columns i.e. any of these inserts would be forbidden: INSERT INTO table (ColA,ColB) values('a','e'); INSERT INTO table (ColA,ColB) values('z','a'); INSERT INTO table (ColA,ColB) values('d','g'); and any of these inserts would be allowed: INSERT INTO table (ColA,ColB) values('z','e'); INSERT INTO table (ColA,ColB) values('l','k'); So CONSTRAINT unique_name

MySQL: Constraining a set of columns so at least one is not NULL

陌路散爱 提交于 2019-12-10 13:28:24
问题 I want to have a SQL table with two columns. One is a key into another table, the other holds a string literal. The idea is phone numbers can be entered either exactly (in which case the ID into the phonebook table is used) or as a wildcard (in which the string literal is used). This means that one column in the table will hold a value, and the other will hold a NULL. Is it possible to constrain a table in such a way that one column must have a value, and the other must be NULL? If both

Namespace constraint with generic class declaration

↘锁芯ラ 提交于 2019-12-10 13:18:31
问题 I would like to know if (and if so how) it is possible to define a namespace as a constraint parameter in a generic class declaration. What I have is this: namespace MyProject.Models.Entities <-- Contains my classes to be persisted in db namespace MyProject.Tests.BaseTest <-- Obvious i think Now the decleration of my 'BaseTest' class looks like so; public class BaseTest<T> This BaseTest does little more (at the time of writing) than remove all entities that were added to the database during

Add multiple constraints in one statement

北战南征 提交于 2019-12-10 12:58:59
问题 I am supposed to modify my current table named MEMBER in Microsoft SQL Server 2012. I am trying to modify the tables ALTER TABLE MEMBER ADD CONSTRAINT U_MEMBERID UNIQUE(MEMBER_ID), primary key (MEMBER_ID); ADD CONSTRAINT Sys_date DEFAULT GETDATE() FOR MEMBER_ID; The above doesn't work and it says: Msg 156, Level 15, State 1, Line 3 Incorrect syntax near the keyword 'CONSTRAINT'. I think I am doing something wrong, but I am not sure what it is. ALTER TABLE TITLE ADD CONSTRAINT U_TITLEID UNIQUE

What is the way of designing a simple teacher-subject-student-batch relational database?

坚强是说给别人听的谎言 提交于 2019-12-10 12:12:42
问题 Conditions are Many teachers to one subject relationship , that is one subject can be taught by more than one teachers, but one teacher can only teach one subject Many students to many subjects relationship, that is many students can take a common subject and one student can take many subjects. Many students to many batches relationship. Two batches can not be held in one time , so need a unique date field in batch table. Many batches to one subject relationship, that is only one subject is

Display custom message when constraint is violated PL/SQL

徘徊边缘 提交于 2019-12-10 12:12:24
问题 I'm writing a pl/sql procedure. I've got a constraint on a column which doesn't allow values below 0 and above 500. I need to display a custom message if this constraint is violated (eg. "ID out of range"). Currently this is the exception and also the output in getting. There is another procedure that is outputting the error, hence the use raise_applcation_error. Exception when VALUE_ERROR then raise_application_error(-20002, 'Customer ID out of range'); Error Message "ORA-20000: ORA-02290: