samedi 19 septembre 2015

unique constraint violation on sqlite composite primary key

I have a table definition in sqlite like this:

CREATE TABLE baskets ( name TEXT NOT NULL, 
                       period TEXT NOT NULL, 
                       delay TEXT NOT NULL, 
                       profile TEXT NOT NULL, 
PRIMARY KEY (name, profile), 
FOREIGN KEY (profile) REFERENCES profiles (profile_name));

When try to insert a row with a non unique name i receive a SQLite code 19 error:

android.database.sqlite.SQLiteConstraintException: columns name, name are not unique (code 19)

The combination of values of primary key is unique, and sqlite is validating just the "name" value.

How can I solve this issue? I need that primary key.

For more information I'm developing in android SDK version 16.

Thansk a lot!

Aucun commentaire:

Enregistrer un commentaire