diff options
Diffstat (limited to 'packages/fcl-db')
-rw-r--r-- | packages/fcl-db/src/base/dsparams.inc | 11 | ||||
-rw-r--r-- | packages/fcl-db/tests/sqldbtoolsunit.pas | 72 | ||||
-rw-r--r-- | packages/fcl-db/tests/testbasics.pas | 2 | ||||
-rw-r--r-- | packages/fcl-db/tests/toolsunit.pas | 4 |
4 files changed, 43 insertions, 46 deletions
diff --git a/packages/fcl-db/src/base/dsparams.inc b/packages/fcl-db/src/base/dsparams.inc index dbe32f5d85..b09830ee38 100644 --- a/packages/fcl-db/src/base/dsparams.inc +++ b/packages/fcl-db/src/base/dsparams.inc @@ -257,14 +257,17 @@ begin if p^='*' then // /* */ comment begin Result := True; - repeat - Inc(p); + Inc(p); + while p^ <> #0 do + begin if p^='*' then // possible end of comment begin Inc(p); if p^='/' then Break; // end of comment - end; - until p^=#0; + end + else + Inc(p); + end; if p^='/' then Inc(p); // skip final / end; end; diff --git a/packages/fcl-db/tests/sqldbtoolsunit.pas b/packages/fcl-db/tests/sqldbtoolsunit.pas index 02956a39cb..f7a0fd9f13 100644 --- a/packages/fcl-db/tests/sqldbtoolsunit.pas +++ b/packages/fcl-db/tests/sqldbtoolsunit.pas @@ -357,6 +357,11 @@ begin testStringValues[i] := TrimRight(testStringValues[i]); end; + if SQLServerType in [ssMSSQL, ssSQLite, ssSybase] then + // Some DB's do not support sql compliant boolean data type. + for i := 0 to testValuesCount-1 do + testValues[ftBoolean, i] := BoolToStr(testBooleanValues[i], '1', '0'); + if SQLServerType in [ssMySQL] then begin // Some DB's do not support milliseconds in datetime and time fields. @@ -498,46 +503,35 @@ begin begin sql := sql + ',F' + Fieldtypenames[FType]; if testValues[FType,CountID] <> '' then - case FType of - ftBlob, ftBytes, ftGraphic, ftVarBytes: - if SQLServerType in [ssOracle] then - // Oracle does not accept string literals in blob insert statements - // convert 'DEADBEEF' hex literal to binary: - sql1 := sql1 + ', HEXTORAW(' + QuotedStr(String2Hex(testValues[FType,CountID])) + ') ' - else // other dbs have no problems with the original string values - sql1 := sql1 + ',' + QuotedStr(testValues[FType,CountID]); - ftCurrency: - sql1 := sql1 + ',' + testValues[FType,CountID]; - ftDate: - // Oracle requires date conversion; otherwise - // ORA-01861: literal does not match format string - if SQLServerType in [ssOracle] then - // ANSI/ISO date literal: - sql1 := sql1 + ', DATE ' + QuotedStr(testValues[FType,CountID]) - else - sql1 := sql1 + ',' + QuotedStr(testValues[FType,CountID]); - ftDateTime: - // similar to ftDate handling - if SQLServerType in [ssOracle] then - begin - // Could be a real date+time or only date. Does not consider only time. - if pos(' ',testValues[FType,CountID])>0 then - sql1 := sql1 + ', TIMESTAMP ' + QuotedStr(testValues[FType,CountID]) - else - sql1 := sql1 + ', DATE ' + QuotedStr(testValues[FType,CountID]); - end - else - sql1 := sql1 + ',' + QuotedStr(testValues[FType,CountID]); - ftTime: - // similar to ftDate handling - if SQLServerType in [ssOracle] then - // More or less arbitrary default time; there is no time-only data type in Oracle. - sql1 := sql1 + ', TIMESTAMP ' + QuotedStr('0001-01-01 '+testValues[FType,CountID]) - else - sql1 := sql1 + ',' + QuotedStr(testValues[FType,CountID]); - else - sql1 := sql1 + ',' + QuotedStr(testValues[FType,CountID]) + if FType in [ftBoolean, ftCurrency] then + sql1 := sql1 + ',' + testValues[FType,CountID] + else if (FType in [ftBlob, ftBytes, ftGraphic, ftVarBytes]) and + (SQLServerType = ssOracle) then + // Oracle does not accept string literals in blob insert statements + // convert 'DEADBEEF' hex literal to binary: + sql1 := sql1 + ', HEXTORAW(' + QuotedStr(String2Hex(testValues[FType,CountID])) + ') ' + else if (FType = ftDate) and + (SQLServerType = ssOracle) then + // Oracle requires date conversion; otherwise + // ORA-01861: literal does not match format string + // ANSI/ISO date literal: + sql1 := sql1 + ', DATE ' + QuotedStr(testValues[FType,CountID]) + else if (FType = ftDateTime) and + (SQLServerType = ssOracle) then begin + // similar to ftDate handling + // Could be a real date+time or only date. Does not consider only time. + if pos(' ',testValues[FType,CountID])>0 then + sql1 := sql1 + ', TIMESTAMP ' + QuotedStr(testValues[FType,CountID]) + else + sql1 := sql1 + ', DATE ' + QuotedStr(testValues[FType,CountID]); end + else if (FType = ftTime) and + (SQLServerType = ssOracle) then + // similar to ftDate handling + // More or less arbitrary default time; there is no time-only data type in Oracle. + sql1 := sql1 + ', TIMESTAMP ' + QuotedStr('0001-01-01 '+testValues[FType,CountID]) + else + sql1 := sql1 + ',' + QuotedStr(testValues[FType,CountID]) else sql1 := sql1 + ',NULL'; end; diff --git a/packages/fcl-db/tests/testbasics.pas b/packages/fcl-db/tests/testbasics.pas index 6fa029435e..69ee0ea3be 100644 --- a/packages/fcl-db/tests/testbasics.pas +++ b/packages/fcl-db/tests/testbasics.pas @@ -145,6 +145,8 @@ begin // Bracketed comment AssertEquals( 'select * from table where id=/*comment :c*/$1-$2', Params.ParseSQL('select * from table where id=/*comment :c*/:a-:b', True, True, True, psPostgreSQL)); + AssertEquals( 'select * from table where id=/*comment :c**/$1-$2', + Params.ParseSQL('select * from table where id=/*comment :c**/:a-:b', True, True, True, psPostgreSQL)); // Consecutive comments, with quote in second comment AssertEquals( '--c1'#10'--c'''#10'select '':a'' from table where id=$1', Params.ParseSQL('--c1'#10'--c'''#10'select '':a'' from table where id=:id', True, True, True, psPostgreSQL)); diff --git a/packages/fcl-db/tests/toolsunit.pas b/packages/fcl-db/tests/toolsunit.pas index b3ab9625e3..1580f6fed2 100644 --- a/packages/fcl-db/tests/toolsunit.pas +++ b/packages/fcl-db/tests/toolsunit.pas @@ -526,8 +526,6 @@ end; procedure InitialiseDBConnector; -const B: array[boolean] of char=('0','1'); // should be exported from some main db unit, as SQL true/false? - var DBConnectorClass : TPersistentClass; i : integer; FormatSettings : TFormatSettings; @@ -548,7 +546,7 @@ begin testValues[ftFMTBcd] := testFmtBCDValues; for i := 0 to testValuesCount-1 do begin - testValues[ftBoolean,i] := B[testBooleanValues[i]]; + testValues[ftBoolean,i] := BoolToStr(testBooleanValues[i], True); testValues[ftFloat,i] := FloatToStr(testFloatValues[i],FormatSettings); testValues[ftSmallint,i] := IntToStr(testSmallIntValues[i]); testValues[ftInteger,i] := IntToStr(testIntValues[i]); |