sqlite_orm
sqlite_orm copied to clipboard
Delete a foreign key
Is there a way to delete a foreign key? I have two tables, A and B. Rows in A refer to rows in B. I would like to delete a row in B, and to reset the foreign key in A. How do I do that?
Example: class A: int _id; string name; std:shared_ptr key;
class B: int _id; I tried to reset the key ptr and update the row, but reveiced "FOREIGN KEY constraint failed: constraint failed"; Also tried to do key = nullptr, but the same error.
Yotam
first you need to remove A column values in all rows which have values equal to fk you want to remove. Next remove B row
And how do I remove values from a specific column in the row? I tried to use storage.update with a nullptr value for the key variable, but that didn't work.
And how do I remove values from a specific column in the row?
How do you do same things with raw SQLite? You can either remove the whole row with DELETE FROM ... or by UPDATE.
Anyway how would you do the same in raw SQLite? When you understand what to do with raw SQLite (e.g. with any SQLite client) you will understand what to do with sqlite_orm
@yotamkr is this issue actual?
Not anymore