浏览代码

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

git-svn-id: trunk@19872 -
marco 13 年之前
父节点
当前提交
0b655b19d9
共有 1 个文件被更改,包括 7 次插入0 次删除
  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;