constraints

Android, handle SQLiteConstraintException

我们两清 提交于 2019-12-06 20:44:31
问题 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

Remove constraints in sequelize migration

为君一笑 提交于 2019-12-06 19:30:01
问题 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

Fluent NHibernate primary key constraint naming conventions

こ雲淡風輕ζ 提交于 2019-12-06 18:29:47
问题 Is there any way to create a naming convention for my primary key constraints in Fluent NHibernate? I know you can name foreign key constraints, but it does not appear possible to name the primary key constraint. 回答1: James Gregory from FNH says... No, that's not supported through NHibernate, so we can't support it either. http://groups.google.com/group/fluent-nhibernate/browse_thread/thread/9ea7155407d33772 来源: https://stackoverflow.com/questions/1358043/fluent-nhibernate-primary-key

Dart, constraints on Generics?

强颜欢笑 提交于 2019-12-06 17:55:30
问题 Is there a Dart equivalent syntax to the c# ability to specify type constraints on a generic type, e.g. in C#-like syntax where TBase is SomeType : class StackPanel<TBase> extends Panel<TBase> where TBase : SomeType{ } 回答1: You can specify type constraints like this : class StackPanel<TBase extends SomeType> extends Panel<TBase> { } The language specification says : A type parameter T may be suffixed with an extends clause that specifies the upper bound for T . If no extends clause is present

How to add constraints programmatically to a programmatically created UIView?

倖福魔咒の 提交于 2019-12-06 17:25:34
问题 I have created a UIView using the following code within viewDidLoad (where 'secondview' obviously is the name of the UIView): secondview = [[UIView alloc] initWithFrame:self.view.frame]; [secondview setBackgroundColor: [UIColor yellowColor]]; secondview.translatesAutoresizingMaskIntoConstraints = NO; [self.view addSubview:secondview]; Then within viewDidAppear I added constraints to this view: NSLayoutConstraint *constraint = [NSLayoutConstraint constraintWithItem:secondview attribute

Is this possible in Oracle/Sql?

六月ゝ 毕业季﹏ 提交于 2019-12-06 16:09:52
I have two tables: CREATE TABLE Event_details( event_no INTEGER AUTOINCREMENT NOT NULL, no_players INTEGER NOT NULL, game_type VARCHAR(20) NOT NULL, payout_positions INTEGER NOT NULL, PRIMARY KEY(event_no) CONSTRAINT check_game_type CHECK(game_type IN ('NLH','NLO','PLO','PLH','STUD','HORSE') CONSTRAINT check_no_players CHECK (no_players > 1) CONSTRAINT check_payouts CHECK (payout_positions > 0 AND payout_positions < no_players)); CREATE TABLE Venue( venue_no INTEGER AUTOINCREMENT NOT NULL, name VARCHAR(20) NOT NULL, location VARCHAR(20) NOT NULL, capacity INTEGER NOT NULL, PRIMARY KEY (venue

UISlider Handle Changes Width on Different Size iPads

梦想的初衷 提交于 2019-12-06 15:48:38
I have a vertical slider which uses the following code to generate a handle image within its custom class: func generateHandleImage(with color: UIColor) -> UIImage { let rect = CGRect(x: 0, y: 0, width: (superview?.bounds.size.height)! * 0.07, height: (superview?.bounds.size.width)!) return UIGraphicsImageRenderer(size: rect.size).image { (imageContext) in imageContext.cgContext.setFillColor(color.cgColor) imageContext.cgContext.fill(rect.insetBy(dx: 0, dy: 0)) } } I have set the autolayout constraints in IB for the slider for it to be centered in the x & y axes of it's superview and equal

Hibernate check deletion constraints

泪湿孤枕 提交于 2019-12-06 15:28:05
I am using Spring - Hibernate to control models in my application. The models are linked to each other (one-to-many, many-to-many, almost kinds of relationships), and now I have a problem when deleting one entity which is being used by other entities. The problem is I want to show the detail message that informs exactly what other objects (type, name) are using the entity that I am going to delete. It's not the common message about Constraint violation that Hibernate throws me. For example: Car --> Person, House --> Person ; then when I delete one Person who has a car and house, the message

DBUnit Sybase unable to CLEAN_INSERT

馋奶兔 提交于 2019-12-06 15:14:19
According to the DBUnit docs link it should support using a CLEAN_INSERT when using a DatabaseSequenceFilter. I get the following exception when attempting this com.sybase.jdbc2.jdbc.SybSQLException: Dependent foreign key constraint violation in a referential integrity constraint. dbname = 'my_db', table name = 'tbl_child', constraint name = 'fk_tbl_child_parentid'. My tables look like this: CREATE TABLE dbo.tbl_parent ( parent_id numeric(19,0) IDENTITY, ... ) CREATE TABLE dbo.tbl_child ( child_id numeric(19,0) IDENTITY, parent_id numeric(19,0) NOT NULL, ... ) ALTER TABLE dbo.tbl_child ADD

How to constrain the number of records allowed in an SQL table?

£可爱£侵袭症+ 提交于 2019-12-06 14:48:54
问题 Say I have two tables, Parent and Child. Parent has a MaxChildren (int) field and Child has an Enabled (bit) field and a ParentID (int) field linking back to the parent record. I'd like to have a constraint such that there can't be more than MaxChildren records for each parent where Enabled = 1. This would mean that any attempt to insert or update any record in the Child table will fail if it goes over the applicable MaxChildren value, or any attempt to lower MaxChildren to below the current