mORMot and Open Source friends
Check-in [9355b61606]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:{800} fixed unexpected TSQLRestServer time synchronization to the DB local time in TSQLRestStorageExternal.Create - now the reference clock is the ORM server
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 9355b616066e6c2c1163269bdebc8fbf29e8029f
User & Date: ab 2015-02-01 18:08:33
Context
2015-02-01
18:14
{801} new TSQLDBConnection.ServerDateTime property which will return the external database Server current date and time as TDateTime value check-in: 009ed4bb0f user: ab tags: trunk
18:08
{800} fixed unexpected TSQLRestServer time synchronization to the DB local time in TSQLRestStorageExternal.Create - now the reference clock is the ORM server check-in: 9355b61606 user: ab tags: trunk
17:24
{799} added https recognition to the Cross-Platform wrappers, when they are created from a https URI check-in: c276d8dd09 user: ab tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to SQLite3/mORMotDB.pas.

90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111


112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
...
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
    directly (virtual behavior for count(*) is to loop through all records,
    which may be slow), 'GROUP BY' clause, and 'IN (...)' or 'IS NULL' / 'IS NOT NULL' where
    clauses, several fields or ASC/DESC attributes in 'ORDER BY' clause - see
    also [e48f87b3db]
  - now TSQLRestStorageExternal will call TSQLRestServer.OnUpdateEvent and
    OnBlobUpdateEvent callbacks, if defined (even in BATCH mode)
  - BatchDelete() will now split its batch statement executed following
    TSQLDBConnectionProperties.BatchMaxSentAtOnce property expectations 
  - now TSQLRestStorageExternal won't create any columns for external
    tables with unsupported published property types (sftUnknown or sftMany),
    just like TSQLRecord.GetSQLCreate() method
  - TSQLRestStorageExternal will create sftID/sftRecord/sftEnumerate/sftBoolean
    columns as 32 bit integer instead of 64 bit integer
  - now handles TSQLDBConnectionProperties.ForcedSchemaName as expected
  - fixed issue in TSQLRestStorageExternal.EngineDeleteWhere() when
    calling commands like MyDB.Delete(TSQLMyClass, 'PLU < ?', [20000])
  - TSQLRestStorageExternal.EngineDeleteWhere() will handle more border cases,
    and will split DELETE FROM table WHERE ID IN (....) in several intervals 
  - fixed errors when executing JOINed queries (e.g. via FillPrepareMany)
  - fixed ticket [3c41462594] in TSQLRestStorageExternal.ExecuteFromJSON()
  - fixed ticket [9a821d26ee] in TSQLRestStorageExternal.Create() not
    creating any missing field


  - fixed ticket [b109c22750] about SQLite3 cache not flushed after CRUD updates
  - ensure no INDEX is created for SQLite3 which generates an index for ID/RowID
  - ensure DESC INDEX is created for Firebird ID column, as expected for
    faster MAX(ID) execution - see http://www.firebirdfaq.org/faq205
  - fix TSQLRestStorageExternal.CreateSQLMultiIndex() to set ColumnIndexed=TRUE,
    and fixed ticket [929cb6fc3047c5f78b95] by ignoring BLOB fields
  - ensure duplicated indexs are not created on ID primary key column 
  - fixed TSQLRestStorageExternal.UpdateBlobFields() to return true
    if no BLOB field is defined, and to proper handle multi-field update
  - fixed ticket [21c2d5ae96] when inserting/updating blob-only table content
  - handle null binding in TSQLRestStorageExternal.ExecuteInlined()
  - added TSQLRestStorageExternal.TableHasRows/TableRowCount overrides
  - added TSQLRestStorageExternal.PrepareInlinedForRows() and
    PrepareDirectForRows() methods to call new ExecutePreparedAndFetchAllAsJSON()
    method of ISQLDBStatement as expected by TSQLDBProxyStatement
  - optimized TSQLRestStorageExternal.UpdateBlobFields()/RetrieveBlobFields()
    methods, updating/retrieving all BLOB fields at once in the same SQL statement
  - added VirtualTableExternalMap() function for easier mapping definition
  - handle TSQLModelRecordPropertiesExternal.MapAutoKeywordFields for automatic
    maping of field which name conflicts with a SQL keyword - see [7fbbd53966] 
  - this unit will now set SynDBLog := TSQLLog during its initialization
  - replaced confusing TVarData by a new dedicated TSQLVar memory structure,
    shared with SynDB and mORMot units (includes methods refactoring)

}

{$I Synopse.inc} // define HASINLINE USETYPEINFO CPU32 CPU64 OWNNORMTOUPPER
................................................................................
  inherited Create(aClass,aServer);
  // initialize external DB properties
  fTableName := StoredClassProps.ExternalDB.TableName;
  fProperties := StoredClassProps.ExternalDB.ConnectionProperties as TSQLDBConnectionProperties;
  if fProperties=nil then
    raise EBusinessLayerException.CreateUTF8(
      '%.Create: No external DB defined for %',[self,StoredClass]);
  // try to connect to the remote DB, and synchronize local Rest time
  if Owner<>nil then
    try
      Owner.ServerTimeStamp := fProperties.ThreadSafeConnection.ServerTimeStamp;
    except
      on E: Exception do ; // ignore any error here
    end;
  // ensure external field names are compatible with the external DB keywords
  for f := 0 to StoredClassRecordProps.Fields.Count-1 do begin
    nfo := StoredClassRecordProps.Fields.List[f];
    if nfo.SQLFieldType in COPIABLE_FIELDS then begin // ignore sftMany
      SQL := fStoredClassProps.ExternalDB.FieldNames[f];
      if fProperties.IsSQLKeyword(SQL) then begin
        log := Owner.LogClass.Add;






