Преглед изворни кода

* Allow generators in sqlite in 3.0.4

git-svn-id: trunk@42285 -
michael пре 6 година
родитељ
комит
ce68a56c01
1 измењених фајлова са 17 додато и 0 уклоњено
  1. 17 0
      packages/fcl-web/src/restbridge/sqldbrestdata.pp

+ 17 - 0
packages/fcl-web/src/restbridge/sqldbrestdata.pp

@@ -715,6 +715,23 @@ function TSQLDBRestDBHandler.GetGeneratorValue(const aGeneratorName: String
   ): Int64;
 
 begin
+{$IFDEF VER3_0_4}
+  // The 'get next value' SQL in 3.0.4 is wrong, so we need to do this sep
+  if (IO.Connection is TSQLConnector) and SameText((IO.Connection as TSQLConnector).ConnectorType,'Sqlite3') then
+    begin
+    With CreateQuery('SELECT seq+1 FROM sqlite_sequence WHERE name=:aName') do
+      Try
+        ParamByName('aName').AsString:=aGeneratorName;
+        Open;
+        if (EOF and BOF) then
+          DatabaseErrorFmt('Generator %s does not exist',[aGeneratorName]);
+        Result:=Fields[0].asLargeint;
+      Finally
+        Free;
+      end;
+    end
+  else
+{$ENDIF}
   Result:=IO.Connection.GetNextValue(aGeneratorName,1);
 end;