Browse Source

Fix incorrect field type detection

Reinier Olislagers 11 năm trước cách đây
mục cha
commit
fb0bd17339
3 tập tin đã thay đổi với 19 bổ sung4 xóa
  1. 1 1
      comparison.lfm
  2. 4 0
      main.pas
  3. 14 3
      systables.pas

+ 1 - 1
comparison.lfm

@@ -63,7 +63,7 @@ object fmComparison: TfmComparison
     ParentFont = False
   end
   object bbStart: TBitBtn
-    Left = 568
+    Left = 542
     Height = 30
     Top = 288
     Width = 154

+ 4 - 0
main.pas

@@ -2487,6 +2487,10 @@ begin
   SetConnection(DatabaseIndex);
   FSQLTransaction.Commit;
   SQLQuery1.SQL.Text:= format(QueryTemplate,[ATableName]);
+  {$IFDEF NEVER}
+  // Left for debugging
+  SendDebug('GetFields: '+SQLQuery1.SQL.Text);
+  {$ENDIF}
   SQLQuery1.Open;
   // Fill field list if needed
   if FieldsList <> nil then

+ 14 - 3
systables.pas

@@ -646,20 +646,31 @@ procedure TdmSysTables.GetDomainInfo(dbIndex: Integer; DomainName: string; var D
 const
   // Select domain and associated collation (if text type domain)
   // note weird double join fields required...
+  //
   QueryTemplate= 'select f.*, '+
     'coll.rdb$collation_name, '+
     'cs.rdb$character_set_name '+
     'from rdb$fields as f '+
-    'left join rdb$collations as coll on '+
-    'f.rdb$collation_id=coll.rdb$collation_id and '+
-    'f.rdb$character_set_id=coll.rdb$character_set_id '+
+    'left join '+
+    { the entire inner join in the next part is treated as one entity that
+    is left outer joined. Result: you get collation info with associated
+    character set or just NULL }
+    '( '+
+    'rdb$collations as coll '+
     'inner join rdb$character_sets as cs on '+
     'coll.rdb$character_set_id=cs.rdb$character_set_id '+
+    ') '+
+    'on f.rdb$collation_id=coll.rdb$collation_id and '+
+    'f.rdb$character_set_id=coll.rdb$character_set_id '+
     'where f.rdb$field_name=''%s'' ';
 begin
   Init(dbIndex);
   sqQuery.Close;
   sqQuery.SQL.Text:= format(QueryTemplate, [UpperCase(DomainName)]);
+  {$IFDEF NEVER}
+  // Left for debugging
+  SendDebug(sqQuery.SQL.Text);
+  {$ENDIF}
   sqQuery.Open;
 
   if sqQuery.RecordCount > 0 then