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

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

Overview
Comment:{1377} let TSQLRestStorageExternal handle exernal field names defined as [symbolname] also with FireBird
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: ff05ffb48bf01dd958b59f5f3d23e2a02140d2a1
User & Date: ab 2015-05-20 10:35:23
Context
2015-05-20
10:37
{1378} fixed TSQLRestServer.CreateSQLMultiIndex when VirtualTableDirect is false check-in: 066c986be0 user: ab tags: trunk
10:35
{1377} let TSQLRestStorageExternal handle exernal field names defined as [symbolname] also with FireBird check-in: ff05ffb48b user: ab tags: trunk
06:07
{1376} added UnQuotedSQLSymbolName() function, used e.g. by TSQLRestStorageExternal to handle exernal field names defined as [symbolname] check-in: db5c0c622e user: ab tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to SQLite3/mORMotDB.pas.

1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806


1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
  if fProperties.InheritsFrom(TSQLDBConnectionPropertiesThreadSafe) then
    TSQLDBConnectionPropertiesThreadSafe(fProperties).EndCurrentThread;
end;

function TSQLRestStorageExternal.InternalFieldNameToFieldExternalIndex(
  const InternalFieldName: RawUTF8): integer;
begin
  result := StoredClassRecordProps.Fields.IndexByNameOrExcept(InternalFieldName);
  result := fFieldsInternalToExternal[result+1];
end;

function TSQLRestStorageExternal.JSONDecodedPrepareToSQL(
  var Decoder: TJSONObjectDecoder; out ExternalFields: TRawUTF8DynArray;
  out Types: TSQLDBFieldTypeArray; Occasion: TSQLOccasion;
  BatchOptions: TSQLRestBatchOptions): RawUTF8;
var f,k: Integer;
begin
  SetLength(ExternalFields,Decoder.FieldCount);
  for f := 0 to Decoder.FieldCount-1 do begin
    k := InternalFieldNameToFieldExternalIndex(Decoder.FieldNames[f]);


    if k<0 then
      raise ESQLDBException.CreateUTF8(
        '%.JSONDecodedPrepareToSQL: Unknown field "%" in %',
        [self,Decoder.FieldNames[f],StoredClass]);
    ExternalFields[f] := fFieldsExternal[k].ColumnName;
    Types[f] := fFieldsExternal[k].ColumnType;
  end;
  // compute SQL statement and associated bound parameters
  Decoder.DecodedFieldNames := pointer(ExternalFields);
  result := Decoder.EncodeAsSQLPrepared(fTableName,Occasion,
    StoredClassProps.ExternalDB.RowIDFieldName,BatchOptions);
  if Occasion=soUpdate then






|











|
>
>


|
|
<







1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812

1813
1814
1815
1816
1817
1818
1819
  if fProperties.InheritsFrom(TSQLDBConnectionPropertiesThreadSafe) then
    TSQLDBConnectionPropertiesThreadSafe(fProperties).EndCurrentThread;
end;

function TSQLRestStorageExternal.InternalFieldNameToFieldExternalIndex(
  const InternalFieldName: RawUTF8): integer;
begin
  result := fStoredClassRecordProps.Fields.IndexByNameOrExcept(InternalFieldName);
  result := fFieldsInternalToExternal[result+1];
end;

function TSQLRestStorageExternal.JSONDecodedPrepareToSQL(
  var Decoder: TJSONObjectDecoder; out ExternalFields: TRawUTF8DynArray;
  out Types: TSQLDBFieldTypeArray; Occasion: TSQLOccasion;
  BatchOptions: TSQLRestBatchOptions): RawUTF8;
var f,k: Integer;
begin
  SetLength(ExternalFields,Decoder.FieldCount);
  for f := 0 to Decoder.FieldCount-1 do begin
    k := fStoredClassRecordProps.Fields.IndexByNameOrExcept(Decoder.FieldNames[f]);
    ExternalFields[f] := fStoredClassProps.ExternalDB.FieldNameByIndex(k);
    k := fFieldsInternalToExternal[k+1]; // retrieve exact Types[f] from SynDB
    if k<0 then
      raise ESQLDBException.CreateUTF8(
        '%.JSONDecodedPrepareToSQL(%): No column for "%" field in table %',
        [self,StoredClass,Decoder.FieldNames[f],fTableName]);

    Types[f] := fFieldsExternal[k].ColumnType;
  end;
  // compute SQL statement and associated bound parameters
  Decoder.DecodedFieldNames := pointer(ExternalFields);
  result := Decoder.EncodeAsSQLPrepared(fTableName,Occasion,
    StoredClassProps.ExternalDB.RowIDFieldName,BatchOptions);
  if Occasion=soUpdate then

Changes to SynCrtSock.pas.

1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
  {$endif}


/// retrieve the HTTP reason text from a code
// - e.g. StatusCodeToReason(200)='OK'
function StatusCodeToReason(Code: integer): SockString;

/// retrieve the IP adress from a computer name
function ResolveName(const Name: SockString;
  Family: Integer=AF_INET; SockProtocol: Integer=IPPROTO_TCP;
  SockType: integer=SOCK_STREAM): SockString;

/// Base64 encoding of a string
function Base64Encode(const s: SockString): SockString;







|







1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
  {$endif}


/// retrieve the HTTP reason text from a code
// - e.g. StatusCodeToReason(200)='OK'
function StatusCodeToReason(Code: integer): SockString;

/// retrieve the IP address from a computer name
function ResolveName(const Name: SockString;
  Family: Integer=AF_INET; SockProtocol: Integer=IPPROTO_TCP;
  SockType: integer=SOCK_STREAM): SockString;

/// Base64 encoding of a string
function Base64Encode(const s: SockString): SockString;

Changes to SynopseCommit.inc.

1
'1.18.1376'
|
1
'1.18.1377'