diff --git a/fcl/dbtests/testsqlfieldtypes.pas b/fcl/dbtests/testsqlfieldtypes.pas index d8863f3d6f..b15e7aa48d 100644 --- a/fcl/dbtests/testsqlfieldtypes.pas +++ b/fcl/dbtests/testsqlfieldtypes.pas @@ -27,11 +27,15 @@ type procedure RunTest; override; published + procedure TestUpdateIndexDefs; + procedure TestGetIndexDefs; procedure TestDoubleQuoteEscapeComments; procedure TestpfInUpdateFlag; // bug 7565 procedure TestInt; procedure TestScript; + procedure TestTemporaryTable; + procedure TestParametersAndDates; procedure TestExceptionOnsecondClose; @@ -61,6 +65,8 @@ implementation uses sqldbtoolsunit,toolsunit, variants, sqldb, bufdataset; +Type HackedDataset = class(TDataset); + const testFloatValuesCount = 21; testFloatValues : Array[0..testFloatValuesCount-1] of double = (-maxSmallint-1,-maxSmallint,-256,-255,-128,-127,-1,0,1,127,128,255,256,maxSmallint,maxSmallint+1,0.123456,-0.123456,4.35,12.434E7,9.876e-5,123.45678); @@ -829,6 +835,63 @@ begin inherited RunTest; end; +procedure TTestFieldTypes.TestUpdateIndexDefs; +var ds : TSQLQuery; +begin + ds := DBConnector.GetNDataset(1) as TSQLQuery; + ds.Prepare; + ds.IndexDefs.Update; + AssertEquals(1,ds.IndexDefs.count); + AssertEquals('ID',ds.indexdefs[0].Fields); + Asserttrue(ds.indexdefs[0].Options=[ixPrimary,ixUnique]); + ds.IndexDefs.Update; + AssertEquals(1,ds.IndexDefs.count); + AssertEquals('ID',ds.indexdefs[0].Fields); + Asserttrue(ds.indexdefs[0].Options=[ixPrimary,ixUnique]); +end; + +procedure TTestFieldTypes.TestTemporaryTable; +begin + with TSQLDBConnector(DBConnector).Query do + begin + SQL.Clear; + SQL.Add('CREATE TEMPORARY TABLE TEMP1 (id int)'); + ExecSQL; + SQL.Text := 'INSERT INTO TEMP1(id) values (5)'; + ExecSQL; + SQL.Text := 'SELECT * FROM TEMP1'; + Open; + AssertEquals(5,fields[0].AsInteger); + Close; + end; +end; + +procedure TTestFieldTypes.TestGetIndexDefs; + +var ds : TSQLQuery; + inddefs : TIndexDefs; + +begin + ds := DBConnector.GetNDataset(1) as TSQLQuery; + ds.Open; + AssertEquals(1,ds.IndexDefs.count); + inddefs := HackedDataset(ds).GetIndexDefs(ds.IndexDefs,[ixPrimary]); + AssertEquals(1,inddefs.count); + AssertEquals('ID',inddefs[0].Fields); + Asserttrue(inddefs[0].Options=[ixPrimary,ixUnique]); + inddefs.Free; + + inddefs := HackedDataset(ds).GetIndexDefs(ds.IndexDefs,[ixPrimary,ixUnique]); + AssertEquals(1,inddefs.count); + AssertEquals('ID',inddefs[0].Fields); + Asserttrue(inddefs[0].Options=[ixPrimary,ixUnique]); + inddefs.Free; + + inddefs := HackedDataset(ds).GetIndexDefs(ds.IndexDefs,[ixDescending]); + AssertEquals(0,inddefs.count); + inddefs.Free; +end; + procedure TTestFieldTypes.TestDoubleQuoteEscapeComments; begin with TSQLDBConnector(DBConnector).Query do