constraints

XML Serialize boolean as 0 and 1

╄→尐↘猪︶ㄣ 提交于 2019-11-29 13:22:02
The XML Schema Part 2 specifies that an instance of a datatype that is defined as boolean can have the following legal literals {true, false, 1, 0}. The following XML, for example, when deserialized, sets the boolean property "Emulate" to true . <root> <emulate>1</emulate> </root> However, when I serialize the object back to the XML, I get true instead of the numerical value. My question is, is there a way that I can control the boolean representation in the XML? You can implement IXmlSerializable which will allow you to alter the serialized output of your class however you want. This will

how to set scrollview content size with auto layout?

試著忘記壹切 提交于 2019-11-29 13:03:56
I have one screen where I have added 1 scroll view on self view. Tab bar and navigation bar both are there and for iPhone 4 view height is 455.I have added more content on scroll view.the height of scroll view and self view is same.but when i am unable to set content size for scroll view.even i set too it is not working.Please help me. Thanks Here is how to set up the size of the contentView in Auto Layout: Add a view to your scrollView. This should be the only top level view on your scrollView and it will serve as your contentView. Constrain the left, top, right, and bottom edges of this

Finding out reason of Pyomo model infeasibility

泪湿孤枕 提交于 2019-11-29 12:56:20
I got a pyomo concrete model with lots of variables and constraints. Somehow, one of the variable inside my model violates one constraint, which makes my model infeasible: WARNING: Loading a SolverResults object with a warning status into model=xxxx; message from solver=Model was proven to be infeasible. Is there a way to ask the solver, the reason of the infeasibility? So for example, lets assume I got a variable called x , and if I define following 2 constraints, model will be ofc. infeasible. const1: x >= 10 const2: x <= 5 And what I want to achieve that pointing out the constraints and

Equivalent to exclusion constraint composed of integer and range

淺唱寂寞╮ 提交于 2019-11-29 12:07:39
I need to have something equivalent to this exclusion constraint drop table if exists t; create table t ( i int, tsr tstzrange, exclude using gist (i with =, tsr with &&) ); ERROR: data type integer has no default operator class for access method "gist" HINT: You must specify an operator class for the index or define a default operator class for the data type. I guess the problem is obvious from the error message. How to do it? Erwin Brandstetter You need to install the additional module btree_gist to make it work. The module installs the missing operator class. Details in this related answer:

Solr - Block join Parent query with many Children constraints

久未见 提交于 2019-11-29 10:28:44
问题 The question is applied for the following nested documents: <doc> <field name="id">1</field> <field name="title">Solr has block join support</field> <field name="content_type">parentDocument</field> <doc> <field name="id">11</field> <field name="type">comment</field> <field name="comments">SolrCloud supports it too!</field> </doc> <doc> <field name="id">12</field> <field name="type">publisher</field> <field name="address">England</field> .... </doc> </doc> .... My question is, how to write

Adding an one-out-of-two not null constraint in postgresql

こ雲淡風輕ζ 提交于 2019-11-29 09:08:30
If I have a table in Postgresql: create table Education ( id integer references Profiles(id), finished YearValue not null, started YearValue, qualification text, schoolName text, studiedAt integer references Organizations(id), primary key (id) ); I need to make a constraint so that either schoolName or studiedAt needs to not be null (one of them has to have information in it). How do I do this? You can use a check constraint e.g. constraint chk_education check (schoolName is not null or studiedAt is not null) From the manual: A check constraint is the most generic constraint type. It allows

Why can I create a table with PRIMARY KEY on a nullable column?

蓝咒 提交于 2019-11-29 09:05:54
The following code creates a table without raising any errors: CREATE TABLE test( ID INTEGER NULL, CONSTRAINT PK_test PRIMARY KEY(ID) ) Note that I cannot insert a NULL, as expected: INSERT INTO test VALUES(1),(NULL) ERROR: null value in column "id" violates not-null constraint DETAIL: Failing row contains (null). ********** Error ********** ERROR: null value in column "id" violates not-null constraint SQL state: 23502 Detail: Failing row contains (null). Why can I create a table with a self-contradictory definition? ID column is explicitly declared as NULLable, and it is implicitly not

A constraint that only allows one of two tables to reference a base table

戏子无情 提交于 2019-11-29 07:31:18
I have 3 tables. A base table, call it Table A, and two tables that reference Table A, Call them Table X and Table Y. Both X and Y have a foreign key contraint that references Table A. The Foreign Key of X and Y is also their own Primary Key. I'd like to know if it is possible to add a constraint that will only allow one of these tables to contain a recrod that references Table A. So if X has a record that references A then Y can't have one and if Y has a record that references A then X can't have one. Is this possible? Thanks, gbn CHECK constraints with UDFs (which is Oded's answer) don't

How to keep foreign key relations consistent in a “diamond-shaped” system of relationships

不打扰是莪最后的温柔 提交于 2019-11-29 07:13:54
Consider this situation: a Car is bought from a Salesperson . A Salesperson works at a Showroom (and at only one Showroom). A Showroom is affiliated to a Manufacturer , and only sells cars made by that Manufacturer. At the same time, a Car is of a particular Model , and a Model is made by a Manufacturer. Restriction R: A Car's Model's Manufacturer must be the same Manufacturer as the Car's Salesperson's Showroom's affiliated Manufacturer. The diagram shows the obvious foreign key relationships. ----> Manufacturer <---- | | | | Showroom | ^ | | Model | ^ Salesperson | ^ | | | --------- Car ----

F# member constraints + ^a byref parameters

拟墨画扇 提交于 2019-11-29 06:55:30
After some playing around F# member constraints feature and writing function like this: let inline parse< ^a when ^a : (static member Parse: string -> ^a) > s = (^a: (static member Parse: string -> ^a) s) That works perfectly fine: let xs = [ "123"; "456"; "999" ] |> List.map parse<int> I'm trying to write other func tryParse , that uses static method TryParse and wraps the parse result into 'a option type for better support in F#. Something like this doesn't compiles: let inline tryParse s = let mutable x = Unchecked.defaultof< ^a> if (^a: (static member TryParse: string * ^a byref -> bool)