Changeset 37


Ignore:
Timestamp:
Mar 8, 2012, 3:11:10 PM (12 years ago)
Author:
chronos
Message:
  • Modified: Direct acces using Database: TSqlDatabase replaced by TChronisClient interface.
Location:
trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Application/Clients/UChronisClientMySQL.pas

    r34 r37  
    1313
    1414  TChronisClientMySQL = class(TChronisClient)
     15  protected
     16    function GetConnected: Boolean; override;
     17  public
    1518    Database: TSqlDatabase;
    1619    procedure ObjectLoad(AObject: TObjectProxy); override;
     
    2023    procedure ListLoad(AList: TListProxy); override;
    2124    procedure ListSave(AList: TListProxy); override;
    22     constructor Create;
     25    procedure DefineType(AType: TChronisType); override;
     26    procedure UndefineType(AType: TChronisType); override;
     27    procedure Install;
     28    procedure Uninstall;
     29    constructor Create; override;
    2330    destructor Destroy; override;
     31    procedure Connect; override;
     32    procedure Disconnect; override;
    2433  end;
    2534
     
    2736
    2837{ TChronisClientMySQL }
     38
     39function TChronisClientMySQL.GetConnected: Boolean;
     40begin
     41  Result := Database.Connected;
     42end;
    2943
    3044procedure TChronisClientMySQL.ObjectLoad(AObject: TObjectProxy);
     
    5266  DbRows: TDbRows;
    5367  Filter: string;
    54   Condition: string;
     68  DbCondition: string;
    5569  I: Integer;
    5670  NewObject: TObjectProxy;
     71  Table: string;
    5772begin
    5873  try
     
    6479      Delete(Filter, Length(Filter) - 1, 2);
    6580    end else Filter := '*';
    66     if AList.ConditionUse then Condition := '`' + AList.ConditionColumn + '` = "' +
    67       AList.ConditionValue + '"'
    68       else Condition := '1';
    69     Database.Query(DbRows, 'SELECT ' + Filter + ' FROM `' + AList.SchemaName + '`.`' +
    70       AList.ObjectName + '` WHERE ' + Condition);
     81    if AList.Condition <> '' then DbCondition := ' WHERE ' + AList.Condition
     82      else DbCondition := '';
     83    Table := '`' + AList.ObjectName + '`';
     84    if AList.SchemaName <> '' then Table := '`' + AList.SchemaName + '`.' + Table;
     85    Database.Query(DbRows, 'SELECT ' + Filter + ' FROM ' + Table + DbCondition);
    7186    AList.Objects.Clear;
    7287    for I := 0 to DbRows.Count - 1 do begin
     
    86101end;
    87102
     103procedure TChronisClientMySQL.DefineType(AType: TChronisType);
     104var
     105  Data: TDictionaryStringString;
     106  I: Integer;
     107begin
     108  try
     109    Data := TDictionaryStringString.Create;
     110    Data.Add('Name', AType.Name);
     111    Database.Insert('Type', Data);
     112  finally
     113    Data.Free;
     114  end;
     115  if AType is TChronisTypeRecord then begin
     116    for I := 0 to TChronisTypeRecord(AType).Items.Count - 1 do
     117      try
     118        Data := TDictionaryStringString.Create;
     119        Data.Add('Name',
     120          TChronisTypeRecordItem(TChronisTypeRecord(AType).Items[I]).Name);
     121        Data.Add('Type', IntToStr(
     122          TChronisTypeRecordItem(TChronisTypeRecord(AType).Items[I]).ItemType.OID));
     123        Database.Insert('TypeRecordItem', Data);
     124      finally
     125        Data.Free;
     126      end;
     127  end;
     128end;
     129
     130procedure TChronisClientMySQL.UndefineType(AType: TChronisType);
     131begin
     132
     133end;
     134
     135procedure TChronisClientMySQL.Install;
     136begin
     137(*  if Tables.IndexOf(InformationTable) = -1 then begin
     138    Database.Query(DbRows, 'CREATE TABLE IF NOT EXISTS `' + InformationTable + '` ( ' +
     139'`Version` varchar(255) NOT NULL,' +
     140'`LastUpdateTime` datetime NOT NULL' +
     141') ENGINE=InnoDB DEFAULT CHARSET=utf8;');
     142    Database.Query(DbRows, 'INSERT INTO `' + InformationTable + '` (`Version`, `LastUpdateTime`) VALUES ' +
     143'("0.1", "0000-00-00 00:00:00");');
     144  end;
     145  Database.Select(DbRows, InformationTable);
     146  StructureVersion := DbRows[0].Values['Version'];*)
     147end;
     148
     149procedure TChronisClientMySQL.Uninstall;
     150begin
     151
     152end;
     153
    88154constructor TChronisClientMySQL.Create;
    89155begin
     
    97163end;
    98164
     165procedure TChronisClientMySQL.Connect;
     166begin
     167  Database.Port := Port;
     168  Database.UserName := User;
     169  Database.Password := Password;
     170  Database.HostName := Host;
     171  Database.Database := Schema;
     172  Database.Connect;
     173end;
     174
     175procedure TChronisClientMySQL.Disconnect;
     176begin
     177  Database.Disconnect;
     178end;
     179
    99180end.
    100181
  • trunk/Application/UChronisClient.pas

    r34 r37  
    1919    Properties: TDictionaryStringString;
    2020    Client: TChronisClient;
     21    ObjectName: string;
     22    SchemaName: string;
    2123    procedure Load;
    2224    procedure Save;
     
    3941    ColumnsFilter: TListString;
    4042    ColummsFilterUse: Boolean;
    41     ConditionColumn: string;
    42     ConditionValue: string;
    43     ConditionUse: Boolean;
     43    Condition: string;
    4444    ObjectName: string;
    4545    SchemaName: string;
    4646    Objects: TListObject; // TListObject<TObjectProxy>
    47     procedure SetCondition(ColumnName: string; Value: string);
    4847    procedure Clear;
    4948    constructor Create;
     
    5352  end;
    5453
     54  TChronisType = class
     55    OID: Integer;
     56    Name: string;
     57  end;
     58
     59  TChronisTypeRecordItem = class
     60    Name: string;
     61    ItemType: TChronisType;
     62  end;
     63
     64  { TChronisTypeRecord }
     65
     66  TChronisTypeRecord = class(TChronisType)
     67    Items: TListObject; // TListObject<TChronisTypeRecordItem>
     68    constructor Create;
     69    destructor Destroy; override;
     70  end;
     71
    5572  { TChronisClient }
    5673
    5774  TChronisClient = class
     75  protected
     76    function GetConnected: Boolean; virtual;
     77  public
    5878    Host: string;
    5979    Port: Word;
     
    6787    procedure ListLoad(AList: TListProxy); virtual; abstract;
    6888    procedure ListSave(AList: TListProxy); virtual; abstract;
     89    procedure DefineType(AType: TChronisType); virtual; abstract;
     90    procedure UndefineType(AType: TChronisType); virtual; abstract;
    6991    constructor Create; virtual;
     92    procedure Connect; virtual; abstract;
     93    procedure Disconnect; virtual; abstract;
     94    property Connected: Boolean read GetConnected;
    7095  end;
    7196
    7297implementation
     98
     99{ TChronisTypeRecord }
     100
     101constructor TChronisTypeRecord.Create;
     102begin
     103  Items := TListObject.Create;
     104end;
     105
     106destructor TChronisTypeRecord.Destroy;
     107begin
     108  Items.Free;
     109  inherited Destroy;
     110end;
    73111
    74112{ TObjectProxy }
     
    107145{ TListProxy }
    108146
    109 procedure TListProxy.SetCondition(ColumnName: string; Value: string);
    110 begin
    111   ConditionColumn := ColumnName;
    112   ConditionValue := Value;
    113   ConditionUse := True;
    114 end;
    115 
    116147procedure TListProxy.Clear;
    117148begin
    118   ConditionUse := False;
    119149  PageUse := False;
    120150  ColummsFilterUse := False;
     
    148178{ TChronisClient }
    149179
     180function TChronisClient.GetConnected: Boolean;
     181begin
     182  Result := False;
     183end;
     184
    150185constructor TChronisClient.Create;
    151186begin
  • trunk/Application/UDataTypes.pas

    r23 r37  
    66
    77uses
    8   Classes, SysUtils, Controls, Spin, StdCtrls, ExtCtrls, MaskEdit, EditBtn;
     8  Classes, SysUtils, Controls, Spin, StdCtrls, ExtCtrls, MaskEdit, EditBtn,
     9  UChronisClient;
    910
    1011type
     
    147148function GetDataType(ACustomType: Integer): TDataType;
    148149var
    149   DbRows: TDbRows;
     150  Proxy: TListProxy;
    150151  BaseType: Integer;
    151152begin
    152153  try
    153     DbRows := TDbRows.Create;
    154     Core.System.Database.Select(DbRows, CustomTypeTableName, '*', 'Id=' + IntToStr(ACustomType));
    155     BaseType := StrToInt(DbRows[0].Values['Type']);
     154    Proxy := TListProxy.Create;
     155    Proxy.Client := Core.System.Client;
     156    Proxy.ObjectName := CustomTypeTableName;
     157    Proxy.Condition := 'Id=' + IntToStr(ACustomType);
     158    Proxy.Load;
     159    BaseType := StrToInt(TObjectProxy(Proxy.Objects[0]).Properties.Values['Type']);
    156160  finally
    157     DbRows.Free;
     161    Proxy.Free;
    158162  end;
    159163
     
    231235procedure TDataTypeRelationMany.LoadDef(ACustomType: Integer);
    232236var
    233   DbRows: TDbRows;
     237  Proxy: TListProxy;
    234238  BaseType: Integer;
    235239begin
    236240  try
    237     DbRows := TDbRows.Create;
    238     Core.System.Database.Select(DbRows, TypeRelationMany, '*', 'CustomType=' + IntToStr(ACustomType));
    239     PropertyID := StrToInt(DbRows[0].Values['ObjectProperty']);
     241    Proxy := TListProxy.Create;
     242    Proxy.Client := Core.System.Client;
     243    Proxy.ObjectName := TypeRelationMany;
     244    Proxy.Condition := 'CustomType=' + IntToStr(ACustomType);
     245    Proxy.Load;
     246    PropertyID := StrToInt(TObjectProxy(Proxy.Objects[0]).Properties.Values['ObjectProperty']);
    240247  finally
    241     DbRows.Free;
     248    Proxy.Free;
    242249  end;
    243250  try
    244     DbRows := TDbRows.Create;
    245     Core.System.Database.Select(DbRows, PropertyTable, '*', 'Id=' + IntToStr(PropertyID));
    246     ObjectId := StrToInt(DbRows[0].Values['Object']);
    247     PropertyName := DbRows[0].Values['ColumnName'];
     251    Proxy := TListProxy.Create;
     252    Proxy.Client := Core.System.Client;
     253    Proxy.ObjectName := PropertyTable;
     254    Proxy.Condition := 'Id=' + IntToStr(PropertyID);
     255    ObjectId := StrToInt(TObjectProxy(Proxy.Objects[0]).Properties.Values['Object']);
     256    PropertyName := TObjectProxy(Proxy.Objects[0]).Properties.Values['ColumnName'];
    248257  finally
    249     DbRows.Free;
     258    Proxy.Free;
    250259  end;
    251260end;
     
    286295procedure TDataTypeRelationOne.LoadDef(ACustomType: Integer);
    287296var
    288   DbRows: TDbRows;
     297  Proxy: TListProxy;
    289298begin
    290299  try
    291     DbRows := TDbRows.Create;
    292     Core.System.Database.Select(DbRows, TypeRelationOne, '*', 'CustomType=' + IntToStr(ACustomType));
    293     ObjectId := StrToInt(DbRows[0].Values['Object']);
     300    Proxy := TListProxy.Create;
     301    Proxy.Client := Core.System.Client;
     302    Proxy.ObjectName := TypeRelationOne;
     303    Proxy.Condition := 'CustomType=' + IntToStr(ACustomType);
     304    Proxy.Load;
     305    ObjectId := StrToInt(TObjectProxy(Proxy.Objects[0]).Properties.Values['Object']);
    294306  finally
    295     DbRows.Free;
     307    Proxy.Free;
    296308  end;
    297309end;
  • trunk/Forms/UItemAdd.pas

    r31 r37  
    88  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls,
    99  StdCtrls, Spin, EditBtn, MaskEdit, USqlDatabase, USystem,
    10   SpecializedDictionary, SpecializedList;
     10  SpecializedDictionary, SpecializedList, UChronisClient;
    1111
    1212type
     
    5353var
    5454  Data: TDictionaryStringString;
     55  NewProxy: TObjectProxy;
    5556  I: Integer;
    5657  DataType: TDataType;
     
    5960  try
    6061    Data := TDictionaryStringString.Create;
     62    NewProxy := TObjectProxy.Create;
     63    NewProxy.Client := Client;
     64    NewProxy.ObjectName := SelectedObject.Table;
     65    NewProxy.SchemaName := SelectedObject.Schema;
    6166    for I := 0 to Report.Columns.Count - 1 do
    6267    if not (TReportColumn(Report.Columns[I]).CustomType is TDataTypeRelationMany) then
    6368    if TReportColumn(Report.Columns[I]).ColumnName <> SelectedObject.PrimaryKey then begin
    6469      DataType := TReportColumn(Report.Columns[I]).CustomType;
    65       Data.Add(TReportColumn(Report.Columns[I]).ColumnName,
     70      NewProxy.Properties.Add(TReportColumn(Report.Columns[I]).ColumnName,
    6671        DataType.GetControlValue(TWinControl(TReportColumn(Report.Columns[I]).Control)));
    6772    end;
    68     Database.Insert(SelectedObject.Table, Data, SelectedObject.Schema);
     73    NewProxy.Save;
    6974  finally
    7075    Data.Free;
     76    NewProxy.Free;
    7177  end;
    7278  //MainForm.LoadItemList;
  • trunk/Forms/UItemEdit.pas

    r31 r37  
    11unit UItemEdit;
    22
    3 {$mode objfpc}{$H+}
     3{$mode Delphi}{$H+}
    44
    55interface
     
    88  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls,
    99  StdCtrls, Spin, EditBtn, USqlDatabase, MaskEdit, ComCtrls, USystem,
    10   SpecializedList, SpecializedDictionary;
     10  SpecializedList, SpecializedDictionary, UChronisClient;
    1111
    1212type
     
    119119procedure TItemEditForm.ButtonSaveClick(Sender: TObject);
    120120var
    121   Data: TDictionaryStringString;
     121  Proxy: TObjectProxy;
    122122  I: Integer;
    123123  DataType: TDataType;
     
    125125  with Core.System do
    126126  try
    127     Data := TDictionaryStringString.Create;
     127    Proxy := TObjectProxy.Create;
     128    Proxy.Client := Client;
     129    Proxy.ObjectName := SelectedObject.Table;
     130    Proxy.SchemaName := SelectedObject.Schema;
     131    Proxy.Id := SelectedItemId;
    128132    for I := 0 to Report.Columns.Count - 1 do
    129133    if not (TReportColumn(Report.Columns[I]).CustomType is TDataTypeRelationMany) then
    130134    if TReportColumn(Report.Columns[I]).ColumnName <> SelectedObject.PrimaryKey then begin
    131135      DataType := TReportColumn(Report.Columns[I]).CustomType;
    132       Data.Add(TReportColumn(Report.Columns[I]).ColumnName,
     136      Proxy.Properties.Add(TReportColumn(Report.Columns[I]).ColumnName,
    133137        DataType.GetControlValue(TWinControl(TReportColumn(Report.Columns[I]).Control)));
    134138    end;
    135     Database.Update(SelectedObject.Table, Data,
    136       '`' + SelectedObject.PrimaryKey + '` = ' + IntToStr(SelectedItemId), SelectedObject.Schema);
     139    Proxy.Save;
    137140  finally
    138     Data.Free;
     141    Proxy.Free;
    139142  end;
    140143  if (SelectedObject.Table = ObjectGroupTable) or
  • trunk/Forms/UMainForm.pas

    r36 r37  
    148148procedure TMainForm.UpdateInterface;
    149149begin
    150   ADisconnect.Enabled := Core.System.Database.Connected;
    151   AConnect.Enabled := not Core.System.Database.Connected;
    152   AImportStructure.Enabled := Core.System.Database.Connected;
     150  ADisconnect.Enabled := Core.System.Client.Connected;
     151  AConnect.Enabled := not Core.System.Client.Connected;
     152  AImportStructure.Enabled := Core.System.Client.Connected;
    153153  if Assigned(MainPanelForm) then
    154154    Caption := MainPanelForm.Caption + ' - ' + ApplicationInfo.Name
     
    257257  if LoginForm.ShowModal = mrOK then begin
    258258    with TConnectProfile(Core.Profiles[Core.LastProfile]) do begin
    259       Core.System.Database.HostName := HostName;
    260       Core.System.Database.Database := Database;
    261       Core.System.Database.UserName := Core.LastUserName;
    262       Core.System.Database.Password := Core.LastPassword;
    263       Core.System.Database.Port := Port;
     259      Core.System.Client.Host := HostName;
     260      Core.System.Client.Schema := Database;
     261      Core.System.Client.User := Core.LastUserName;
     262      Core.System.Client.Password := Core.LastPassword;
     263      Core.System.Client.Port := Port;
    264264      if Protocol = cpDirect then Core.Client := TChronisClientDirect.Create;
    265265    end;
    266266    try
    267       Core.System.Database.Connect;
     267      Core.System.Client.Connect;
    268268      if Core.System.IsDatabaseEmpty then Core.System.ModuleSystem.Install;
    269269      Core.System.LoadTypes;
     
    277277procedure TMainForm.ADisconnectExecute(Sender: TObject);
    278278begin
    279   if Core.System.Database.Connected then begin
    280     Core.System.Database.Disconnect;
     279  if Core.System.Client.Connected then begin
     280    Core.System.Client.Disconnect;
    281281    TreeView1.Items.Clear;
    282282    Core.System.Types.Clear;
     
    361361      Groups.Client := Core.System.Client;
    362362      Groups.ObjectName := ObjectGroupTable;
    363       Groups.SchemaName := Core.System.Database.Database;
     363      Groups.SchemaName := Core.System.Client.Schema;
    364364      Groups.Load;
    365365      for I := 0 to Groups.Objects.Count - 1 do begin
     
    373373          Objects.Client := Core.System.Client;
    374374          Objects.ObjectName := ObjectTable;
    375           Objects.SchemaName := Core.System.Database.Database;
    376           Objects.SetCondition('Group', Obj.Properties.Values['Id']);
     375          Objects.SchemaName := Core.System.Client.Schema;
     376          Objects.Condition := '`Group`="' + Obj.Properties.Values['Id'] + '"';
    377377          Objects.Load;
    378378          for O := 0 to Objects.Objects.Count - 1 do begin
  • trunk/Module/UModuleSystem.pas

    r29 r37  
    2626
    2727uses
    28   USystem, USqlDatabase;
     28  USystem, USqlDatabase, UChronisClient;
    2929
    3030{ TModuleSystem }
     
    8686  GroupId := AddObjectGroup('System');
    8787
    88   ObjectGroupId := AddObject('Object groups', 'ObjectGroup', Database.Database, GroupId);
     88  ObjectGroupId := AddObject('Object groups', 'ObjectGroup', Client.Schema, GroupId);
    8989    AddPropertyNumber(ObjectGroupId, 'Id', 'Id', False);
    9090    AddPropertyString(ObjectGroupId, 'Name', 'Name', True);
    9191    ObjectGroupParentId := AddPropertyRelationOne(ObjectGroupId, 'Parent', 'Parent', True, ObjectGroupId);
    9292
    93   ObjectId := AddObject('Objects', 'Object', Database.Database, GroupId);
     93  ObjectId := AddObject('Objects', 'Object', Client.Schema, GroupId);
    9494    AddPropertyNumber(ObjectId, 'Id', 'Id', False);
    9595    AddPropertyString(ObjectId, 'Name', 'Name', True);
     
    100100    AddPropertyNumber(ObjectId, 'Sequence', 'Sequence', True);
    101101
    102   PropertyTypeId := AddObject('Property types', 'Type', Database.Database, GroupId);
     102  PropertyTypeId := AddObject('Property types', 'Type', Client.Schema, GroupId);
    103103    AddPropertyNumber(PropertyTypeId, 'Id', 'Id', False);
    104104    AddPropertyString(PropertyTypeId, 'Name', 'Name', True);
     
    106106    //AddPropertyNumber(ObjectId, 'Parent', 'Parent');
    107107
    108   CustomTypeId := AddObject('Custom types', 'TypeCustom', Database.Database, GroupId);
     108  CustomTypeId := AddObject('Custom types', 'TypeCustom', Client.Schema, GroupId);
    109109    AddPropertyNumber(CustomTypeId, 'Id', 'Id', False);
    110110    CustomTypeIdType := AddPropertyRelationOne(CustomTypeId, 'Type', 'Type', True, PropertyTypeId);
    111111
    112   ObjectPropertyGroupId := AddObject('Property groups', 'PropertyGroup', Database.Database, GroupId);
     112  ObjectPropertyGroupId := AddObject('Property groups', 'PropertyGroup', Client.Schema, GroupId);
    113113    AddPropertyNumber(ObjectPropertyGroupId, 'Id', 'Id', False);
    114114
    115   ObjectPropertyId := AddObject('Properties', 'Property', Database.Database, GroupId);
     115  ObjectPropertyId := AddObject('Properties', 'Property', Client.Schema, GroupId);
    116116    AddPropertyNumber(ObjectPropertyId, 'Id', 'Id', False);
    117117    AddPropertyString(ObjectPropertyId, 'Name', 'Name', True);
     
    127127    AddPropertyRelationMany(ObjectPropertyGroupId, 'Properties', 'Properties', True, ObjectPropertyIdGroup);
    128128    AddPropertyRelationMany(PropertyTypeId, 'Custom types', 'CustomTypes', True, CustomTypeIdType);
    129   ModuleId := AddObject('Modules', 'Module', Database.Database, GroupId);
     129
     130  ModuleId := AddObject('Modules', 'Module', Client.Schema, GroupId);
    130131    AddPropertyNumber(ModuleId, 'Id', 'Id', False);
    131132    AddPropertyString(ModuleId, 'Name', 'Name', True);
     
    149150procedure TModuleSystem.InitStructure;
    150151var
    151   DbRows: TDbRows;
    152   DbRows2: TDbRows;
    153152  StructureVersion: string;
    154153  Data: TDictionaryStringString;
     
    156155  Tables: TListString;
    157156  I: Integer;
     157  NewProxy: TListProxy;
    158158begin
    159159  with TChronisBase(System) do
    160160  try
    161     DbRows := TDbRows.Create;
    162161    Tables := TListString.Create;
    163162    Data := TDictionaryStringString.Create;
    164163
    165     Database.Query(DbRows, 'SHOW TABLES');
    166     Tables.Count := DbRows.Count;
    167     for I := 0 to DbRows.Count - 1 do
    168       Tables[I] := DbRows[I].Items[0].Value;
    169 
    170     if Tables.IndexOf(InformationTable) = -1 then begin
    171       Database.Query(DbRows, 'CREATE TABLE IF NOT EXISTS `' + InformationTable + '` ( ' +
    172   '`Version` varchar(255) NOT NULL,' +
    173   '`LastUpdateTime` datetime NOT NULL' +
    174 ') ENGINE=InnoDB DEFAULT CHARSET=utf8;');
    175       Database.Query(DbRows, 'INSERT INTO `' + InformationTable + '` (`Version`, `LastUpdateTime`) VALUES ' +
    176   '("0.1", "0000-00-00 00:00:00");');
    177     end;
    178     Database.Select(DbRows, InformationTable);
    179     StructureVersion := DbRows[0].Values['Version'];
    180 
    181     if Tables.IndexOf(ObjectTable) = -1 then begin
     164    NewProxy := TListProxy.Create;
     165    NewProxy.SchemaName := 'information_schema';
     166    NewProxy.ObjectName := 'TABLES';
     167    NewProxy.Condition := 'TABLE_SCHEMA = "' + Client.Schema + '"';
     168    NewProxy.Load;
     169    //Database.Query(DbRows, 'SHOW TABLES');
     170    Tables.Count := NewProxy.Objects.Count;
     171    for I := 0 to NewProxy.Objects.Count - 1 do
     172      Tables[I] := TObjectProxy(NewProxy.Objects[I]).Properties.Values['TABLE'];
     173
     174(*    if Tables.IndexOf(ObjectTable) = -1 then begin
    182175      Database.Query(DbRows, 'CREATE TABLE IF NOT EXISTS `' + ObjectTable + '` ( ' +
    183176        '`Id` int(11) NOT NULL AUTO_INCREMENT,' +
     
    372365        'PRIMARY KEY (`Id`)' +
    373366        ') ENGINE=InnoDB  DEFAULT CHARSET=utf8');
    374     end;
     367    end;   *)
    375368  finally
    376369    Tables.Free;
    377370    Data.Free;
    378     DbRows.Free;
     371    NewProxy.Free;
    379372  end;
    380373end;
  • trunk/UCore.pas

    r33 r37  
    5555  LoadFromRegistry;
    5656  System := TChronisBase.Create;
    57   System.Database := SqlDatabase1;
    5857  System.Client := TChronisClientMySQL.Create;
    5958  TChronisClientMySQL(System.Client).Database := SqlDatabase1;
  • trunk/USystem.pas

    r35 r37  
    106106    Types: TChronisTypeList;
    107107    Client: TChronisClient;
    108     Database: TSqlDatabase;
     108    //Database: TSqlDatabase;
    109109    Modules: TListObject; // TListObject<TChronisModule>
    110110    ModuleSystem: TChronisModule;
     
    207207      Properties.Client := Base.Client;
    208208      Properties.ObjectName := PropertyTable;
    209       Properties.SchemaName := Base.Database.Database;
    210       Properties.SetCondition('Object', IntToStr(Obj.Id));
     209      Properties.SchemaName := Base.Client.Schema;
     210      Properties.Condition := 'Object="' + IntToStr(Obj.Id) + '"';
    211211      Properties.Load;
    212212      Columns.Clear;
     
    262262function TChronisBase.AddType(Name, DataType: string; TypeIndex: TDbValueType): Integer;
    263263var
    264   DbRows: TDbRows;
    265   Data: TDictionaryStringString;
    266 begin
    267   try
    268     DbRows := TDbRows.Create;
    269     Data := TDictionaryStringString.Create;
    270     Data.Add('Name', Name);
    271     Data.Add('DbType', DataType);
    272     Data.Add('Id', IntToStr(Integer(TypeIndex)));
    273     Database.Insert(PropertyTypeTable, Data);
    274     Result := Database.LastInsertId;
    275   finally
    276     Data.Free;
    277     DbRows.Free;
     264  Proxy: TObjectProxy;
     265begin
     266  try
     267    Proxy := TObjectProxy.Create;
     268    Proxy.Client := Client;
     269    Proxy.ObjectName := PropertyTypeTable;
     270    Proxy.Properties.Add('Name', Name);
     271    Proxy.Properties.Add('DbType', DataType);
     272    Proxy.Properties.Add('Id', IntToStr(Integer(TypeIndex)));
     273    Proxy.Save;
     274    Result := Proxy.Id;
     275  finally
     276    Proxy.Free;
    278277  end;
    279278end;
     
    281280function TChronisBase.AddGroup(Name: string; ParentGroupId: Integer): Integer;
    282281var
    283   DbRows: TDbRows;
    284   Data: TDictionaryStringString;
    285 begin
    286   try
    287     DbRows := TDbRows.Create;
    288     Data := TDictionaryStringString.Create;
    289     Data.Add('Name', Name);
    290     Data.Add('Parent', IntToStr(ParentGroupId));
    291     Database.Insert(ObjectGroupTable, Data);
    292     Result := Database.LastInsertId;
    293   finally
    294     Data.Free;
    295     DbRows.Free;
     282  Proxy: TObjectProxy;
     283begin
     284  try
     285    Proxy := TObjectProxy.Create;
     286    Proxy.Client := Client;
     287    Proxy.ObjectName := ObjectGroupTable;
     288    Proxy.Properties.Add('Name', Name);
     289    Proxy.Properties.Add('Parent', IntToStr(ParentGroupId));
     290    Proxy.Save;
     291    Result := Proxy.Id;
     292  finally
     293    Proxy.Free;
    296294  end;
    297295end;
     
    300298  GroupId: Integer): Integer;
    301299var
    302   DbRows: TDbRows;
    303   Data: TDictionaryStringString;
    304 begin
    305   try
    306     DbRows := TDbRows.Create;
    307     Data := TDictionaryStringString.Create;
    308     Data.Add('Name', Name);
    309     Data.Add('Schema', Schema);
    310     Data.Add('Table', TableName);
    311     Data.Add('Group', IntToStr(GroupId));
    312     Database.Insert(ObjectTable, Data);
    313     Result := Database.LastInsertId;
    314   finally
    315     Data.Free;
    316     DbRows.Free;
     300  Proxy: TObjectProxy;
     301begin
     302  try
     303    Proxy := TObjectProxy.Create;
     304    Proxy.Client := Client;
     305    Proxy.ObjectName := ObjectTable;
     306    Proxy.Properties.Add('Name', Name);
     307    Proxy.Properties.Add('Schema', Schema);
     308    Proxy.Properties.Add('Table', TableName);
     309    Proxy.Properties.Add('Group', IntToStr(GroupId));
     310    Proxy.Save;
     311    Result := Proxy.Id;
     312  finally
     313    Proxy.Free;
    317314  end;
    318315end;
     
    321318  CustomType: Integer; Editable: Boolean): Integer;
    322319var
    323   DbRows: TDbRows;
    324   Data: TDictionaryStringString;
    325 begin
    326   try
    327     DbRows := TDbRows.Create;
    328     Data := TDictionaryStringString.Create;
    329     Data.Add('Name', Name);
    330     Data.Add('Object', IntToStr(ObjectId));
    331     Data.Add('ColumnName', ColumnName);
    332     Data.Add('CustomType', IntToStr(CustomType));
    333     Data.Add('Editable', IntToStr(Integer(Editable)));
    334     Database.Insert(PropertyTable, Data);
    335     Result := Database.LastInsertId;
    336   finally
    337     Data.Free;
    338     DbRows.Free;
     320  Proxy: TObjectProxy;
     321begin
     322  try
     323    Proxy := TObjectProxy.Create;
     324    Proxy.Client := Client;
     325    Proxy.ObjectName := PropertyTable;
     326    Proxy.Properties.Add('Name', Name);
     327    Proxy.Properties.Add('Object', IntToStr(ObjectId));
     328    Proxy.Properties.Add('ColumnName', ColumnName);
     329    Proxy.Properties.Add('CustomType', IntToStr(CustomType));
     330    Proxy.Properties.Add('Editable', IntToStr(Integer(Editable)));
     331    Proxy.Save;
     332    Result := Proxy.Id;
     333  finally
     334    Proxy.Free;
    339335  end;
    340336end;
     
    344340  Max: Integer = High(Integer)): Integer;
    345341var
    346   DbRows: TDbRows;
    347   Data: TDictionaryStringString;
     342  Proxy: TObjectProxy;
    348343  CustomTypeId: Integer;
    349344begin
    350345  try
    351     DbRows := TDbRows.Create;
    352     Data := TDictionaryStringString.Create;
    353 
    354     Data.Clear;
    355     Data.Add('Type', IntToStr(Integer(vtInteger)));
    356     Database.Insert(CustomTypeTableName, Data);
    357     CustomTypeId := Database.LastInsertId;
    358 
    359     Data.Clear;
    360     Data.Add('CustomType', IntToStr(CustomTypeId));
    361     Data.Add('Min', IntToStr(Min));
    362     Data.Add('Max', IntToStr(Max));
    363     Data.Add('Default', IntToStr(Default));
    364     Database.Insert(TypeNumber, Data);
     346    Proxy := TObjectProxy.Create;
     347    Proxy.Client := Client;
     348    Proxy.ObjectName := CustomTypeTableName;
     349    Proxy.Properties.Add('Type', IntToStr(Integer(vtInteger)));
     350    CustomTypeId := Proxy.Id;
     351
     352    Proxy.ObjectName := TypeNumber;
     353    Proxy.Properties.Clear;
     354    Proxy.Properties.Add('CustomType', IntToStr(CustomTypeId));
     355    Proxy.Properties.Add('Min', IntToStr(Min));
     356    Proxy.Properties.Add('Max', IntToStr(Max));
     357    Proxy.Properties.Add('Default', IntToStr(Default));
     358    Proxy.Save;
    365359    //CustomTypeId := Database.LastInsertId;
    366360
    367361    Result := AddProperty(ObjectId, Name, ColumnName, CustomTypeId, Editable);
    368   finally
    369     Data.Free;
    370     DbRows.Free;
     362    Result := Proxy.Id;
     363  finally
     364    Proxy.Free;
    371365  end;
    372366end;
     
    375369  ColumnName: string; Editable: Boolean; Default: Double; Min: Double; Max: Double): Integer;
    376370var
    377   DbRows: TDbRows;
    378   Data: TDictionaryStringString;
     371  Proxy: TObjectProxy;
    379372  CustomTypeId: Integer;
    380373begin
    381374  try
    382     DbRows := TDbRows.Create;
    383     Data := TDictionaryStringString.Create;
    384 
    385     Data.Clear;
    386     Data.Add('Type', IntToStr(Integer(vtFloat)));
    387     Database.Insert(CustomTypeTableName, Data);
    388     CustomTypeId := Database.LastInsertId;
    389 
    390     Data.Clear;
    391     Data.Add('CustomType', IntToStr(CustomTypeId));
    392     Data.Add('Min', MySQLFloatToStr(Min));
    393     Data.Add('Max', MySQLFloatToStr(Max));
    394     Data.Add('Default', MySQLFloatToStr(Default));
    395     Database.Insert(TypeFloat, Data);
     375    Proxy := TObjectProxy.Create;
     376    Proxy.Client := Client;
     377    Proxy.ObjectName := CustomTypeTableName;
     378    Proxy.Properties.Add('Type', IntToStr(Integer(vtFloat)));
     379    CustomTypeId := Proxy.Id;
     380
     381    Proxy.ObjectName := TypeFloat;
     382    Proxy.Properties.Clear;
     383    Proxy.Properties.Add('CustomType', IntToStr(CustomTypeId));
     384    Proxy.Properties.Add('Min', MySQLFloatToStr(Min));
     385    Proxy.Properties.Add('Max', MySQLFloatToStr(Max));
     386    Proxy.Properties.Add('Default', MySQLFloatToStr(Default));
     387    Proxy.Save;
    396388    //CustomTypeId := Database.LastInsertId;
    397389
    398390    Result := AddProperty(ObjectId, Name, ColumnName, CustomTypeId, Editable);
    399391  finally
    400     Data.Free;
    401     DbRows.Free;
     392    Proxy.Free;
    402393  end;
    403394end;
     
    407398  ): Integer;
    408399var
    409   DbRows: TDbRows;
    410   Data: TDictionaryStringString;
     400  Proxy: TObjectProxy;
    411401  CustomTypeId: Integer;
    412402begin
    413403  try
    414     DbRows := TDbRows.Create;
    415     Data := TDictionaryStringString.Create;
    416 
    417     Data.Clear;
    418     Data.Add('Type', IntToStr(Integer(vtDateTime)));
    419     Database.Insert(CustomTypeTableName, Data);
    420     CustomTypeId := Database.LastInsertId;
    421 
    422     Data.Clear;
    423     Data.Add('CustomType', IntToStr(CustomTypeId));
    424     Data.Add('Min', DateTimeToSQL(Min));
    425     Data.Add('Max', DateTimeToSQL(Max));
    426     Data.Add('Default', DateTimeToSQL(Default));
    427     Database.Insert(TypeDateTime, Data);
     404    Proxy := TObjectProxy.Create;
     405    Proxy.Client := Client;
     406    Proxy.ObjectName := CustomTypeTableName;
     407    Proxy.Properties.Add('Type', IntToStr(Integer(vtDateTime)));
     408    Proxy.Save;
     409    CustomTypeId := Proxy.Id;
     410
     411    Proxy.ObjectName := TypeDateTime;
     412    Proxy.Properties.Clear;
     413    Proxy.Properties.Add('CustomType', IntToStr(CustomTypeId));
     414    Proxy.Properties.Add('Min', DateTimeToSQL(Min));
     415    Proxy.Properties.Add('Max', DateTimeToSQL(Max));
     416    Proxy.Properties.Add('Default', DateTimeToSQL(Default));
     417    Proxy.Save;
    428418    //CustomTypeId := Database.LastInsertId;
    429419
    430420    Result := AddProperty(ObjectId, Name, ColumnName, CustomTypeId, Editable);
    431421  finally
    432     Data.Free;
    433     DbRows.Free;
     422    Proxy.Free;
    434423  end;
    435424end;
     
    438427  ColumnName: string; Editable: Boolean; Default: string = ''; MaxLength: Integer = 255): Integer;
    439428var
    440   DbRows: TDbRows;
    441   Data: TDictionaryStringString;
     429  Proxy: TObjectProxy;
    442430  CustomTypeId: Integer;
    443431begin
    444432  try
    445     DbRows := TDbRows.Create;
    446     Data := TDictionaryStringString.Create;
    447 
    448     Data.Clear;
    449     Data.Add('Type', IntToStr(Integer(vtString)));
    450     Database.Insert(CustomTypeTableName, Data);
    451     CustomTypeId := Database.LastInsertId;
    452 
    453     Data.Clear;
    454     Data.Add('CustomType', IntToStr(CustomTypeId));
    455     Data.Add('MaxLength', IntToStr(MaxLength));
    456     Data.Add('Default', Default);
    457     Database.Insert(TypeString, Data);
     433    Proxy := TObjectProxy.Create;
     434    Proxy.Client := Client;
     435    Proxy.ObjectName := CustomTypeTableName;
     436    Proxy.Properties.Add('Type', IntToStr(Integer(vtString)));
     437    Proxy.Save;
     438    CustomTypeId := Proxy.Id;
     439
     440    Proxy.ObjectName := TypeString;
     441    Proxy.Properties.Clear;
     442    Proxy.Properties.Add('CustomType', IntToStr(CustomTypeId));
     443    Proxy.Properties.Add('MaxLength', IntToStr(MaxLength));
     444    Proxy.Properties.Add('Default', Default);
     445    Proxy.Save;
    458446    //CustomTypeId := Database.LastInsertId;
    459447
    460448    Result := AddProperty(ObjectId, Name, ColumnName, CustomTypeId, Editable);
    461449  finally
    462     Data.Free;
    463     DbRows.Free;
     450    Proxy.Free;
    464451  end;
    465452end;
     
    468455  ColumnName: string; Editable: Boolean; Default: string): Integer;
    469456var
    470   DbRows: TDbRows;
    471   Data: TDictionaryStringString;
     457  Proxy: TObjectProxy;
    472458  CustomTypeId: Integer;
    473459begin
    474460  try
    475     DbRows := TDbRows.Create;
    476     Data := TDictionaryStringString.Create;
    477 
    478     Data.Clear;
    479     Data.Add('Type', IntToStr(Integer(vtText)));
    480     Database.Insert(CustomTypeTableName, Data);
    481     CustomTypeId := Database.LastInsertId;
    482 
    483     Data.Clear;
    484     Data.Add('CustomType', IntToStr(CustomTypeId));
    485     Data.Add('Default', Default);
    486     Database.Insert(TypeString, Data);
     461    Proxy := TObjectProxy.Create;
     462    Proxy.Client := Client;
     463    Proxy.ObjectName := CustomTypeTableName;
     464    Proxy.Properties.Add('Type', IntToStr(Integer(vtText)));
     465    Proxy.Save;
     466    CustomTypeId := Proxy.Id;
     467
     468    Proxy.ObjectName := TypeString;
     469    Proxy.Properties.Clear;
     470    Proxy.Properties.Add('CustomType', IntToStr(CustomTypeId));
     471    Proxy.Properties.Add('Default', Default);
     472    Proxy.Save;
    487473    //CustomTypeId := Database.LastInsertId;
    488474
    489475    Result := AddProperty(ObjectId, Name, ColumnName, CustomTypeId, Editable);
    490476  finally
    491     Data.Free;
    492     DbRows.Free;
     477    Proxy.Free;
    493478  end;
    494479end;
     
    497482  ColumnName: string; Editable: Boolean; ReferedObject: Integer): Integer;
    498483var
    499   DbRows: TDbRows;
    500   Data: TDictionaryStringString;
     484  Proxy: TObjectProxy;
    501485  CustomTypeId: Integer;
    502486begin
    503487  try
    504     DbRows := TDbRows.Create;
    505     Data := TDictionaryStringString.Create;
    506 
    507     Data.Clear;
    508     Data.Add('Type', IntToStr(Integer(vtRelationOne)));
    509     Database.Insert(CustomTypeTableName, Data);
    510     CustomTypeId := Database.LastInsertId;
    511 
    512     Data.Clear;
    513     Data.Add('CustomType', IntToStr(CustomTypeId));
    514     Data.Add('Object', IntToStr(ReferedObject));
    515     Database.Insert(TypeRelationOne, Data);
     488    Proxy := TObjectProxy.Create;
     489    Proxy.Client := Client;
     490    Proxy.ObjectName := CustomTypeTableName;
     491    Proxy.Properties.Add('Type', IntToStr(Integer(vtRelationOne)));
     492    Proxy.Save;
     493    CustomTypeId := Proxy.Id;
     494
     495    Proxy.ObjectName := TypeRelationOne;
     496    Proxy.Properties.Clear;
     497    Proxy.Properties.Add('CustomType', IntToStr(CustomTypeId));
     498    Proxy.Properties.Add('Object', IntToStr(ReferedObject));
     499    Proxy.Save;
    516500    //CustomTypeId := Database.LastInsertId;
    517501
    518502    Result := AddProperty(ObjectId, Name, ColumnName, CustomTypeId, Editable);
    519503  finally
    520     Data.Free;
    521     DbRows.Free;
     504    Proxy.Free;
    522505  end;
    523506end;
     
    526509  ColumnName: string; Editable: Boolean; ReferedObjectProperty: Integer): Integer;
    527510var
    528   DbRows: TDbRows;
    529   Data: TDictionaryStringString;
     511  Proxy: TObjectProxy;
    530512  CustomTypeId: Integer;
    531513begin
    532514  try
    533     DbRows := TDbRows.Create;
    534     Data := TDictionaryStringString.Create;
    535 
    536     Data.Clear;
    537     Data.Add('Type', IntToStr(Integer(vtRelationMany)));
    538     Database.Insert(CustomTypeTableName, Data);
    539     CustomTypeId := Database.LastInsertId;
    540 
    541     Data.Clear;
    542     Data.Add('CustomType', IntToStr(CustomTypeId));
    543     Data.Add('ObjectProperty', IntToStr(ReferedObjectProperty));
    544     Database.Insert(TypeRelationMany, Data);
     515    Proxy := TObjectProxy.Create;
     516    Proxy.Client := Client;
     517    Proxy.ObjectName := CustomTypeTableName;
     518
     519    Proxy.Properties.Clear;
     520    Proxy.Properties.Add('Type', IntToStr(Integer(vtRelationMany)));
     521    Proxy.Save;
     522    CustomTypeId := Proxy.Id;
     523
     524    Proxy.ObjectName := TypeRelationMany;
     525    Proxy.Properties.Clear;
     526    Proxy.Properties.Add('CustomType', IntToStr(CustomTypeId));
     527    Proxy.Properties.Add('ObjectProperty', IntToStr(ReferedObjectProperty));
     528    Proxy.Save;
    545529    //CustomTypeId := Database.LastInsertId;
    546530
    547531    Result := AddProperty(ObjectId, Name, ColumnName, CustomTypeId, Editable);
    548532  finally
    549     Data.Free;
    550     DbRows.Free;
     533    Proxy.Free;
    551534  end;
    552535end;
     
    554537function TChronisBase.AddObjectGroup(Name: string): Integer;
    555538var
    556   DbRows: TDbRows;
    557   Data: TDictionaryStringString;
    558 begin
    559   try
    560     DbRows := TDbRows.Create;
    561     Data := TDictionaryStringString.Create;
    562     Data.Add('Name', Name);
    563     Database.Insert(ObjectGroupTable, Data);
    564     Result := Database.LastInsertId;
    565   finally
    566     Data.Free;
    567     DbRows.Free;
     539  Proxy: TObjectProxy;
     540begin
     541  try
     542    Proxy := TObjectProxy.Create;
     543    Proxy.Client := Client;
     544    Proxy.ObjectName := ObjectGroupTable;
     545    Proxy.Properties.Add('Name', Name);
     546    Proxy.Save;
     547    Result := Proxy.Id;
     548  finally
     549    Proxy.Free;
    568550  end;
    569551end;
     
    571553function TChronisBase.AddEnumeration(Name: string): Integer;
    572554var
    573   DbRows: TDbRows;
    574   Data: TDictionaryStringString;
    575 begin
    576   try
    577     DbRows := TDbRows.Create;
    578     Data := TDictionaryStringString.Create;
    579     Data.Add('Name', Name);
    580     Database.Insert(Enumeration, Data);
    581     Result := Database.LastInsertId;
    582   finally
    583     Data.Free;
    584     DbRows.Free;
     555  Proxy: TObjectProxy;
     556begin
     557  try
     558    Proxy := TObjectProxy.Create;
     559    Proxy.Client := Client;
     560    Proxy.ObjectName := Enumeration;
     561    Proxy.Properties.Add('Name', Name);
     562    Proxy.Save;
     563    Result := Proxy.Id;
     564  finally
     565    Proxy.Free;
    585566  end;
    586567end;
     
    589570  ): Integer;
    590571var
    591   DbRows: TDbRows;
    592   Data: TDictionaryStringString;
    593 begin
    594   try
    595     DbRows := TDbRows.Create;
    596     Data := TDictionaryStringString.Create;
    597     Data.Add('Enumeration', IntToStr(Enum));
    598     Data.Add('Name', Name);
    599     Database.Insert(EnumerationState, Data);
    600     Result := Database.LastInsertId;
    601   finally
    602     Data.Free;
    603     DbRows.Free;
     572  Proxy: TObjectProxy;
     573begin
     574  try
     575    Proxy := TObjectProxy.Create;
     576    Proxy.Client := Client;
     577    Proxy.ObjectName := EnumerationState;
     578    Proxy.Properties.Add('Enumeration', IntToStr(Enum));
     579    Proxy.Properties.Add('Name', Name);
     580    Proxy.Save;
     581    Result := Proxy.Id;
     582  finally
     583    Proxy.Free;
    604584  end;
    605585end;
     
    608588  License: string): Integer;
    609589var
    610   DbRows: TDbRows;
    611   Data: TDictionaryStringString;
    612 begin
    613   try
    614     DbRows := TDbRows.Create;
    615     Data := TDictionaryStringString.Create;
    616     Data.Add('Name', Name);
    617     Data.Add('Author', Author);
    618     Data.Add('Website', Website);
    619     Data.Add('Version', Version);
    620     Data.Add('Description', Description);
    621     Data.Add('License', License);
    622     Database.Insert(ModuleTable, Data);
    623     Result := Database.LastInsertId;
    624   finally
    625     Data.Free;
    626     DbRows.Free;
     590  Proxy: TObjectProxy;
     591begin
     592  try
     593    Proxy := TObjectProxy.Create;
     594    Proxy.Client := Client;
     595    Proxy.ObjectName := ModuleTable;
     596    Proxy.Properties.Add('Name', Name);
     597    Proxy.Properties.Add('Author', Author);
     598    Proxy.Properties.Add('Website', Website);
     599    Proxy.Properties.Add('Version', Version);
     600    Proxy.Properties.Add('Description', Description);
     601    Proxy.Properties.Add('License', License);
     602    Proxy.Save;
     603    Result := Proxy.Id;
     604  finally
     605    Proxy.Free;
    627606  end;
    628607end;
     
    630609procedure TChronisBase.LoadTypes;
    631610var
    632   DbRows: TDbRows;
     611  Proxy: TListProxy;
    633612  I: Integer;
    634613begin
    635614  try
    636     DbRows := TDbRows.Create;
     615    Proxy := TListProxy.Create;
     616    Proxy.Client := Client;
     617    Proxy.ObjectName := PropertyTypeTable;
     618    Proxy.Load;
    637619    Types.Clear;
    638     Database.Select(DbRows, PropertyTypeTable);
    639     for I := 0 to DbRows.Count - 1 do begin
     620    for I := 0 to Proxy.Objects.Count - 1 do begin
    640621      with TChronisType(Types.AddNew(TChronisType.Create)) do
    641       with DbRows[I] do begin
    642         Id := StrToInt(Values['Id']);
    643         DbType := Values['DbType'];
    644         //Parent := StrToInt(Values['Parent']);
     622      with TObjectProxy(Proxy.Objects[I]) do begin
     623        Id := StrToInt(Properties.Values['Id']);
     624        DbType := Properties.Values['DbType'];
     625        //Parent := StrToInt(Properties.Values['Parent']);
    645626      end;
    646627    end;
    647628  finally
    648     DbRows.Free;
     629    Proxy.Free;
    649630  end;
    650631end;
     
    652633function TChronisBase.IsDatabaseEmpty: Boolean;
    653634var
    654   DbRows: TDbRows;
    655 begin
    656   try
    657     DbRows := TDbRows.Create;
    658     Database.Query(DbRows, 'SELECT 1 FROM information_schema.tables WHERE table_name = "Information" AND table_schema = "' +
    659       Database.Database + '"');
    660     Result := DbRows.Count = 0;
    661   finally
    662     DbRows.Free;
     635  Proxy: TListProxy;
     636begin
     637  try
     638    Proxy := TListProxy.Create;
     639    Proxy.Client := Client;
     640    Proxy.SchemaName := 'information_schema';
     641    Proxy.ObjectName := 'tables';
     642    Proxy.Condition := 'table_name = "Information" AND table_schema = "' +
     643      Client.Schema + '"';
     644    Proxy.Load;
     645    Result := Proxy.Objects.Count = 0;
     646  finally
     647    Proxy.Free;
    663648  end;
    664649end;
     
    718703    List.Client := Core.System.Client;
    719704    List.ObjectName := ObjectTable;
    720     List.SchemaName := Core.System.Database.Database;
    721     List.SetCondition('Id', IntToStr(ObjectId));
     705    List.SchemaName := Core.System.Client.Schema;
     706    List.Condition := 'Id=' + IntToStr(ObjectId);
    722707    List.Load;
    723708    if List.Objects.Count = 1 then begin
Note: See TracChangeset for help on using the changeset viewer.