Browse Source

fcl-db: tests: adapt some tests for Interbase XE
(Interbase and Firebird are not the same; f.e. Interbase does not support BIGINT data type, CTEs, Execute block, insert returning etc.)

git-svn-id: trunk@23069 -

lacak 12 years ago
parent
commit
d53b5371bb
2 changed files with 30 additions and 26 deletions
  1. 17 12
      packages/fcl-db/tests/sqldbtoolsunit.pas
  2. 13 14
      packages/fcl-db/tests/testfieldtypes.pas

+ 17 - 12
packages/fcl-db/tests/sqldbtoolsunit.pas

@@ -33,7 +33,7 @@ const MySQLConnTypes = [mysql40,mysql41,mysql50,mysql51,mysql55];
           'VARCHAR(10)',
           'VARCHAR(10)',
           'SMALLINT',
           'SMALLINT',
           'INTEGER',
           'INTEGER',
-          '',
+          '',             // ftWord
           'BOOLEAN',
           'BOOLEAN',
           'DOUBLE PRECISION', // ftFloat
           'DOUBLE PRECISION', // ftFloat
           '',             // ftCurrency
           '',             // ftCurrency
@@ -41,8 +41,8 @@ const MySQLConnTypes = [mysql40,mysql41,mysql50,mysql51,mysql55];
           'DATE',
           'DATE',
           'TIME',
           'TIME',
           'TIMESTAMP',    // ftDateTime
           'TIMESTAMP',    // ftDateTime
-          '',
-          '',
+          '',             // ftBytes
+          '',             // ftVarBytes
           '',             // ftAutoInc
           '',             // ftAutoInc
           'BLOB',         // ftBlob
           'BLOB',         // ftBlob
           'BLOB',         // ftMemo
           'BLOB',         // ftMemo
@@ -53,7 +53,7 @@ const MySQLConnTypes = [mysql40,mysql41,mysql50,mysql51,mysql55];
           '',
           '',
           '',
           '',
           'CHAR(10)',     // ftFixedChar
           'CHAR(10)',     // ftFixedChar
-          '',
+          '',             // ftWideString
           'BIGINT',       // ftLargeInt
           'BIGINT',       // ftLargeInt
           '',
           '',
           '',
           '',
@@ -67,8 +67,8 @@ const MySQLConnTypes = [mysql40,mysql41,mysql50,mysql51,mysql55];
           '',             // ftGuid
           '',             // ftGuid
           'TIMESTAMP',    // ftTimestamp
           'TIMESTAMP',    // ftTimestamp
           'NUMERIC(18,6)',// ftFmtBCD
           'NUMERIC(18,6)',// ftFmtBCD
-          '',
-          ''
+          '',             // ftFixedWideChar
+          ''              // ftWideMemo
         );
         );
              
              
 
 
@@ -195,17 +195,22 @@ begin
   FieldtypeDefinitions := FieldtypeDefinitionsConst;
   FieldtypeDefinitions := FieldtypeDefinitionsConst;
 
 
   case SQLServerType of
   case SQLServerType of
-    ssFirebird, ssInterbase:
+    ssFirebird:
       begin
       begin
       FieldtypeDefinitions[ftBoolean] := '';
       FieldtypeDefinitions[ftBoolean] := '';
-      FieldtypeDefinitions[ftMemo] := 'BLOB SUB_TYPE TEXT';
+      FieldtypeDefinitions[ftMemo]    := 'BLOB SUB_TYPE TEXT';
+      end;
+    ssInterbase:
+      begin
+      FieldtypeDefinitions[ftMemo]     := 'BLOB SUB_TYPE TEXT';
+      FieldtypeDefinitions[ftLargeInt] := 'NUMERIC(18,0)';
       end;
       end;
     ssMSSQL, ssSybase:
     ssMSSQL, ssSybase:
       // todo: Sybase: copied over MSSQL; verify correctness
       // todo: Sybase: copied over MSSQL; verify correctness
       begin
       begin
       FieldtypeDefinitions[ftBoolean] := 'BIT';
       FieldtypeDefinitions[ftBoolean] := 'BIT';
-      FieldtypeDefinitions[ftCurrency]:= 'MONEY';
       FieldtypeDefinitions[ftFloat]   := 'FLOAT';
       FieldtypeDefinitions[ftFloat]   := 'FLOAT';
+      FieldtypeDefinitions[ftCurrency]:= 'MONEY';
       FieldtypeDefinitions[ftDate]    := 'DATETIME';
       FieldtypeDefinitions[ftDate]    := 'DATETIME';
       FieldtypeDefinitions[ftTime]    := '';
       FieldtypeDefinitions[ftTime]    := '';
       FieldtypeDefinitions[ftDateTime]:= 'DATETIME';
       FieldtypeDefinitions[ftDateTime]:= 'DATETIME';
@@ -218,14 +223,14 @@ begin
     ssMySQL:
     ssMySQL:
       begin
       begin
       //MySQL recognizes BOOLEAN, but as synonym for TINYINT, not true sql boolean datatype
       //MySQL recognizes BOOLEAN, but as synonym for TINYINT, not true sql boolean datatype
