|
@@ -50,11 +50,11 @@ type
|
|
|
procedure TestGetFieldNames;
|
|
|
procedure TestUpdateIndexDefs;
|
|
|
procedure TestMultipleFieldPKIndexDefs;
|
|
|
+ procedure TestGetIndexDefs;
|
|
|
procedure TestSetBlobAsMemoParam;
|
|
|
procedure TestSetBlobAsBlobParam;
|
|
|
procedure TestSetBlobAsStringParam;
|
|
|
procedure TestNonNullableParams;
|
|
|
- procedure TestGetIndexDefs;
|
|
|
procedure TestDblQuoteEscComments;
|
|
|
procedure TestpfInUpdateFlag; // bug 7565
|
|
|
procedure TestInt;
|
|
@@ -88,7 +88,9 @@ type
|
|
|
procedure TestStringParamQuery;
|
|
|
procedure TestFixedStringParamQuery;
|
|
|
procedure TestDateParamQuery;
|
|
|
+ procedure TestSmallIntParamQuery;
|
|
|
procedure TestIntParamQuery;
|
|
|
+ procedure TestLargeIntParamQuery;
|
|
|
procedure TestTimeParamQuery;
|
|
|
procedure TestDateTimeParamQuery;
|
|
|
procedure TestFmtBCDParamQuery;
|
|
@@ -114,6 +116,7 @@ type
|
|
|
procedure TestSQLLargeint;
|
|
|
procedure TestSQLInterval;
|
|
|
procedure TestSQLIdentity;
|
|
|
+ procedure TestSQLReal;
|
|
|
end;
|
|
|
|
|
|
implementation
|
|
@@ -184,7 +187,7 @@ begin
|
|
|
AFld3.FieldName := 'CALCFLD';
|
|
|
AFld3.DataSet := ds;
|
|
|
Afld3.FieldKind := fkCalculated;
|
|
|
- AFld3.ProviderFlags := [];
|
|
|
+ AFld3.ProviderFlags := []; // do not include calculated fields into generated sql insert/update
|
|
|
|
|
|
Open;
|
|
|
Edit;
|
|
@@ -218,13 +221,13 @@ begin
|
|
|
script.append('create table b (id int);');
|
|
|
ExecuteScript;
|
|
|
// Firebird/Interbase need a commit after a DDL statement. Not necessary for the other connections
|
|
|
- if SQLConnType=interbase then TSQLDBConnector(DBConnector).Transaction.CommitRetaining;
|
|
|
+ TSQLDBConnector(DBConnector).CommitDDL;
|
|
|
end;
|
|
|
finally
|
|
|
TSQLDBConnector(DBConnector).Connection.ExecuteDirect('drop table a');
|
|
|
TSQLDBConnector(DBConnector).Connection.ExecuteDirect('drop table b');
|
|
|
// Firebird/Interbase need a commit after a DDL statement. Not necessary for the other connections
|
|
|
- if SQLConnType=interbase then TSQLDBConnector(DBConnector).Transaction.CommitRetaining;
|
|
|
+ TSQLDBConnector(DBConnector).CommitDDL;
|
|
|
end;
|
|
|
end;
|
|
|
|
|
@@ -257,8 +260,8 @@ procedure TTestFieldTypes.TestLargeRecordSize;
|
|
|
begin
|
|
|
TSQLDBConnector(DBConnector).Connection.ExecuteDirect('create table FPDEV2 (plant varchar(8192),sampling_type varchar(8192),area varchar(8192), area_description varchar(8192), batch varchar(8192), sampling_datetime timestamp, status varchar(8192), batch_commentary varchar(8192))');
|
|
|
|
|
|
-// Firebird/Interbase need a commit after a DDL statement. Not necessary for the other connections
|
|
|
- if UpperCase(dbconnectorparams)='INTERBASE' then TSQLDBConnector(DBConnector).Transaction.CommitRetaining;
|
|
|
+ // Firebird/Interbase need a commit after a DDL statement. Not necessary for the other connections
|
|
|
+ TSQLDBConnector(DBConnector).CommitDDL;
|
|
|
|
|
|
with TSQLDBConnector(DBConnector).Query do
|
|
|
begin
|
|
@@ -302,7 +305,7 @@ begin
|
|
|
else
|
|
|
s := ', N19_0 NUMERIC(19,0)';
|
|
|
Connection.ExecuteDirect('create table FPDEV2 (FT NUMERIC(18,4), N4_2 NUMERIC(4,2), N9_3 NUMERIC(9,3), N9_5 NUMERIC(9,5), N18_0 NUMERIC(18,0), N18_3 NUMERIC(18,3), N18_5 NUMERIC(18,5)' + s + ')');
|
|
|
- Transaction.CommitRetaining;
|
|
|
+ CommitDDL;
|
|
|
|
|
|
with Query do
|
|
|
begin
|
|
@@ -470,8 +473,6 @@ begin
|
|
|
else
|
|
|
TSQLDBConnector(DBConnector).Connection.ExecuteDirect('insert into FPDEV2 (FT) values (''' + testDateValues[i] + ''')');
|
|
|
|
|
|
-// TSQLDBConnector(DBConnector).Transaction.CommitRetaining; // For debug-purposes
|
|
|
-
|
|
|
with TSQLDBConnector(DBConnector).Query do
|
|
|
begin
|
|
|
Open;
|
|
@@ -491,7 +492,7 @@ var s : string;
|
|
|
|
|
|
begin
|
|
|
TSQLDBConnector(DBConnector).Connection.ExecuteDirect('create table FPDEV2 (ID int,FT '+FieldtypeDefinitions[ftblob]+')');
|
|
|
- TSQLDBConnector(DBConnector).Transaction.CommitRetaining; // For interbase
|
|
|
+ TSQLDBConnector(DBConnector).CommitDDL;
|
|
|
|
|
|
TSQLDBConnector(DBConnector).Connection.ExecuteDirect('insert into FPDEV2 (ID,FT) values (1,''Test deze blob'')');
|
|
|
|
|
@@ -537,8 +538,6 @@ begin
|
|
|
TSQLDBConnector(DBConnector).Connection.ExecuteDirect('insert into FPDEV2 (FT) values (''Test deze blob'')');
|
|
|
TSQLDBConnector(DBConnector).Connection.ExecuteDirect('insert into FPDEV2 (FT) values (Null)');
|
|
|
|
|
|
-// TSQLDBConnector(DBConnector).Transaction.CommitRetaining; // For debug-purposes
|
|
|
-
|
|
|
with TSQLDBConnector(DBConnector).Query do
|
|
|
begin
|
|
|
Open;
|
|
@@ -568,12 +567,6 @@ begin
|
|
|
end;
|
|
|
end;
|
|
|
|
|
|
-procedure TTestFieldTypes.TestSetBlobAsStringParam;
|
|
|
-
|
|
|
-begin
|
|
|
- TestSetBlobAsParam(1);
|
|
|
-end;
|
|
|
-
|
|
|
|
|
|
procedure TTestFieldTypes.TestBlob;
|
|
|
|
|
@@ -583,8 +576,6 @@ begin
|
|
|
|
|
|
TSQLDBConnector(DBConnector).Connection.ExecuteDirect('insert into FPDEV2 (FT) values (''Test deze blob'')');
|
|
|
|
|
|
-// TSQLDBConnector(DBConnector).Transaction.CommitRetaining; // For debug-purposes
|
|
|
-
|
|
|
with TSQLDBConnector(DBConnector).Query do
|
|
|
begin
|
|
|
Open;
|
|
@@ -690,8 +681,8 @@ end;
|
|
|
procedure TTestFieldTypes.TestNullValues;
|
|
|
begin
|
|
|
TSQLDBConnector(DBConnector).Connection.ExecuteDirect('create table FPDEV2 (FIELD1 INT, FIELD2 INT)');
|
|
|
-// Firebird/Interbase need a commit after a DDL statement. Not necessary for the other connections
|
|
|
- TSQLDBConnector(DBConnector).Transaction.CommitRetaining;
|
|
|
+ // Firebird/Interbase need a commit after a DDL statement. Not necessary for the other connections
|
|
|
+ TSQLDBConnector(DBConnector).CommitDDL;
|
|
|
|
|
|
TSQLDBConnector(DBConnector).Connection.ExecuteDirect('insert into FPDEV2 (FIELD1) values (1)');
|
|
|
|
|
@@ -708,11 +699,15 @@ end;
|
|
|
|
|
|
|
|
|
procedure TTestFieldTypes.TestParamQuery;
|
|
|
+// Tests running insert queries using parameters
|
|
|
+const
|
|
|
+ DecoyFieldData1='decoytest';
|
|
|
+ DecoyFieldData2=':decoy ::test $decoy2 $$2';
|
|
|
begin
|
|
|
TSQLDBConnector(DBConnector).Connection.ExecuteDirect('create table FPDEV2 (FIELD1 INT, FIELD2 INT, FIELD3 INT, DECOY VARCHAR(30))');
|
|
|
|
|
|
-// Firebird/Interbase need a commit after a DDL statement. Not necessary for the other connections
|
|
|
- TSQLDBConnector(DBConnector).Transaction.CommitRetaining;
|
|
|
+ // Firebird/Interbase need a commit after a DDL statement. Not necessary for the other connections
|
|
|
+ TSQLDBConnector(DBConnector).CommitDDL;
|
|
|
|
|
|
with TSQLDBConnector(DBConnector).Query do
|
|
|
begin
|
|
@@ -722,7 +717,7 @@ begin
|
|
|
ExecSQL;
|
|
|
|
|
|
sql.clear;
|
|
|
- sql.append('insert into FPDEV2 (field1,field2,decoy) values (:field1,:field2,''decoytest'')');
|
|
|
+ sql.append('insert into FPDEV2 (field1,field2,decoy) values (:field1,:field2,'''+DecoyFieldData1+''')');
|
|
|
Params.ParamByName('field1').AsInteger := 2;
|
|
|
Params.ParamByName('field2').DataType := ftInteger;
|
|
|
Params.ParamByName('field2').Value := Null;
|
|
@@ -736,7 +731,7 @@ begin
|
|
|
ExecSQL;
|
|
|
|
|
|
sql.clear;
|
|
|
- sql.append('insert into FPDEV2 (field1,field2,field3,decoy) values (:field1,:field2,:field3,'':decoy ::test $decoy2 $$2'')');
|
|
|
+ sql.append('insert into FPDEV2 (field1,field2,field3,decoy) values (:field1,:field2,:field3,'''+DecoyFieldData2+''')');
|
|
|
Params.ParamByName('field1').AsInteger := 4;
|
|
|
Params.ParamByName('field2').AsInteger := 2;
|
|
|
Params.ParamByName('field3').AsInteger := 3;
|
|
@@ -759,7 +754,7 @@ begin
|
|
|
AssertEquals(2,FieldByName('FIELD1').asinteger);
|
|
|
AssertTrue(FieldByName('FIELD2').IsNull);
|
|
|
AssertTrue(FieldByName('FIELD3').IsNull);
|
|
|
- AssertEquals('decoytest',FieldByName('DECOY').AsString);
|
|
|
+ AssertEquals(DecoyFieldData1,FieldByName('DECOY').AsString);
|
|
|
next;
|
|
|
AssertEquals(3,FieldByName('FIELD1').asinteger);
|
|
|
AssertEquals(2,FieldByName('FIELD2').asinteger);
|
|
@@ -769,7 +764,7 @@ begin
|
|
|
AssertEquals(4,FieldByName('FIELD1').asinteger);
|
|
|
AssertEquals(2,FieldByName('FIELD2').asinteger);
|
|
|
AssertEquals(3,FieldByName('FIELD3').asinteger);
|
|
|
- AssertEquals(':decoy ::test $decoy2 $$2',FieldByName('DECOY').AsString);
|
|
|
+ AssertEquals(DecoyFieldData2,FieldByName('DECOY').AsString);
|
|
|
next;
|
|
|
AssertEquals(5,FieldByName('FIELD1').asinteger);
|
|
|
AssertEquals(2,FieldByName('FIELD2').asinteger);
|
|
@@ -781,14 +776,24 @@ begin
|
|
|
TSQLDBConnector(DBConnector).Transaction.CommitRetaining;
|
|
|
end;
|
|
|
|
|
|
+procedure TTestFieldTypes.TestSmallIntParamQuery;
|
|
|
+begin
|
|
|
+ TestXXParamQuery(ftSmallInt,FieldtypeDefinitions[ftSmallInt],testValuesCount);
|
|
|
+end;
|
|
|
+
|
|
|
procedure TTestFieldTypes.TestIntParamQuery;
|
|
|
begin
|
|
|
TestXXParamQuery(ftInteger,'INT',testIntValuesCount);
|
|
|
end;
|
|
|
|
|
|
+procedure TTestFieldTypes.TestLargeIntParamQuery;
|
|
|
+begin
|
|
|
+ TestXXParamQuery(ftLargeInt,FieldtypeDefinitions[ftLargeInt],testValuesCount);
|
|
|
+end;
|
|
|
+
|
|
|
procedure TTestFieldTypes.TestFmtBCDParamQuery;
|
|
|
begin
|
|
|
- TestXXParamQuery(ftFMTBcd,FieldtypeDefinitionsConst[ftFMTBcd],testValuesCount);
|
|
|
+ TestXXParamQuery(ftFMTBcd,FieldtypeDefinitions[ftFMTBcd],testValuesCount);
|
|
|
end;
|
|
|
|
|
|
procedure TTestFieldTypes.TestDateParamQuery;
|
|
@@ -796,6 +801,11 @@ begin
|
|
|
TestXXParamQuery(ftDate,FieldtypeDefinitions[ftDate],testDateValuesCount);
|
|
|
end;
|
|
|
|
|
|
+procedure TTestFieldTypes.TestCrossStringDateParam;
|
|
|
+begin
|
|
|
+ TestXXParamQuery(ftDate,FieldtypeDefinitions[ftDate],testDateValuesCount,True);
|
|
|
+end;
|
|
|
+
|
|
|
procedure TTestFieldTypes.TestTimeParamQuery;
|
|
|
begin
|
|
|
TestXXParamQuery(ftTime,FieldtypeDefinitions[ftTime],testValuesCount);
|
|
@@ -854,8 +864,8 @@ begin
|
|
|
|
|
|
TSQLDBConnector(DBConnector).Connection.ExecuteDirect('create table FPDEV2 (ID INT, FIELD1 '+ASQLTypeDecl+')');
|
|
|
|
|
|
-// Firebird/Interbase need a commit after a DDL statement. Not necessary for the other connections
|
|
|
- if SQLConnType=interbase then TSQLDBConnector(DBConnector).Transaction.CommitRetaining;
|
|
|
+ // Firebird/Interbase need a commit after a DDL statement. Not necessary for the other connections
|
|
|
+ TSQLDBConnector(DBConnector).CommitDDL;
|
|
|
|
|
|
with TSQLDBConnector(DBConnector).Query do
|
|
|
begin
|
|
@@ -870,7 +880,9 @@ begin
|
|
|
begin
|
|
|
Params.ParamByName('id').AsInteger := i;
|
|
|
case ADataType of
|
|
|
- ftInteger: Params.ParamByName('field1').asInteger := testIntValues[i];
|
|
|
+ ftSmallInt: Params.ParamByName('field1').AsSmallInt := testSmallIntValues[i];
|
|
|
+ ftInteger: Params.ParamByName('field1').AsInteger := testIntValues[i];
|
|
|
+ ftLargeInt: Params.ParamByName('field1').AsLargeInt := testLargeIntValues[i];
|
|
|
ftBoolean: Params.ParamByName('field1').AsBoolean := testBooleanValues[i];
|
|
|
ftFloat : Params.ParamByName('field1').AsFloat := testFloatValues[i];
|
|
|
ftBCD : Params.ParamByName('field1').AsCurrency:= testBCDValues[i];
|
|
@@ -906,7 +918,9 @@ begin
|
|
|
begin
|
|
|
AssertEquals(i,FieldByName('ID').AsInteger);
|
|
|
case ADataType of
|
|
|
+ ftSmallInt: AssertEquals(testSmallIntValues[i],FieldByName('FIELD1').AsInteger);
|
|
|
ftInteger: AssertEquals(testIntValues[i],FieldByName('FIELD1').AsInteger);
|
|
|
+ ftLargeInt: AssertEquals(testLargeIntValues[i],FieldByName('FIELD1').AsLargeInt);
|
|
|
ftBoolean: AssertEquals(testBooleanValues[i],FieldByName('FIELD1').AsBoolean);
|
|
|
ftFloat : AssertEquals(testFloatValues[i],FieldByName('FIELD1').AsFloat);
|
|
|
ftBCD : AssertEquals(testBCDValues[i],FieldByName('FIELD1').AsCurrency);
|
|
@@ -928,10 +942,12 @@ begin
|
|
|
TSQLDBConnector(DBConnector).Transaction.CommitRetaining;
|
|
|
end;
|
|
|
|
|
|
+
|
|
|
procedure TTestFieldTypes.TestSetBlobAsParam(asWhat: integer);
|
|
|
+const
|
|
|
+ TestValue='Test deze BLob';
|
|
|
var
|
|
|
ASQL : TSQLQuery;
|
|
|
-
|
|
|
begin
|
|
|
CreateTableWithFieldType(ftBlob,FieldtypeDefinitions[ftBlob]);
|
|
|
TestFieldDeclaration(ftBlob,0);
|
|
@@ -941,9 +957,9 @@ begin
|
|
|
begin
|
|
|
sql.Text := 'insert into FPDEV2 (FT) values (:BlobParam)';
|
|
|
case asWhat of
|
|
|
- 0: Params.ParamByName('blobParam').AsMemo := 'Test deze BLob';
|
|
|
- 1: Params.ParamByName('blobParam').AsString := 'Test deze BLob';
|
|
|
- 2: Params.ParamByName('blobParam').AsBlob := 'Test deze BLob';
|
|
|
+ 0: Params.ParamByName('blobParam').AsMemo := TestValue;
|
|
|
+ 1: Params.ParamByName('blobParam').AsString := TestValue;
|
|
|
+ 2: Params.ParamByName('blobParam').AsBlob := TestValue;
|
|
|
end;
|
|
|
ExecSQL;
|
|
|
end;
|
|
@@ -952,16 +968,34 @@ begin
|
|
|
begin
|
|
|
Open;
|
|
|
if not eof then
|
|
|
- AssertEquals('Test deze BLob',fields[0].AsString);
|
|
|
+ AssertEquals(TestValue, Fields[0].AsString);
|
|
|
close;
|
|
|
end;
|
|
|
end;
|
|
|
|
|
|
+procedure TTestFieldTypes.TestSetBlobAsMemoParam;
|
|
|
+begin
|
|
|
+ // Firebird/Interbase ODBC driver : if parameter of ValueType=SQL_C_CHAR is bind to BLOB column
|
|
|
+ // driver interprets character data as hexadecimal string and performs conversion ('FF10'=#255#16)
|
|
|
+ TestSetBlobAsParam(0);
|
|
|
+end;
|
|
|
+
|
|
|
+procedure TTestFieldTypes.TestSetBlobAsStringParam;
|
|
|
+begin
|
|
|
+ TestSetBlobAsParam(1);
|
|
|
+end;
|
|
|
+
|
|
|
+procedure TTestFieldTypes.TestSetBlobAsBlobParam;
|
|
|
+begin
|
|
|
+ TestSetBlobAsParam(2);
|
|
|
+end;
|
|
|
+
|
|
|
+
|
|
|
procedure TTestFieldTypes.TestAggregates;
|
|
|
begin
|
|
|
TSQLDBConnector(DBConnector).Connection.ExecuteDirect('create table FPDEV2 (FIELD1 INT, FIELD2 INT)');
|
|
|
-// Firebird/Interbase need a commit after a DDL statement. Not necessary for the other connections
|
|
|
- TSQLDBConnector(DBConnector).Transaction.CommitRetaining;
|
|
|
+ // Firebird/Interbase need a commit after a DDL statement. Not necessary for the other connections
|
|
|
+ TSQLDBConnector(DBConnector).CommitDDL;
|
|
|
|
|
|
TSQLDBConnector(DBConnector).Connection.ExecuteDirect('insert into FPDEV2 values (1,1)');
|
|
|
TSQLDBConnector(DBConnector).Connection.ExecuteDirect('insert into FPDEV2 values (2,3)');
|
|
@@ -1001,7 +1035,7 @@ begin
|
|
|
begin
|
|
|
Connection.ExecuteDirect('create table FPDEV2 (FT ' +ASQLTypeDecl+ ')');
|
|
|
// Firebird/Interbase need a commit after a DDL statement. Not necessary for the other connections
|
|
|
- Transaction.CommitRetaining;
|
|
|
+ CommitDDL;
|
|
|
end;
|
|
|
end;
|
|
|
|
|
@@ -1021,24 +1055,6 @@ begin
|
|
|
end;
|
|
|
end;
|
|
|
|
|
|
-procedure TTestFieldTypes.SetUp;
|
|
|
-begin
|
|
|
- InitialiseDBConnector;
|
|
|
-end;
|
|
|
-
|
|
|
-procedure TTestFieldTypes.TearDown;
|
|
|
-begin
|
|
|
- if assigned(DBConnector) then
|
|
|
- TSQLDBConnector(DBConnector).Transaction.Rollback;
|
|
|
- FreeDBConnector;
|
|
|
-end;
|
|
|
-
|
|
|
-procedure TTestFieldTypes.RunTest;
|
|
|
-begin
|
|
|
-// if (SQLConnType in TSQLConnType) then
|
|
|
- inherited RunTest;
|
|
|
-end;
|
|
|
-
|
|
|
procedure TTestFieldTypes.TestQueryAfterReconnect;
|
|
|
var DS: TDataset;
|
|
|
begin
|
|
@@ -1220,7 +1236,7 @@ end;
|
|
|
|
|
|
procedure TTestFieldTypes.TestInsertReturningQuery;
|
|
|
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
|
|
|
begin
|
|
|
// This only works with databases that supports 'insert into .. returning'
|
|
@@ -1291,26 +1307,25 @@ begin
|
|
|
// at least one row must be returned
|
|
|
with TSQLDBConnector(DBConnector) do
|
|
|
begin
|
|
|
- case SQLConnType of
|
|
|
- sqlite3:
|
|
|
+ case SQLServerType of
|
|
|
+ ssSQLite:
|
|
|
statements := TTestStatements.Create('pragma table_info(FPDEV)');
|
|
|
- interbase:
|
|
|
+ ssFirebird:
|
|
|
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:
|
|
|
+ ssPostgreSQL:
|
|
|
statements := TTestStatements.Create(CTE_SELECT);
|
|
|
- mssql:
|
|
|
+ ssMSSQL:
|
|
|
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
|
|
|
- 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;
|
|
|
|
|
|
for s in statements do
|
|
@@ -1505,13 +1520,14 @@ const
|
|
|
begin
|
|
|
with TSQLDBConnector(DBConnector) do
|
|
|
begin
|
|
|
- Connection.ExecuteDirect('create table FPDEV2 ( ' +
|
|
|
- ' ID INT NOT NULL , ' +
|
|
|
- ' NAME VARCHAR(16000), ' +
|
|
|
- ' PRIMARY KEY (ID) ' +
|
|
|
- ') ');
|
|
|
-// Firebird/Interbase need a commit after a DDL statement. Not necessary for the other connections
|
|
|
- TSQLDBConnector(DBConnector).Transaction.CommitRetaining;
|
|
|
+ Connection.ExecuteDirect('create table FPDEV2 ( ' +
|
|
|
+ ' ID INT NOT NULL , ' +
|
|
|
+ ' NAME VARCHAR(16000),' +
|
|
|
+ ' PRIMARY KEY (ID) ' +
|
|
|
+ ') ');
|
|
|
+ // Firebird/Interbase need a commit after a DDL statement. Not necessary for the other connections
|
|
|
+ TSQLDBConnector(DBConnector).CommitDDL;
|
|
|
+
|
|
|
query.sql.Text:='select * from FPDEV2';
|
|
|
Query.Open;
|
|
|
Query.InsertRecord([1,FieldValue]);
|
|
@@ -1527,13 +1543,14 @@ procedure TTestFieldTypes.TestNumericNames;
|
|
|
begin
|
|
|
with TSQLDBConnector(DBConnector) do
|
|
|
begin
|
|
|
- Connection.ExecuteDirect('create table FPDEV2 ( ' +
|
|
|
- ' '+connection.FieldNameQuoteChars[0]+'2ID'+connection.FieldNameQuoteChars[1]+' INT NOT NULL, ' +
|
|
|
- ' '+connection.FieldNameQuoteChars[0]+'3TEST'+connection.FieldNameQuoteChars[1]+' VARCHAR(10), ' +
|
|
|
+ Connection.ExecuteDirect('create table FPDEV2 (' +
|
|
|
+ ' '+connection.FieldNameQuoteChars[0]+'2ID'+connection.FieldNameQuoteChars[1]+' INT NOT NULL,' +
|
|
|
+ ' '+connection.FieldNameQuoteChars[0]+'3TEST'+connection.FieldNameQuoteChars[1]+' VARCHAR(10),' +
|
|
|
' PRIMARY KEY ('+connection.FieldNameQuoteChars[0]+'2ID'+connection.FieldNameQuoteChars[0]+') ' +
|
|
|
- ') ');
|
|
|
-// Firebird/Interbase need a commit after a DDL statement. Not necessary for the other connections
|
|
|
- TSQLDBConnector(DBConnector).Transaction.CommitRetaining;
|
|
|
+ ') ');
|
|
|
+ // Firebird/Interbase need a commit after a DDL statement. Not necessary for the other connections
|
|
|
+ TSQLDBConnector(DBConnector).CommitDDL;
|
|
|
+
|
|
|
with query do
|
|
|
begin
|
|
|
SQL.Text:='select * from FPDEV2';
|
|
@@ -1562,13 +1579,14 @@ begin
|
|
|
with TSQLDBConnector(DBConnector) do
|
|
|
begin
|
|
|
AssertEquals(-1,query.RowsAffected);
|
|
|
- Connection.ExecuteDirect('create table FPDEV2 ( ' +
|
|
|
- ' ID INT NOT NULL , ' +
|
|
|
- ' '+Connection.FieldNameQuoteChars[0]+'NAME-TEST'+Connection.FieldNameQuoteChars[1]+' VARCHAR(250), ' +
|
|
|
- ' PRIMARY KEY (ID) ' +
|
|
|
- ') ');
|
|
|
-// Firebird/Interbase need a commit after a DDL statement. Not necessary for the other connections
|
|
|
- TSQLDBConnector(DBConnector).Transaction.CommitRetaining;
|
|
|
+ Connection.ExecuteDirect('create table FPDEV2 (' +
|
|
|
+ ' ID INT NOT NULL, ' +
|
|
|
+ ' '+Connection.FieldNameQuoteChars[0]+'NAME-TEST'+Connection.FieldNameQuoteChars[1]+' VARCHAR(250), ' +
|
|
|
+ ' PRIMARY KEY (ID) ' +
|
|
|
+ ') ');
|
|
|
+ // Firebird/Interbase need a commit after a DDL statement. Not necessary for the other connections
|
|
|
+ TSQLDBConnector(DBConnector).CommitDDL;
|
|
|
+
|
|
|
Connection.ExecuteDirect('insert into FPDEV2(ID,'+Connection.FieldNameQuoteChars[0]+'NAME-TEST'+Connection.FieldNameQuoteChars[1]+') values (1,''test1'')');
|
|
|
Query.SQL.Text := 'select * from FPDEV2';
|
|
|
Query.Open;
|
|
@@ -1655,13 +1673,14 @@ begin
|
|
|
with TSQLDBConnector(DBConnector) do
|
|
|
begin
|
|
|
AssertEquals(-1,query.RowsAffected);
|
|
|
- Connection.ExecuteDirect('create table FPDEV2 ( ' +
|
|
|
- ' ID INT NOT NULL , ' +
|
|
|
- ' NAME VARCHAR(250), ' +
|
|
|
- ' PRIMARY KEY (ID) ' +
|
|
|
- ') ');
|
|
|
-// Firebird/Interbase need a commit after a DDL statement. Not necessary for the other connections
|
|
|
- TSQLDBConnector(DBConnector).Transaction.CommitRetaining;
|
|
|
+ Connection.ExecuteDirect('create table FPDEV2 (' +
|
|
|
+ ' ID INT NOT NULL, ' +
|
|
|
+ ' NAME VARCHAR(250),' +
|
|
|
+ ' PRIMARY KEY (ID) ' +
|
|
|
+ ') ');
|
|
|
+ // Firebird/Interbase need a commit after a DDL statement. Not necessary for the other connections
|
|
|
+ TSQLDBConnector(DBConnector).CommitDDL;
|
|
|
+
|
|
|
Query.SQL.Text := 'insert into FPDEV2(ID,NAME) values (1,''test1'')';
|
|
|
Query.ExecSQL;
|
|
|
AssertEquals(1,query.RowsAffected);
|
|
@@ -1720,7 +1739,7 @@ begin
|
|
|
begin
|
|
|
Connection.ExecuteDirect('create table FPDEV2 (id1 int, id2 int,vchar varchar(10))');
|
|
|
// Firebird/Interbase need a commit after a DDL statement. Not necessary for the other connections
|
|
|
- TSQLDBConnector(DBConnector).Transaction.CommitRetaining;
|
|
|
+ TSQLDBConnector(DBConnector).CommitDDL;
|
|
|
|
|
|
Query.sql.Text := 'insert into FPDEV2 values(:id1,:id2,:vchar)';
|
|
|
query.params[0].asinteger := 1;
|
|
@@ -1743,7 +1762,7 @@ begin
|
|
|
begin
|
|
|
Connection.ExecuteDirect('create table FPDEV2 (id1 int, id2 int, id3 int, id4 int,id5 int,id6 int,id7 int,id8 int, id9 int, id10 int, id11 int)');
|
|
|
// Firebird/Interbase need a commit after a DDL statement. Not necessary for the other connections
|
|
|
- TSQLDBConnector(DBConnector).Transaction.CommitRetaining;
|
|
|
+ TSQLDBConnector(DBConnector).CommitDDL;
|
|
|
|
|
|
Query.sql.Text := 'insert into FPDEV2 values(:id1,:id2,:id3,:id4,:id5,:id6,:id7,:id8,:id9,:id10,:id11)';
|
|
|
for i := 0 to 10 do
|
|
@@ -1760,43 +1779,37 @@ end;
|
|
|
procedure TTestFieldTypes.TestBug9744;
|
|
|
var i : integer;
|
|
|
begin
|
|
|
- if not(SQLServerType in [ssMySQL, ssSQLite]) then Ignore('This test does not apply to this db-engine, since it has no double field-type');
|
|
|
-
|
|
|
+ // Tests rev.8703: "Fixed MySQL ftLargeInt support"; count() returns BIGINT values
|
|
|
with TSQLDBConnector(DBConnector) do
|
|
|
begin
|
|
|
try
|
|
|
- Connection.ExecuteDirect('create table TTTOBJ ( ' +
|
|
|
- ' ID INT NOT NULL, ' +
|
|
|
- ' NAME VARCHAR(250), ' +
|
|
|
- ' PRIMARY KEY (ID) ' +
|
|
|
- ') ');
|
|
|
- Connection.ExecuteDirect('create table TTTXY ( ' +
|
|
|
- ' ID INT NOT NULL, ' +
|
|
|
- ' NP INT NOT NULL, ' +
|
|
|
- ' X DOUBLE, ' +
|
|
|
- ' Y DOUBLE, ' +
|
|
|
- ' PRIMARY KEY (ID,NP) ' +
|
|
|
- ') ');
|
|
|
+ Connection.ExecuteDirect('create table TTTOBJ ( ' +
|
|
|
+ ' ID INT NOT NULL, ' +
|
|
|
+ ' NAME VARCHAR(250), ' +
|
|
|
+ ' PRIMARY KEY (ID) ' +
|
|
|
+ ') ');
|
|
|
+ Connection.ExecuteDirect('create table TTTXY ( ' +
|
|
|
+ ' ID INT NOT NULL, ' +
|
|
|
+ ' NP INT NOT NULL, ' +
|
|
|
+ ' PRIMARY KEY (ID,NP)' +
|
|
|
+ ') ');
|
|
|
+ Transaction.CommitRetaining;
|
|
|
for i := 0 to 7 do
|
|
|
begin
|
|
|
connection.ExecuteDirect('insert into TTTOBJ(ID,NAME) values ('+inttostr(i)+',''A'+inttostr(i)+''')');
|
|
|
- connection.ExecuteDirect('insert into TTTXY(ID,NP,X,Y) values ('+inttostr(i)+',1,1,1)');
|
|
|
- connection.ExecuteDirect('insert into TTTXY(ID,NP,X,Y) values ('+inttostr(i)+',2,2,2)');
|
|
|
+ connection.ExecuteDirect('insert into TTTXY(ID,NP) values ('+inttostr(i)+',1)');
|
|
|
+ connection.ExecuteDirect('insert into TTTXY(ID,NP) values ('+inttostr(i)+',2)');
|
|
|
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';
|
|
|
+ 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.open;
|
|
|
query.close;
|
|
|
finally
|
|
|
Connection.ExecuteDirect('drop table TTTXY');
|
|
|
Connection.ExecuteDirect('drop table TTTOBJ');
|
|
|
- end
|
|
|
- end;
|
|
|
-end;
|
|
|
-
|
|
|
-procedure TTestFieldTypes.TestCrossStringDateParam;
|
|
|
-begin
|
|
|
- TestXXParamQuery(ftDate,'DATE',testDateValuesCount,True);
|
|
|
+ Transaction.CommitRetaining;
|
|
|
+ end
|
|
|
+ end;
|
|
|
end;
|
|
|
|
|
|
procedure TTestFieldTypes.TestGetFieldNames;
|
|
@@ -1903,7 +1916,7 @@ begin
|
|
|
end;
|
|
|
|
|
|
var testIntervalValuesCount: integer;
|
|
|
-const testIntervalValues: array[0..4] of shortstring = ('00:00:00.000','00:00:01.000','23:59:59.000','838:59:59.000','1000:00:00.000');
|
|
|
+const testIntervalValues: array[0..5] of shortstring = ('00:00:00.000','00:00:01.000','23:59:59.000','99:59:59.000','838:59:59.000','1000:00:00.000');
|
|
|
// Placed here, as long as bug 18702 is not solved
|
|
|
function TestSQLInterval_GetSQLText(const a: integer) : string;
|
|
|
begin
|
|
@@ -1925,7 +1938,7 @@ begin
|
|
|
if SQLConnType = postgresql then
|
|
|
begin
|
|
|
datatype:='INTERVAL';
|
|
|
- testIntervalValuesCount := 5;
|
|
|
+ testIntervalValuesCount := 6;
|
|
|
end
|
|
|
else
|
|
|
begin
|
|
@@ -1933,9 +1946,10 @@ begin
|
|
|
if datatype = '' then
|
|
|
Ignore(STestNotApplicable);
|
|
|
if SQLServerType = ssSQLite then
|
|
|
- testIntervalValuesCount := 5
|
|
|
+ testIntervalValuesCount := 6
|
|
|
else if SQLServerType = ssMySQL then
|
|
|
- testIntervalValuesCount := 4
|
|
|
+ // MySQL ODBC driver does not correctly handles time values >= '100:00:00'
|
|
|
+ testIntervalValuesCount := 5
|
|
|
else
|
|
|
testIntervalValuesCount := 3;
|
|
|
end;
|
|
@@ -2023,9 +2037,41 @@ begin
|
|
|
end;
|
|
|
end;
|
|
|
|
|
|
+function TestSQLReal_GetSQLText(const i: integer) : string;
|
|
|
+begin
|
|
|
+ if i < 20 then // first 20 values fit into MySQL FLOAT data type
|
|
|
+ Result := FloatToStr(testFloatValues[i], DBConnector.FormatSettings)
|
|
|
+ else
|
|
|
+ Result := 'NULL';
|
|
|
+end;
|
|
|
+procedure TTestFieldTypes.TestSQLReal;
|
|
|
+ procedure CheckFieldValue(AField:TField; i: integer);
|
|
|
+ begin
|
|
|
+ if i < 20 then
|
|
|
+ AssertEquals(testFloatValues[i], AField.AsFloat)
|
|
|
+ else
|
|
|
+ AssertTrue(AField.IsNull);
|
|
|
+ end;
|
|
|
+var datatype: string;
|
|
|
+begin
|
|
|
+ case SQLServerType of
|
|
|
+ ssFirebird, ssInterbase,
|
|
|
+ ssMySQL:
|
|
|
+ datatype:='FLOAT';
|
|
|
+ else
|
|
|
+ datatype:='REAL';
|
|
|
+ end;
|
|
|
+ TestSQLFieldType(ftFloat, datatype, sizeof(double), @TestSQLReal_GetSQLText, @CheckFieldValue);
|
|
|
+end;
|
|
|
+
|
|
|
procedure TTestFieldTypes.TestUpdateIndexDefs;
|
|
|
var ds : TSQLQuery;
|
|
|
begin
|
|
|
+ // Firebird/Interbase ODBC driver returns for :
|
|
|
+ // SQLPrimaryKeys (PK_NAME): RDB$RELATION_CONSTRAINTS(RDB$CONSTRAINT_NAME)
|
|
|
+ // SQLStatistics (INDEX_NAME): RDB$INDICES(RDB$INDEX_NAME)
|
|
|
+ // these two names can differ (when PRIMARY KEY is created without giving constraint name),
|
|
|
+ // therefore two indexes may be created instead of one (see TODBCConnection.UpdateIndexDefs)
|
|
|
ds := DBConnector.GetNDataset(1) as TSQLQuery;
|
|
|
ds.Prepare;
|
|
|
ds.ServerIndexDefs.Update;
|
|
@@ -2042,14 +2088,13 @@ procedure TTestFieldTypes.TestMultipleFieldPKIndexDefs;
|
|
|
var ds : TSQLQuery;
|
|
|
begin
|
|
|
TSQLDBConnector(DBConnector).Connection.ExecuteDirect('create table FPDEV2 (' +
|
|
|
- ' ID1 INT NOT NULL, ' +
|
|
|
- ' ID2 INT NOT NULL, ' +
|
|
|
- ' NAME VARCHAR(50), ' +
|
|
|
- ' PRIMARY KEY (ID1, ID2) ' +
|
|
|
- ') ');
|
|
|
-
|
|
|
+ ' ID1 INT NOT NULL, ' +
|
|
|
+ ' ID2 INT NOT NULL, ' +
|
|
|
+ ' NAME VARCHAR(50), ' +
|
|
|
+ ' PRIMARY KEY (ID1, ID2)' +
|
|
|
+ ') ');
|
|
|
// Firebird/Interbase need a commit after a DDL statement. Not necessary for the other connections
|
|
|
- if SQLConnType=interbase then TSQLDBConnector(DBConnector).Transaction.CommitRetaining;
|
|
|
+ TSQLDBConnector(DBConnector).CommitDDL;
|
|
|
|
|
|
ds := TSQLDBConnector(DBConnector).Query;
|
|
|
ds.sql.Text:='select * from FPDEV2';
|
|
@@ -2060,19 +2105,36 @@ begin
|
|
|
Asserttrue(ds.ServerIndexDefs[0].Options=[ixPrimary,ixUnique]);
|
|
|
end;
|
|
|
|
|
|
+procedure TTestFieldTypes.TestGetIndexDefs;
|
|
|
|
|
|
-procedure TTestFieldTypes.TestSetBlobAsMemoParam;
|
|
|
-begin
|
|
|
- TestSetBlobAsParam(0);
|
|
|
-end;
|
|
|
+var ds : TSQLQuery;
|
|
|
+ inddefs : TIndexDefs;
|
|
|
|
|
|
-procedure TTestFieldTypes.TestSetBlobAsBlobParam;
|
|
|
begin
|
|
|
- TestSetBlobAsParam(2);
|
|
|
+ ds := DBConnector.GetNDataset(1) as TSQLQuery;
|
|
|
+ ds.Open;
|
|
|
+ AssertEquals('ServerIndexDefs.Count', 1, ds.ServerIndexDefs.Count);
|
|
|
+ inddefs := HackedDataset(ds).GetIndexDefs(ds.ServerIndexDefs,[ixPrimary]);
|
|
|
+ AssertEquals('ixPrimary', 1, inddefs.count);
|
|
|
+ AssertTrue(CompareText('ID',inddefs[0].Fields)=0);
|
|
|
+ AssertTrue(inddefs[0].Options=[ixPrimary,ixUnique]);
|
|
|
+ inddefs.Free;
|
|
|
+
|
|
|
+ inddefs := HackedDataset(ds).GetIndexDefs(ds.ServerIndexDefs,[ixPrimary,ixUnique]);
|
|
|
+ AssertEquals('ixPrimary,ixUnique', 1, inddefs.count);
|
|
|
+ AssertTrue(CompareText('ID',inddefs[0].Fields)=0);
|
|
|
+ AssertTrue(inddefs[0].Options=[ixPrimary,ixUnique]);
|
|
|
+ inddefs.Free;
|
|
|
+
|
|
|
+ inddefs := HackedDataset(ds).GetIndexDefs(ds.ServerIndexDefs,[ixDescending]);
|
|
|
+ AssertEquals('ixDescending', 0, inddefs.count);
|
|
|
+ inddefs.Free;
|
|
|
end;
|
|
|
|
|
|
+
|
|
|
procedure TTestFieldTypes.TestTemporaryTable;
|
|
|
begin
|
|
|
+ // Tests rev.6481: "Do not use a new connection for every statement that is executed";
|
|
|
if SQLServerType in [ssMSSQL, ssSybase] then Ignore('This test does not apply to this sqldb-connection type, since it doesn''t support temporary tables');
|
|
|
|
|
|
with TSQLDBConnector(DBConnector).Query do
|
|
@@ -2087,7 +2149,7 @@ begin
|
|
|
ExecSQL;
|
|
|
try
|
|
|
// Firebird/Interbase needs a commit after DDL:
|
|
|
- TSQLDBConnector(DBConnector).Transaction.CommitRetaining;
|
|
|
+ TSQLDBConnector(DBConnector).CommitDDL;
|
|
|
|
|
|
SQL.Text := 'INSERT INTO FPDEV_TEMP(id) values (5)';
|
|
|
ExecSQL;
|
|
@@ -2101,38 +2163,12 @@ begin
|
|
|
begin
|
|
|
SQL.Text := 'DROP TABLE FPDEV_TEMP';
|
|
|
ExecSQL;
|
|
|
- TSQLDBConnector(DBConnector).Transaction.CommitRetaining;
|
|
|
+ TSQLDBConnector(DBConnector).CommitDDL;
|
|
|
end;
|
|
|
end;
|
|
|
end;
|
|
|
end;
|
|
|
|
|
|
-procedure TTestFieldTypes.TestGetIndexDefs;
|
|
|
-
|
|
|
-var ds : TSQLQuery;
|
|
|
- inddefs : TIndexDefs;
|
|
|
-
|
|
|
-begin
|
|
|
- ds := DBConnector.GetNDataset(1) as TSQLQuery;
|
|
|
- ds.Open;
|
|
|
- AssertEquals('ServerIndexDefs.Count', 1, ds.ServerIndexDefs.Count);
|
|
|
- inddefs := HackedDataset(ds).GetIndexDefs(ds.ServerIndexDefs,[ixPrimary]);
|
|
|
- AssertEquals('ixPrimary', 1, inddefs.count);
|
|
|
- AssertTrue(CompareText('ID',inddefs[0].Fields)=0);
|
|
|
- AssertTrue(inddefs[0].Options=[ixPrimary,ixUnique]);
|
|
|
- inddefs.Free;
|
|
|
-
|
|
|
- inddefs := HackedDataset(ds).GetIndexDefs(ds.ServerIndexDefs,[ixPrimary,ixUnique]);
|
|
|
- AssertEquals('ixPrimary,ixUnique', 1, inddefs.count);
|
|
|
- AssertTrue(CompareText('ID',inddefs[0].Fields)=0);
|
|
|
- AssertTrue(inddefs[0].Options=[ixPrimary,ixUnique]);
|
|
|
- inddefs.Free;
|
|
|
-
|
|
|
- inddefs := HackedDataset(ds).GetIndexDefs(ds.ServerIndexDefs,[ixDescending]);
|
|
|
- AssertEquals('ixDescending', 0, inddefs.count);
|
|
|
- inddefs.Free;
|
|
|
-end;
|
|
|
-
|
|
|
procedure TTestFieldTypes.TestDblQuoteEscComments;
|
|
|
begin
|
|
|
with TSQLDBConnector(DBConnector).Query do
|
|
@@ -2219,6 +2255,26 @@ begin
|
|
|
end;
|
|
|
end;
|
|
|
|
|
|
+
|
|
|
+procedure TTestFieldTypes.SetUp;
|
|
|
+begin
|
|
|
+ InitialiseDBConnector;
|
|
|
+end;
|
|
|
+
|
|
|
+procedure TTestFieldTypes.TearDown;
|
|
|
+begin
|
|
|
+ if assigned(DBConnector) then
|
|
|
+ TSQLDBConnector(DBConnector).Transaction.Rollback;
|
|
|
+ FreeDBConnector;
|
|
|
+end;
|
|
|
+
|
|
|
+procedure TTestFieldTypes.RunTest;
|
|
|
+begin
|
|
|
+// if (SQLConnType in TSQLConnType) then
|
|
|
+ inherited RunTest;
|
|
|
+end;
|
|
|
+
|
|
|
+
|
|
|
initialization
|
|
|
if uppercase(dbconnectorname)='SQL' then RegisterTest(TTestFieldTypes);
|
|
|
end.
|