constraints

React.PropTypes.number float with min and max

扶醉桌前 提交于 2019-12-22 08:37:51
问题 completed: React.PropTypes.number, Can i specify a minimum and maximum to a number props in React component. expected something like following: completed: React.PropTypes.numberBetween(min, max), I generate an array to specify the range attempt: completed: React.PropTypes.oneOf(Array.from({length: max -min+1, (v, k) => k + min})), However , i want completed props to accept also float as well , whereas , it accepts only integer now . How to make the following constraints combined : prop is

SQL Server: How can I check to see if a field has a “NULL” or “NOT NULL” constraint in place?

我们两清 提交于 2019-12-22 08:36:32
问题 Could anyone please let me know if there is a way to programatically determine if a Micorosft SQL Server database table field has a NULL or NOT NULL constraint in place? I need this so that I can deploy a patch that is safe to be re-runnable. So I'm after something like this (conceptual/pseudo-code): IF (my_table COLUMN end_date HAS CONSTRAINT OF 'NOT NULL') ALTER TABLE my_table ALTER COLUMN end_date DATETIME NULL So I want to change my_table.end_date from 'NOT NULL' to 'NULL' if it hasn't

Animating UIView frame with constraints

若如初见. 提交于 2019-12-22 07:11:05
问题 I have an element in a UIView with a constraint that says it should always be 10 pixels from the bottom of the view. I am then attempting to animate this view's height so that it appears to slide down the screen. According to the constraint, the element should always be 10 pixels from the bottom of the view. This holds true when I add the view like so... printView *vc = [self.storyboard instantiateViewControllerWithIdentifier:@"printView"]; [self addChildViewController:vc]; vc.view.frame =

MySQL: UNIQUE constraint without index

夙愿已清 提交于 2019-12-22 06:56:26
问题 Is it possible to add a constraint like ALTER TABLE `t1` ADD UNIQUE(`col1`, `col2`); without creating an index? The index wouldn't be used for any queries so it would be a waste of space. It wouldn't be a problem if inserts and updates would be way slower, because the table doesn't get updated very often. 回答1: No, this is not possible. A UNIQUE constraint contains an index definition and I barely imagine how it might be implemented without creating an index (in DBMS terms). You should realize

Minimization with R nloptr package - multiple equality constraints

試著忘記壹切 提交于 2019-12-22 06:27:14
问题 Is it possible to specify more than one equality constraint in nloptr function in R? The code that I am trying to run is the following: eval_f <- function( x ) { return( list( "objective" = x[3]^2+x[4]^2, "gradient" = c( 0, 0, 2*x[3], 2*x[4] ) ) ) } # constraint functions # equalities eval_g_eq <- function( x ) { constr <- c( x[1] + x[2] + x[3] - 4, x[1]^2 + x[2]^2 + x[4] - 15 ) grad <- c( c(1, 1, 1, 0), c(2*x[1], 2*x[2], 0, 1) ) return( list( "constraints"=constr, "jacobian"=grad ) ) } #

create table constraint in mysql

你说的曾经没有我的故事 提交于 2019-12-22 05:27:08
问题 I have a table in which I have some columns a,b,c and for each column there is another column ,say, (x,y,z) which is dependent on a,b,c respectively. x,y,z will have value 1 if a,b,c has any value and will contain null if a,b,c has null . For an example Lets say, The values stored in a is 2 and x is the column dependent on it. So x will have value as 1 . If the values stored in a is null then x will have value as null . so is there a way in which we can declare this constraint at the time of

Unable to drop constraint in SQL server 2005, “Could not drop constraint. See previous errors”

穿精又带淫゛_ 提交于 2019-12-22 05:22:08
问题 I'm trying to drop a constraint on a DB table, something like: ALTER TABLE MyTable drop CONSTRAINT FK_MyTable_AnotherTable But the execution just runs and runs. If I stop it I see: Msg 3727, Level 16, State 0, Line 2 Could not drop constraint. See previous errors. Web search throws up various pages but note that the constraint is properly named and I am trying to remove it using the correct name 回答1: I was having the same issue on SQL Server 2008 R2 , I solved my problem with below line

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

别说谁变了你拦得住时间么 提交于 2019-12-22 03:45:23
问题 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

How do I define or reference a variable in SVG?

为君一笑 提交于 2019-12-22 03:36:51
问题 Might be you do not need variables for static images but this would be easier to inspect them and see related parts when everything is defined in terms of variables, IMO. It also simplifies update of the images. See how you do the constrains-based engineering drawing in SolidWorks. It basically makes the sizes of one object relative to the size (or another property) of the other. Can I similarly define an integer (width) or set a width of another object by referencing the width of a reference

iOS - proportional spacing with autolayout

一世执手 提交于 2019-12-22 03:21:22
问题 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