@@ -951,12 +951,20 @@ TSQLDBRowVariantType = class(TSynInvokeableVariantType)
951
951
// - BLOB field value is saved as Base64, in the '"\uFFF0base64encodedbinary"'
952
952
// format and contains true BLOB data
953
953
procedure ExecutePreparedAndFetchAllAsJSON (Expanded: boolean; out JSON: RawUTF8);
954
+
954
955
function GetForceBlobAsNull : boolean;
955
956
procedure SetForceBlobAsNull (value : boolean);
956
957
// / if set, any BLOB field won't be retrieved, and forced to be null
957
958
// - this may be used to speed up fetching the results for SQL requests
958
959
// with * statements
959
960
property ForceBlobAsNull: boolean read GetForceBlobAsNull write SetForceBlobAsNull;
961
+ function GetForceDateWithMS : boolean;
962
+ procedure SetForceDateWithMS (value : boolean);
963
+ // / if set, any ftDate field will contain the milliseconds information
964
+ // when serialized into ISO-8601 text
965
+ // - this setting is private to each statement, since may vary depending
966
+ // on data definition (e.g. ORM TDateTime/TDateTimeMS)
967
+ property ForceDateWithMS: boolean read GetForceDateWithMS write SetForceDateWithMS;
960
968
// / gets a number of updates made by latest executed statement
961
969
function UpdateCount : Integer;
962
970
end ;
@@ -1863,10 +1871,13 @@ TSQLDBStatement = class(TInterfacedObject, ISQLDBRows, ISQLDBStatement)
1863
1871
fCurrentRow: Integer;
1864
1872
fSQLWithInlinedParams: RawUTF8;
1865
1873
fForceBlobAsNull: boolean;
1874
+ fForceDateWithMS: boolean;
1866
1875
fDBMS: TSQLDBDefinition;
1867
1876
function GetSQLWithInlinedParams : RawUTF8;
1868
1877
function GetForceBlobAsNull : boolean;
1869
1878
procedure SetForceBlobAsNull (value : boolean);
1879
+ function GetForceDateWithMS : boolean;
1880
+ procedure SetForceDateWithMS (value : boolean);
1870
1881
// / raise an exception if Col is out of range according to fColumnCount
1871
1882
procedure CheckCol (Col: integer); { $ifdef HASINLINE} inline;{ $endif}
1872
1883
// / will set a Int64/Double/Currency/TDateTime/RawUTF8/TBlobData Dest variable
@@ -2671,8 +2682,8 @@ ESQLDBRemote = class(ESQLDBException);
2671
2682
Params: TSQLDBParamDynArray;
2672
2683
// / if input parameters expected BindArray() process
2673
2684
ArrayCount: integer;
2674
- // / if set, any BLOB field won't be retrieved, and forced to be null
2675
- ForceBlobAsNull: boolean ;
2685
+ // / match ForceBlobAsNull and ForceDateWithMS properties
2686
+ Force: set of (fBlobAsNull, fDateWithMS) ;
2676
2687
end ;
2677
2688
2678
2689
// / implements a proxy-like virtual connection statement to a DB engine
@@ -4543,8 +4554,10 @@ procedure AppendOutput(value: Int64);
4543
4554
RecordLoad(InputExecute,O,TypeInfo(TSQLDBProxyConnectionCommandExecute));
4544
4555
ExecuteWithResults := header.Command<>cExecute;
4545
4556
Stmt := NewStatementPrepared(InputExecute.SQL,ExecuteWithResults,true);
4546
- if InputExecute.ForceBlobAsNull then
4557
+ if fBlobAsNull in InputExecute.Force then
4547
4558
Stmt.ForceBlobAsNull := true;
4559
+ if fDateWithMS in InputExecute.Force then
4560
+ Stmt.ForceDateWithMS := true;
4548
4561
for i := 1 to Length(InputExecute.Params) do
4549
4562
with InputExecute.Params[i-1 ] do
4550
4563
if InputExecute.ArrayCount=0 then
@@ -6730,6 +6743,16 @@ procedure TSQLDBStatement.SetForceBlobAsNull(value: boolean);
6730
6743
fForceBlobAsNull := value ;
6731
6744
end ;
6732
6745
6746
+ function TSQLDBStatement.GetForceDateWithMS : boolean;
6747
+ begin
6748
+ result := fForceDateWithMS;
6749
+ end ;
6750
+
6751
+ procedure TSQLDBStatement.SetForceDateWithMS (value : boolean);
6752
+ begin
6753
+ fForceDateWithMS := value ;
6754
+ end ;
6755
+
6733
6756
constructor TSQLDBStatement.Create(aConnection: TSQLDBConnection);
6734
6757
begin
6735
6758
// SynDBLog.Enter(self);
@@ -6836,7 +6859,7 @@ procedure TSQLDBStatement.ColumnsToJSON(WR: TJSONWriter);
6836
6859
ftCurrency: WR.AddCurr64(ColumnCurrency(col));
6837
6860
ftDate: begin
6838
6861
WR.Add(' "' );
6839
- WR.AddDateTime(ColumnDateTime(col));
6862
+ WR.AddDateTime(ColumnDateTime(col),fForceDateWithMS );
6840
6863
WR.Add(' "' );
6841
6864
end ;
6842
6865
ftUTF8: begin
@@ -6863,6 +6886,7 @@ procedure TSQLDBStatement.ColumnsToJSON(WR: TJSONWriter);
6863
6886
procedure TSQLDBStatement.ColumnToSQLVar (Col: Integer; var Value : TSQLVar;
6864
6887
var Temp: RawByteString);
6865
6888
begin
6889
+ Value .Options := [];
6866
6890
if ColumnNull(Col) then // will call GetCol() to check Col
6867
6891
Value .VType := ftNull else
6868
6892
Value .VType := ColumnType(Col);
@@ -7021,7 +7045,7 @@ function TSQLDBStatement.FetchAllToCSVValues(Dest: TStream; Tab: boolean;
7021
7045
ftDate: begin
7022
7046
if not Tab then
7023
7047
W.Add(' "' );
7024
- W.AddDateTime(V.VDateTime);
7048
+ W.AddDateTime(V.VDateTime,svoDateWithMS in V.Options );
7025
7049
if not Tab then
7026
7050
W.Add(' "' );
7027
7051
end ;
@@ -8481,7 +8505,11 @@ procedure TSQLDBProxyStatement.ParamsToCommand(var Input: TSQLDBProxyConnectionC
8481
8505
SetLength(fParams,fParamCount);
8482
8506
Input.Params := fParams;
8483
8507
Input.ArrayCount := fParamsArrayCount;
8484
- Input.ForceBlobAsNull := fForceBlobAsNull;
8508
+ if fForceBlobAsNull then
8509
+ Input.Force := [fBlobAsNull] else
8510
+ Input.Force := [];
8511
+ if fForceDateWithMS then
8512
+ include(Input.Force,fDateWithMS);
8485
8513
end ;
8486
8514
8487
8515
procedure TSQLDBProxyStatement.ExecutePrepared ;
0 commit comments