Browse Source

* Allow generators in sqlite in 3.0.4

git-svn-id: trunk@42285 -
michael 6 years ago
parent
commit
ce68a56c01
1 changed files with 17 additions and 0 deletions
  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;