Sqlite3 - foreign key mismatch on BLOB -


i using foreign keys, unfortunately in case bellow not able solve mismatch... missing? tebles created by:

create table if not exists `devices` (     `guid`  blob not null,     `device_name`   text not null,     `class` integer not null );  create table if not exists `device_states` (     `guid_d`    blob not null,     `id_d`  text default null,     `tp`    integer not null,     `state` integer not null,     `note`  text default null,     `status`    integer not null default 0,     primary key(`guid_d`,`tp`),     foreign key(`guid_d`) references devices ( `guid` ) on delete restrict ); create index if not exists idx_ds_tp on device_states(`tp`);  insert or ignore `devices` values (x'438d6e77dc3946a4819617adba18adb2','guid_door', 1); 

the select bellow works expected:

select * `devices` guid = x'438d6e77dc3946a4819617adba18adb2'; 

1 rows returned from: select * devices guid = x'438d6e77dc3946a4819617adba18adb2'; (took 1ms)

however, when try insert data devices table, error...

insert device_states (guid_d, id_d, tp, state, note, status)  values (x'438d6e77dc3946a4819617adba18adb2', "d", 132456, 1, "door open", 2); 

foreign key mismatch - "device_states" referencing "devices": insert device_states (guid_d, id_d, tp, state, note, status) values (x'438d6e77dc3946a4819617adba18adb2', "d", 132456, 1, "door open", 2);

does see issue??? lot!

the documentation says:

usually, parent key of foreign key constraint primary key of parent table. if not primary key, parent key columns must collectively subject unique constraint or have unique index.

there no such constraint on guid.


Comments

Popular posts from this blog

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

html - Outlook 2010 Anchor (url/address/link) -

android - How to create dynamically Fragment pager adapter -