فهرست منبع

fcl-db: sqldb: reverting previous commit 37947.
- leave in sqldb.pp ANSI SQL compliant format of datetime literals <unquoted timestamp string> ::= <unquoted date string> <space> <unquoted time string>
- in case of MS SQL there is datetime format affected by SET DATEFORMAT and SET LANGUAGE so here use ISO 8601 format which is unambiguous.
Bug #32979

git-svn-id: trunk@37974 -

lacak 7 سال پیش
والد
کامیت
d47be9c3f7
2فایلهای تغییر یافته به همراه9 افزوده شده و 6 حذف شده
  1. 3 0
      packages/fcl-db/src/sqldb/mssql/mssqlconn.pp
  2. 6 6
      packages/fcl-db/src/sqldb/sqldb.pp

+ 3 - 0
packages/fcl-db/src/sqldb/mssql/mssqlconn.pp

@@ -376,6 +376,9 @@ begin
         //  Result := '0x' + StrToHex(Param.AsString)
         //else
         Result := 'N' + inherited GetAsSQLText(Param);
+      ftDateTime:
+        // ISO 8601 format is unambiguous; is not affected by the SET DATEFORMAT or SET LANGUAGE setting.
+        Result := '''' + FormatDateTime('yyyy-mm-dd"T"hh:nn:ss.zzz', Param.AsDateTime, FSQLFormatSettings) + '''';
       ftBlob, ftBytes, ftVarBytes:
         Result := '0x' + StrToHex(Param.AsString);
       else

+ 6 - 6
packages/fcl-db/src/sqldb/sqldb.pp

@@ -1702,9 +1702,9 @@ begin
   if (not assigned(Field)) or Field.IsNull then Result := 'Null'
   else case Field.DataType of
     ftString   : Result := QuotedStr(Field.AsString);
-    ftDate     : Result := '''' + FormatDateTime('yyyy-mm-dd',Field.AsDateTime,FSqlFormatSettings) + '''';
-    ftDateTime : Result := QuotedStr(FormatDateTime('yyyy-mm-dd"T"hh:nn:ss.zzz',Field.AsDateTime,FSqlFormatSettings));
-    ftTime     : Result := QuotedStr(TimeIntervalToString(Field.AsDateTime));
+    ftDate     : Result := '''' + FormatDateTime('yyyy-mm-dd',Field.AsDateTime,FSQLFormatSettings) + '''';
+    ftDateTime : Result := '''' + FormatDateTime('yyyy-mm-dd hh:nn:ss.zzz',Field.AsDateTime,FSQLFormatSettings) + '''';
+    ftTime     : Result := '''' + TimeIntervalToString(Field.AsDateTime) + '''';
   else
     Result := Field.AsString;
   end; {case}
@@ -1718,9 +1718,9 @@ begin
     ftMemo,
     ftFixedChar,
     ftString   : Result := QuotedStr(GetAsString(Param));
-    ftDate     : Result := '''' + FormatDateTime('yyyy-mm-dd',Param.AsDateTime,FSQLFormatSettings) + '''';
-    ftTime     : Result := QuotedStr(TimeIntervalToString(Param.AsDateTime));
-    ftDateTime : Result := QuotedStr(FormatDateTime('yyyy-mm-dd"T"hh:nn:ss.zzz', Param.AsDateTime, FSQLFormatSettings));
+    ftDate     : Result := '''' + FormatDateTime('yyyy-mm-dd', Param.AsDateTime, FSQLFormatSettings) + '''';
+    ftTime     : Result := '''' + TimeIntervalToString(Param.AsDateTime) + '''';
+    ftDateTime : Result := '''' + FormatDateTime('yyyy-mm-dd hh:nn:ss.zzz', Param.AsDateTime, FSQLFormatSettings) + '''';
     ftCurrency,
     ftBcd      : Result := CurrToStr(Param.AsCurrency, FSQLFormatSettings);
     ftFloat    : Result := FloatToStr(Param.AsFloat, FSQLFormatSettings);