-      FieldtypeDefinitions[ftBoolean] := '';
+      FieldtypeDefinitions[ftBoolean]  := '';
       // Use 'DATETIME' for datetime-fields instead of timestamp, because
       // Use 'DATETIME' for datetime-fields instead of timestamp, because
       // mysql's timestamps are only valid in the range 1970-2038.
       // mysql's timestamps are only valid in the range 1970-2038.
       // Downside is that fields defined as 'TIMESTAMP' aren't tested
       // Downside is that fields defined as 'TIMESTAMP' aren't tested
       FieldtypeDefinitions[ftDateTime] := 'DATETIME';
       FieldtypeDefinitions[ftDateTime] := 'DATETIME';
-      FieldtypeDefinitions[ftBytes] := 'BINARY(5)';
+      FieldtypeDefinitions[ftBytes]    := 'BINARY(5)';
       FieldtypeDefinitions[ftVarBytes] := 'VARBINARY(10)';
       FieldtypeDefinitions[ftVarBytes] := 'VARBINARY(10)';
-      FieldtypeDefinitions[ftMemo] := 'TEXT';
+      FieldtypeDefinitions[ftMemo]     := 'TEXT';
       end;
       end;
     ssOracle:
     ssOracle:
       begin
       begin

+ 13 - 14
packages/fcl-db/tests/testfieldtypes.pas

@@ -1237,7 +1237,7 @@ end;
 
 
 procedure TTestFieldTypes.TestInsertReturningQuery;
 procedure TTestFieldTypes.TestInsertReturningQuery;
 begin
 begin
-  if not(SQLConnType in [postgresql,interbase,oracle]) then Ignore(STestNotApplicable);
+  if not(SQLServerType in [ssFirebird, ssOracle, ssPostgreSQL]) then Ignore(STestNotApplicable);
   with TSQLDBConnector(DBConnector) do
   with TSQLDBConnector(DBConnector) do
     begin
     begin
     // This only works with databases that supports 'insert into .. returning'
     // This only works with databases that supports 'insert into .. returning'
@@ -1308,26 +1308,25 @@ begin
   // at least one row must be returned
   // at least one row must be returned
   with TSQLDBConnector(DBConnector) do
   with TSQLDBConnector(DBConnector) do
   begin
   begin
-    case SQLConnType of
-      sqlite3:
+    case SQLServerType of
+      ssSQLite:
         statements := TTestStatements.Create('pragma table_info(FPDEV)');
         statements := TTestStatements.Create('pragma table_info(FPDEV)');
-      interbase:
+      ssFirebird:
         statements := TTestStatements.Create(
         statements := TTestStatements.Create(
           CTE_SELECT (*FB 2.1*),
           CTE_SELECT (*FB 2.1*),
           'EXECUTE BLOCK RETURNS (U VARCHAR(255)) AS BEGIN SELECT rdb$get_context(''SYSTEM'',''CURRENT_USER'') FROM rdb$database INTO U; SUSPEND; END' (*FB 2.0*)
           'EXECUTE BLOCK RETURNS (U VARCHAR(255)) AS BEGIN SELECT rdb$get_context(''SYSTEM'',''CURRENT_USER'') FROM rdb$database INTO U; SUSPEND; END' (*FB 2.0*)
         );
         );
-      postgresql:
+      ssPostgreSQL:
         statements := TTestStatements.Create(CTE_SELECT);
         statements := TTestStatements.Create(CTE_SELECT);
-      mssql:
+      ssMSSQL:
         statements := TTestStatements.Create(CTE_SELECT  (*MS SQL 2005*));
         statements := TTestStatements.Create(CTE_SELECT  (*MS SQL 2005*));
+      ssMySQL:
+        statements := TTestStatements.Create(
+          'check table FPDEV',  // bug 14519
+          'show tables from '+Connection.DatabaseName  // bug 16842
+        )
       else
       else
-        if SQLConnType in MySQLConnTypes then
-          statements := TTestStatements.Create(
-            'check table FPDEV',  // bug 14519
-            'show tables from '+Connection.DatabaseName  // bug 16842
-          )
-        else
-          Ignore(STestNotApplicable);
+        Ignore(STestNotApplicable);
     end;
     end;
 
 
     for s in statements do
     for s in statements do
@@ -1798,7 +1797,7 @@ begin
         connection.ExecuteDirect('insert into TTTXY(ID,NP) values ('+inttostr(i)+',1)');
         connection.ExecuteDirect('insert into TTTXY(ID,NP) values ('+inttostr(i)+',1)');
         connection.ExecuteDirect('insert into TTTXY(ID,NP) values ('+inttostr(i)+',2)');
         connection.ExecuteDirect('insert into TTTXY(ID,NP) values ('+inttostr(i)+',2)');
         end;
         end;
-      Query.SQL.Text := 'select OBJ.ID, OBJ.NAME, count(XY.NP) as NPF from TTTOBJ as OBJ, TTTXY as XY where OBJ.ID=XY.ID group by OBJ.ID, OBJ.NAME';
+      Query.SQL.Text := 'select OBJ.ID, OBJ.NAME, count(XY.NP) as NPF from TTTOBJ OBJ, TTTXY XY where OBJ.ID=XY.ID group by OBJ.ID, OBJ.NAME';
       query.Prepare;
       query.Prepare;
       query.open;
       query.open;
       query.close;
       query.close;