why foreign key doesn't work in websql..?

梦想与她 提交于 2019-12-05 17:20:15
Martijn

Is the INSERT performed on the same database connection as the CREATE? Because the PRAGMA foreign_keys = ON is only valid for the connection. It has to be executed for each connection you open.

Also, make sure that you run that PRAGMA statement when you’re not in a transaction, since that wouldn’t have any effect. Your example code starting with tx. suggests that is the cause of your problem.

UPDATE As pointed out in the comments by MisterSmith, extensions of Chromium-based browsers can't run SQL statements outside a transaction anyway, so no foreign key enforcement is possible.

So, you’ll have to ensure your foreign keys maintain integrity either in your application code, or you can write triggers to enforce the foreign keys (if triggers are permitted to Chromium extensions, that is).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!