|









|




>
>






|












|







 







<
<
<
<
<
<
<







90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
...
669
670
671
672
673
674
675







676
677
678
679
680
681
682
    directly (virtual behavior for count(*) is to loop through all records,
    which may be slow), 'GROUP BY' clause, and 'IN (...)' or 'IS NULL' / 'IS NOT NULL' where
    clauses, several fields or ASC/DESC attributes in 'ORDER BY' clause - see
    also [e48f87b3db]
  - now TSQLRestStorageExternal will call TSQLRestServer.OnUpdateEvent and
    OnBlobUpdateEvent callbacks, if defined (even in BATCH mode)
  - BatchDelete() will now split its batch statement executed following
    TSQLDBConnectionProperties.BatchMaxSentAtOnce property expectations
  - now TSQLRestStorageExternal won't create any columns for external
    tables with unsupported published property types (sftUnknown or sftMany),
    just like TSQLRecord.GetSQLCreate() method
  - TSQLRestStorageExternal will create sftID/sftRecord/sftEnumerate/sftBoolean
    columns as 32 bit integer instead of 64 bit integer
  - now handles TSQLDBConnectionProperties.ForcedSchemaName as expected
  - fixed issue in TSQLRestStorageExternal.EngineDeleteWhere() when
    calling commands like MyDB.Delete(TSQLMyClass, 'PLU < ?', [20000])
  - TSQLRestStorageExternal.EngineDeleteWhere() will handle more border cases,
    and will split DELETE FROM table WHERE ID IN (....) in several intervals
  - fixed errors when executing JOINed queries (e.g. via FillPrepareMany)
  - fixed ticket [3c41462594] in TSQLRestStorageExternal.ExecuteFromJSON()
  - fixed ticket [9a821d26ee] in TSQLRestStorageExternal.Create() not
    creating any missing field
  - fixed unexpected TSQLRestServer time synchronization to the DB local time in  
    TSQLRestStorageExternal.Create - now the reference clock is the ORM server
  - fixed ticket [b109c22750] about SQLite3 cache not flushed after CRUD updates
  - ensure no INDEX is created for SQLite3 which generates an index for ID/RowID
  - ensure DESC INDEX is created for Firebird ID column, as expected for
    faster MAX(ID) execution - see http://www.firebirdfaq.org/faq205
  - fix TSQLRestStorageExternal.CreateSQLMultiIndex() to set ColumnIndexed=TRUE,
    and fixed ticket [929cb6fc3047c5f78b95] by ignoring BLOB fields
  - ensure duplicated indexs are not created on ID primary key column
  - fixed TSQLRestStorageExternal.UpdateBlobFields() to return true
    if no BLOB field is defined, and to proper handle multi-field update
  - fixed ticket [21c2d5ae96] when inserting/updating blob-only table content
  - handle null binding in TSQLRestStorageExternal.ExecuteInlined()
  - added TSQLRestStorageExternal.TableHasRows/TableRowCount overrides
  - added TSQLRestStorageExternal.PrepareInlinedForRows() and
    PrepareDirectForRows() methods to call new ExecutePreparedAndFetchAllAsJSON()
    method of ISQLDBStatement as expected by TSQLDBProxyStatement
  - optimized TSQLRestStorageExternal.UpdateBlobFields()/RetrieveBlobFields()
    methods, updating/retrieving all BLOB fields at once in the same SQL statement
  - added VirtualTableExternalMap() function for easier mapping definition
  - handle TSQLModelRecordPropertiesExternal.MapAutoKeywordFields for automatic
    maping of field which name conflicts with a SQL keyword - see [7fbbd53966]
  - this unit will now set SynDBLog := TSQLLog during its initialization
  - replaced confusing TVarData by a new dedicated TSQLVar memory structure,
    shared with SynDB and mORMot units (includes methods refactoring)

}

{$I Synopse.inc} // define HASINLINE USETYPEINFO CPU32 CPU64 OWNNORMTOUPPER
................................................................................
  inherited Create(aClass,aServer);
  // initialize external DB properties
  fTableName := StoredClassProps.ExternalDB.TableName;
  fProperties := StoredClassProps.ExternalDB.ConnectionProperties as TSQLDBConnectionProperties;
  if fProperties=nil then
    raise EBusinessLayerException.CreateUTF8(
      '%.Create: No external DB defined for %',[self,StoredClass]);







  // ensure external field names are compatible with the external DB keywords
  for f := 0 to StoredClassRecordProps.Fields.Count-1 do begin
    nfo := StoredClassRecordProps.Fields.List[f];
    if nfo.SQLFieldType in COPIABLE_FIELDS then begin // ignore sftMany
      SQL := fStoredClassProps.ExternalDB.FieldNames[f];
      if fProperties.IsSQLKeyword(SQL) then begin
        log := Owner.LogClass.Add;

Changes to SynopseCommit.inc.

1
'1.18.799'
|
1
'1.18.800'