react-native-sqlite-storage
react-native-sqlite-storage copied to clipboard
the foreign key field accept values that doesn't exist
i created 3 tables test , images , services and all things were good .
the table images has a foreign key :
"CREATE TABLE IF NOT EXISTS images (ID INTEGER PRIMARY KEY AUTOINCREMENT , ID_TEST INTEGER , FOREIGN KEY (ID_TEST) REFERENCES test(ID))"
when i try to insert a new record ID_TEST field accepts everything even if the value given doesn't exist as ID to test table.
have you got any solution ?
it's been a while since i posted this issue and i didn't find any solution , so i went with another solution where i used another package called react native sqlite2 and the problem was solved.
db.executeSql('PRAGMA foreign_keys = ON'); Execute this after creating connection and it will solve your issue .. it worked for me.