constraints

What is the best approach for horizontally aligning 5 buttons with Autolayout

萝らか妹 提交于 2019-12-01 07:32:25
问题 I know this is a little newbie style question but I couldn't find any subject about this and I have to horizontally align multiple buttons in my view controller. I tried to 2 approach first one is separate them with UIViews and <= width changed constraints priority and others. Second one doesn't have UIViews but buttons aligned in starboard very well. I already watched Stanford auto layout lessons. But I couldn't find any solution about this. I don't know how to approach to align multiple

How can I set a table constraint “deferrable initially deferred” in django model?

别等时光非礼了梦想. 提交于 2019-12-01 07:28:34
问题 I am trying to set a constraint to a table model in django with a postgresql database. I can do it via postgresql with this sentence: ALTER TABLE public.mytable ADD CONSTRAINT "myconstraint" UNIQUE(field1, field2) DEFERRABLE INITIALLY DEFERRED; But I want to do it via django model. Reading the django official documentation I have not found anything related. I need something like this: class Meta: unique_together = (('field1', 'field2',), DEFERRABLE INITIALLY DEFERRED) Is it possible to do

MySQL variables in ALTER TABLE script

≯℡__Kan透↙ 提交于 2019-12-01 06:26:33
Hello The following procedure will have to move all constraints from one table to the other however I am having some difficulties at the point where the constraint should be deleted. The problem: how do I use variables in the following line ALTER TABLE var_referenced_table_name DROP FOREIGN KEY var_constraint_name; when I use as is, I receive the following error Error Code: 1146. Table 'oaf_businesslink_dev.var_referenced_table_name' doesn't exist MySQL does not recognise var_referenced_table_name and var_constraint_name as variables. DELIMITER // DROP PROCEDURE IF EXISTS AlterConstraints//

Rules are deprecated, what's instead (TSQL)?

狂风中的少年 提交于 2019-12-01 06:20:51
Rules (Transact-SQL)[1] are reusable what permitted to overcome the shortcoming of non-re-usability of check constraints. And now I read [1] that: "This feature will be removed in a future version of Microsoft SQL Server. Avoid using this feature in new development work, and plan to modify applications that currently use this feature. We recommend that you use check constraints instead. Check constraints are created by using the CHECK keyword of CREATE TABLE or ALTER TABLE" So, what is instead of rules and why are they deprecated? ==== Update: AlexKuznetsov, are table-level check constraints

Why generic extension method with constraint is not recognized as extension method? [duplicate]

只愿长相守 提交于 2019-12-01 06:06:00
Possible Duplicate: No type inference with generic extension method Consider two methods: public static IEnumerable<V> Merge<V> (this IEnumerable<IEnumerable<V>> coll) public static IEnumerable<V> Merge<T, V> (this IEnumerable<T> coll) where T : IEnumerable<V> Both compile just fine, in both cases the type of generic types will be known at compile time of caller, and thus the exact type of extended type. You can call both fine, but only the first one as extension. Why? Update 1 To see it fail, use the second method and such example: var x = new List<List<int>>(); var y = x.Merge(); Update --

CHECK CONSTRAINT in Oracle SQL

非 Y 不嫁゛ 提交于 2019-12-01 06:03:48
问题 I have the following table Goods_In_Wagon(Goods_ID,Wagon_ID,Total_Weight). I need to create a number of if statement check constraint that says "IF WAGON_ID is between 90 and 99 THEN Total_Weight must be greater than 10." AND "IF WAGON_ID is between 100 and 110 THEN Total_Weight must be greater than 20." AND "IF WAGON_ID is between 111 and 120 THEN Total_Weight must be greater than 30." is this possible in SQL Oracle, if it is how can I implement it 回答1: Use an out-of-line constraint: CREATE

C# Type Conversion Error Despite Generic Constraint

半腔热情 提交于 2019-12-01 06:02:13
问题 Why, with a generic constraint on type parameter T of class P of "must inherit from A", does the first call succeed but the second call fail with the type conversion error detailed in the comment: abstract class A { } static class S { public static void DoFirst(A argument) { } public static void DoSecond(ICollection<A> argument) { } } static class P<T> where T : A, new() { static void Do() { S.DoFirst(new T()); // this call is OK S.DoSecond(new List<T>()); // this call won't compile with: /*

How to make a foreign key with a constraint on the referenced table in PostgreSQL

。_饼干妹妹 提交于 2019-12-01 05:52:25
Suppose I have the following tables CREATE TABLE plugins ( id int primary key, type text); insert into plugins values (1,'matrix'); insert into plugins values (2,'matrix'); insert into plugins values (3,'function'); insert into plugins values (4,'function'); CREATE TABLE matrix_params ( id int primary key, pluginid int references plugins (id) ); This all works as expected but I would like to add an additional constraint that a matrix_param can only refer to the pluginid that has type 'matrix'. So insert into matrix_params values (1,1); Should succeed but insert into matrix_params values (2,3);

Exclusion constraint on a bitstring column with bitwise AND operator

瘦欲@ 提交于 2019-12-01 05:33:49
So I was just reading about Exclusion Constraints in PostgreSQL and I couldn't seem to find a way to use bitwise operators on bitstrings, and I was wondering if it was possible. My use case is I have a name: text column and a value: bit(8) column. And I wanted to create a constraint that basically says this: ADD CONSTRAINT route_method_overlap EXCLUDE USING gist(name WITH =, value WITH &) But this doesn't work since operator &(bit,bit) is not a member of operator family "gist_bit_ops" I assume this is because the bit_ops & operator doesn't return a boolean. But is there a way to do what I'm

Create constraint in alter table without checking existing data

早过忘川 提交于 2019-12-01 05:24:53
I'm trying to create a constraint on the OE.PRODUCT_INFORMATION table which is delivered with Oracle 11g R2. The constraint should make the PRODUCT_NAME unique. I've tried it with the following statement: ALTER TABLE PRODUCT_INFORMATION ADD CONSTRAINT PRINF_NAME_UNIQUE UNIQUE (PRODUCT_NAME); The problem is, that in the OE.PRODUCT_INFORMATION there are already product names which currently exist more than twice. Executing the code above throws the following error: an alter table validating constraint failed because the table has duplicate key values. Is there a possibility that a new created