Browse Source

* Patch from Ludo, Foreign key support for SQLite option. Mantis #20865

git-svn-id: trunk@19872 -
marco 13 years ago
parent
commit
0b655b19d9
1 changed files with 7 additions and 0 deletions
  1. 7 0
      packages/fcl-db/src/sqldb/sqlite/sqlite3conn.pp

+ 7 - 0
packages/fcl-db/src/sqldb/sqlite/sqlite3conn.pp

@@ -16,6 +16,11 @@
 { 
 { 
   Based on an implementation by Martin Schreiber, part of MSEIDE.
   Based on an implementation by Martin Schreiber, part of MSEIDE.
   Reworked all code so it conforms to FCL coding standards.
   Reworked all code so it conforms to FCL coding standards.
+
+  TSQLite3Connection properties
+      Params - "foreign_keys=ON" - enable foreign key support for this connection:
+                                   http://www.sqlite.org/foreignkeys.html#fk_enable
+
 } 
 } 
  
  
 unit sqlite3conn;
 unit sqlite3conn;
@@ -708,6 +713,8 @@ begin
   InitializeSqlite(SQLiteLibraryName);
   InitializeSqlite(SQLiteLibraryName);
   str1:= databasename;
   str1:= databasename;
   checkerror(sqlite3_open(pchar(str1),@fhandle));
   checkerror(sqlite3_open(pchar(str1),@fhandle));
+  if Params.IndexOfName('foreign_keys') <> -1 then
+    execsql('PRAGMA foreign_keys =  '+Params.Values['foreign_keys']);
 end;
 end;
 
 
 procedure TSQLite3Connection.DoInternalDisconnect;
 procedure TSQLite3Connection.DoInternalDisconnect;