Browse Source

--- Merging r20656 into '.':
C packages/fcl-db/tests/sqldbtoolsunit.pas
--- Merging r22668 into '.':
C packages/fcl-db/tests/testfieldtypes.pas
Summary of conflicts:
Text conflicts: 2

# revisions: 20656,22668
r20656 | marco | 2012-03-29 20:13:20 +0200 (Thu, 29 Mar 2012) | 3 lines
Changed paths:
M /trunk/packages/fcl-db/tests/sqldbtoolsunit.pas

* disable some dbtypes for win64 that have no know working clientlib,
patch by Reinier, Mantis #21579
r22668 | lacak | 2012-10-16 12:57:08 +0200 (Tue, 16 Oct 2012) | 1 line
Changed paths:
M /trunk/packages/fcl-db/tests/testfieldtypes.pas

Adds test for Firebird's EXECUTE BLOCK RETURNS statement, which returns resultset. Test correct detection of StatementType. Mantis #0022972

git-svn-id: branches/fixes_2_6@24926 -

marco 12 years ago
parent
commit
eb54da314b
2 changed files with 58 additions and 6 deletions
  1. 12 5
      packages/fcl-db/tests/sqldbtoolsunit.pas
  2. 46 1
      packages/fcl-db/tests/testfieldtypes.pas

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

@@ -7,16 +7,21 @@ interface
 uses
   Classes, SysUtils, toolsunit
   ,db, sqldb
-  ,mysql40conn, mysql41conn, mysql50conn, mysql51conn, mysql55conn
-  ,ibconnection
+  ,mysql40conn, mysql41conn, mysql50conn, mysql51conn, mysql55conn,ibconnection
+  {$IFNDEF WIN64}
+  {See packages\fcl-db\src\sqldb\postgres\fpmake.pp: postgres connector won't be present on Win64}
   ,pqconnection
+  {$ENDIF WIN64}
   ,odbcconn
   {$IFNDEF WIN64}
   {See packages\fcl-db\fpmake.pp: Oracle connector is not built if PostgreSQL connectoris not built}
   ,oracleconnection
   {$ENDIF WIN64}
   ,sqlite3conn
+  {$IFNDEF WIN64}
+  {This won't be available on Windows 64, either; perhaps other systems as well}
   ,mssqlconn
+  {$ENDIF WIN64}
   ;
 
 type TSQLDBTypes = (mysql40,mysql41,mysql50,mysql51,mysql55,postgresql,interbase,odbc,oracle,sqlite3,mssql,sybase);
@@ -150,7 +155,7 @@ begin
     FieldtypeDefinitions[ftVarBytes] := 'VARBINARY(10)';
     FieldtypeDefinitions[ftMemo] := 'CLOB'; //or TEXT SQLite supports both, but CLOB is sql standard (TEXT not)
     end;
-  {$IFNDEF win64}
+  {$IFNDEF Win64}    
   if SQLDbType = POSTGRESQL then
     begin
     Fconnection := tPQConnection.Create(nil);
@@ -159,7 +164,7 @@ begin
     FieldtypeDefinitions[ftMemo] := 'TEXT';
     FieldtypeDefinitions[ftGraphic] := '';
     end;
-  {$ENDIF win64}
+  {$ENDIF Win64}
   if SQLDbType = INTERBASE then
     begin
     Fconnection := tIBConnection.Create(nil);
@@ -170,6 +175,7 @@ begin
   {$IFNDEF Win64}
   if SQLDbType = ORACLE then Fconnection := TOracleConnection.Create(nil);
   {$ENDIF Win64}
+  {$IFNDEF Win64}
   if SQLDbType in [MSSQL,Sybase] then
     // todo: Sybase: copied over MSSQL; verify correctness
     begin
@@ -185,6 +191,7 @@ begin
     FieldtypeDefinitions[ftMemo]    := 'TEXT';
     FieldtypeDefinitions[ftGraphic] := '';
     end;
+  {$ENDIF Win64}
 
   if SQLDbType in [mysql40,mysql41,mysql50,mysql51,mysql55,odbc] then
     begin
@@ -225,7 +232,7 @@ begin
       testValues[ftFixedChar,t] := PadRight(testValues[ftFixedChar,t], 10);
 
 
-  if not assigned(Fconnection) then writeln('Invalid database-type, check if a valid database-type was provided in the file ''database.ini''');
+  if not assigned(Fconnection) then writeln('Invalid database type, check if a valid database type for your achitecture was provided in the file ''database.ini''');
 
   with Fconnection do
     begin

+ 46 - 1
packages/fcl-db/tests/testfieldtypes.pas

@@ -61,7 +61,8 @@ type
     procedure TestScript;
     procedure TestInsertReturningQuery;
     procedure TestOpenStoredProc;
-
+    procedure TestOpenSpecialStatements;
+    
     procedure TestTemporaryTable;
     procedure TestRefresh;
 
@@ -1278,6 +1279,50 @@ begin
   end;
 end;
 
+procedure TTestFieldTypes.TestOpenSpecialStatements;
+const CTE_SELECT = 'WITH a AS (SELECT * FROM FPDEV) SELECT * FROM a';
+type TTestStatements = array of string;
+var statements: TTestStatements;
+    s: string;
+begin
+  // tests non-select statements (other than "SELECT ..."), which return result-set
+  // at least one row must be returned
+  with TSQLDBConnector(DBConnector) do
+  begin
+    case SQLDbType of
+      sqlite3:
+        statements := TTestStatements.Create('pragma table_info(FPDEV)');
+      interbase:
+        statements := TTestStatements.Create(
+          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*)
+        );
+      postgresql:
+        statements := TTestStatements.Create(CTE_SELECT);
+      mssql:
+        statements := TTestStatements.Create(CTE_SELECT  (*MS SQL 2005*));
+      else
+        if SQLdbType in MySQLdbTypes then
+          statements := TTestStatements.Create(
+            'check table FPDEV',  // bug 14519
+            'show tables from '+Connection.DatabaseName  // bug 16842
+          )
+        else
+          Ignore(STestNotApplicable);
+    end;
+
+    for s in statements do
+    begin
+      Query.SQL.Text := s;
+      Query.Open;
+      AssertTrue(Query.FieldCount>0);
+      AssertFalse('Eof after open', Query.Eof);
+      Query.Next;
+      Query.Close;
+    end;
+  end;
+end;
+
 procedure TTestFieldTypes.TestClearUpdateableStatus;
 // Test if CanModify is correctly disabled in case of a select query without
 // a from-statement.