constraints

How to Add Constraint for view inside stack view

谁都会走 提交于 2019-12-05 04:55:20
I have one stack view that contains with 4 buttons. And each button I also add subview to that. The subview of that 4 buttons, I try to program to add constraint into it. Some constraint such as .Trailing .Leading .Top .Bottom I cannot add to it by error constraint and stack view problem. How any solution to add that constraints to subview of stackview. if have any sample it's really good for me. thank in advance UIStackView's power is to reduce your using of constrains, just give it some setting info such as axis, distribution, alignment, spacing . stack view will layout your subview item

“Column ’x’ does not exist” error for string literal ’x’ in PostgreSQL [duplicate]

╄→гoц情女王★ 提交于 2019-12-05 02:40:25
This question already has answers here : Closed 7 years ago . Possible Duplicate: Column ‘mary’ does not exist I need to check the values that can be accepted to a column through a check constraint. I need to use the check constraint, because this is for a college assignment. I use this code to create and add the constraint to the table. CREATE TABLE Ereignis( E_Id Serial PRIMARY KEY, Typ varchar(15), Zeitpunkt timestamp, Ort varchar(32), Anzahl_Pers int ); ALTER TABLE Ereignis ADD CONSTRAINT typ_ch CHECK (Typ in (’Verkehrsunfall’, ’Hochwasser’, ’Sonstiges’)); Here is the error I get: ERROR:

Is there a way to avoid row deletion on an specific table using constrains or triggers?

ε祈祈猫儿з 提交于 2019-12-05 02:12:49
Is there a way to avoid row deletion on an specific table using constrains? I'd like to (for example) deny row deletion if the id is 0,1 or 2 This is in order to avoid users deleting master accounts for an application, and I'd like to avoid it even if someone tries it (by mistake) using sql directly. Thanks! EDIT: The whole idea of this question is not to touch the application. It's not a matter of security, I just need to know if It's possible to do what I asked with constrains or any other thing that SQL Server has (It does not need to be an standard db solution). EDIT 2: Code samples are

SQL: how to enforce that only a single column is set in a group of columns

做~自己de王妃 提交于 2019-12-05 01:59:22
In SQL, is there a way to enforce that only one column out of a group of columns has a value, and the others are null? Maybe a constraint or trigger? This type of thing might be for a lookup table, but are there any alternate table designs that might accomplish this better? For example: ID OtherTable1ID OtherTable2ID OtherTable3ID ----------------------------------------------------- 1 23 NULL NULL 2 NULL 45 NULL 3 33 55 NULL -- NOT ALLOWED The main issue is that these columns are all FKs to other tables, so I can't collapse them down to a single column. I'm using SQL Server, but any answer

Remove constraints in sequelize migration

余生长醉 提交于 2019-12-05 01:41:38
I'm adding a unique constraint in a migration via the migrations.changeColumn function. Adding the constraint works, but since you need to provide a “backwards migration“, removing it the same way does not. It doesn't give any errors when migrating backwards, but again applying the forward migration results in Possibly unhandled SequelizeDatabaseError: relation "myAttribute_unique_idx" already exists . (The used database is postgres) module.exports = { up: function (migration, DataTypes, done) { migration.changeColumn( 'Users', 'myAttribute', { type: DataTypes.STRING, unique: true // ADDING

Android, handle SQLiteConstraintException

*爱你&永不变心* 提交于 2019-12-05 00:55:27
I've got this method in Android: public void insertarTitulo(String _id, String title, String url){ ContentValues cv = new ContentValues(); cv.put("_id", _id); cv.put("title", title); cv.put("URL", url); try{ getWritableDatabase().insert("book", "book", cv); }catch(SQLiteConstraintException e){ Log.e(MyActivity.LOGTAG, "This code doesn't show"); } close(); } title value is unique so when I insert a duplicate value throws me the Constraint error, so far that's correct. Everything works as expected. but I can't make the catch code work. Try using insertOrThrow . Otherwise, insert just returns -1

iOS - proportional spacing with autolayout

佐手、 提交于 2019-12-05 00:34:12
I'm trying to create a perfectly to-scale view with interface builder. So far, everything is good. I'm scaling the font, buttons, etc programmatically.. the only problem is the constraints (the spacing) between elements which remains the same. I want to avoid creating outlets for the spacing constraints because it seems messy. I want the spacing between elements to remain proportional as i stretch the element. right now everything is aligned based on the left side of the screen. if i stretch my view, everything stays left aligned. I want it to all stretch apart proportionally. How can I

What is point of constraint validation @Null?

混江龙づ霸主 提交于 2019-12-04 23:19:31
I was checking list of available constraints in javax.validation package and I noticed that there is an annotation @Null which force the field to be null. I do not understand what is point of adding it to my field if I already know it should be null. For example look at this class: public class MyClass{ @NotNull private String myString1; @Null private String myString2; // getter setters... } @NotNull completely makes sense. I do not expect myString1 to be null. but @Null makes myString2 useless. What is point of having a field which should always be null. You may want to use @Null in

How to place unique contraint on multiple column

≯℡__Kan透↙ 提交于 2019-12-04 23:15:01
EmpID DeptID 1 1 1 2 2 1 3 2 4 5 5 2 1 1 2 1 I would like to have a constraint that will make sure that the pair of field is always unique ,such data as last two shown in the example should not be insert-able into the table .in the above table please note that last two rows are duplicates ,I would like to prevent such data from occuring . How do I achieve this in sqlserver 2005.Thanks ALTER TABLE <YourTable, sysname, Emp> ADD CONSTRAINT <YourConstraintName, sysname, uix> UNIQUE NONCLUSTERED (EmpID,DeptID) (Paste into SSMS and use (CTRL + Shift + M)) Or to do this at table creation and as it

How to test route constraints with rspec

烈酒焚心 提交于 2019-12-04 22:58:10
I'm working on an application that will be primarily served as an API (other than a few minor views, such as session/registration, which will be "standard"). I like the approach that was finalized in Railscast #350: Versioning an API , and so followed it. My routes look like: namespace :api, :defaults => {:format => 'json'} do scope :module => :v1, :constraints => ApiConstraints.new(:version => 1, :default => false) do resources :posts, :only => [:create, :show, :destroy, :index] end scope :module => :v2, :constraints => ApiConstraints.new(:version => 2, :default => true) do resources :posts,