stevukas / phpliteadmin

Automatically exported from code.google.com/p/phpliteadmin
0 stars 0 forks source link

Adds Foreign Key Support. #217

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Adds foreign key support by turning foreign_keys pragma to on after the initial 
database connection. This PRAGMA statement should be ignored by SQLite 
databases less then 3.6.19.

http://www.sqlite.org/foreignkeys.html#fk_enable

Original issue reported on code.google.com by Dyg...@gmail.com on 25 May 2013 at 7:45

Attachments:

GoogleCodeExporter commented 9 years ago
Well, first of all, I guess we should make this at least configurable. There is 
a reason why SQLite does not turn this on by default (backward compatibility). 
We can turn it on by default, but we should at least provide an option to turn 
it off.

And of course this is only the starting point. Real foreign key support for 
phpLiteAdmin would mean that foreign key relationships could be created via GUI 
when creating or altering a table, that you could pick possible values of 
foreign keys via a dropdown menu when inserting or updating rows and so on.

But yes, I guess we should at least start with this PRAGMA.

Original comment by crazy4ch...@gmail.com on 4 Jun 2013 at 9:18

GoogleCodeExporter commented 9 years ago
That's the odd thing about FK support within SQLite. There is really no direct 
way to detect it from what I'm seeing. We'd have to call #PRAGMA 
compile_options; and then parse it to see that it does not have 
OMIT_FOREIGN_KEY set. That's the hacky solution that I can see, if you know of 
a direct yes / no please do let me know.

Original comment by Dyg...@gmail.com on 4 Jun 2013 at 10:00

GoogleCodeExporter commented 9 years ago
Well, detecting if FK support is at least available does not really help us. 
Because by default, FK support is disabled and people might use a db where FK 
constraints are defined but they don't want them to be enforced. Of course it 
does not make any sense to define FK constraints and not use them, but people 
might do so and rely on the fact that SQLite does not enforce them by default.

Checking whether FK support is available in the SQLite library is not really 
necessary as I think the PRAGMA does not do any harm if it is not available.

Original comment by crazy4ch...@gmail.com on 5 Jun 2013 at 7:28

GoogleCodeExporter commented 9 years ago

Original comment by crazy4ch...@gmail.com on 25 Dec 2013 at 4:19