Skip to content
This repository has been archived by the owner on Feb 27, 2024. It is now read-only.

Improved support for InterBase 7.5.1 and SQL Dialect 1 #15

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 19 additions & 8 deletions source/uibmetadata.pas
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ TMetaNode = class(TObject)
procedure RegisterDependedOn(OtherNode: TMetaNode);
function GetNodes(const Index: Integer): TNodeItem;
function GetDatabase: TMetaDatabase;
function MetaQuote(const str: string): string;
function MetaQuote(const str: string): string;
property Name: string read GetName;
property AsDDL: string read GetAsDDL;
property AsDDLNode: string read GetAsDDLNode;
Expand Down Expand Up @@ -658,6 +658,7 @@ TMetaDataBase = class(TMetaNode)
FOIDUDFs: TOIDUDFs;
FOIDRoles: TOIDRoles;
FSysInfos: Boolean;
FSQLDialect: Integer;
FDefaultCharset: TCharacterSet;

FSortedTables: TList;
Expand Down Expand Up @@ -1152,7 +1153,8 @@ implementation
' RDB$FIELDS FLD ' +
'left outer join RDB$COLLATIONS COL on (COL.RDB$CHARACTER_SET_ID = FLD.RDB$CHARACTER_SET_ID and COL.RDB$COLLATION_ID = FLD.RDB$COLLATION_ID) ' +
'where ' +
' not (FLD.RDB$FIELD_NAME starting with ''RDB$'')';
' (FLD.RDB$SYSTEM_FLAG <> 1 or FLD.RDB$SYSTEM_FLAG is null) and' +
' (not FLD.RDB$FIELD_NAME starting with ''RDB$'')';

QRYSysDomains =
'select ' +
Expand Down Expand Up @@ -1523,8 +1525,11 @@ function TMetaNode.GetNodes(const Index: Integer): TNodeItem;

function TMetaNode.MetaQuote(const str: string): string;
begin
if (GetDatabase.FIdentifiers.Search(PChar(str)) <> nil) then
Result := '"' + str + '"' else
if GetDatabase.FSQLDialect < 3 then
Result := str
else if (GetDatabase.FIdentifiers.Search(PChar(str)) <> nil) then
Result := '"' + str + '"'
else
Result := SQLQuote(str);
end;

Expand Down Expand Up @@ -2525,6 +2530,7 @@ constructor TMetaDataBase.Create(AOwner: TMetaNode; ClassIndex: Integer);
FOIDUDFs := ALLUDFs;
FOIDRoles := ALLRoles;
FSysInfos := False;
FSQLDialect := 3;
FDefaultCharset := csNONE;

FSortedTables := TList.Create;
Expand Down Expand Up @@ -2616,6 +2622,7 @@ procedure TMetaDataBase.LoadFromDatabase(Transaction: TUIBTransaction);
CheckTransaction(Transaction);

FName := Transaction.DataBase.DatabaseName;
FSQLDialect := Transaction.DataBase.SQLDialect;

Configure(QNames, '');
if FSysInfos then
Expand Down Expand Up @@ -3463,14 +3470,15 @@ procedure TMetaUnique.SaveToDDL(Stream: TStringStream; options: TDDLOptions);
end;
Stream.WriteString(')');

// fb15up
{$IFDEF FB15_UP}
if not ((FIndexName = '') or (not (ddlFull in options) and (Copy(FIndexName, 1, 4) = 'RDB$'))) then
begin
Stream.WriteString(NewLine + ' USING');
if FOrder = ioDescending then
Stream.WriteString(' DESC');
Stream.WriteString(' INDEX ' + FIndexName);
end;
{$ENDIF}

Stream.WriteString(';');
end;
Expand Down Expand Up @@ -3543,14 +3551,16 @@ procedure TMetaPrimary.SaveToDDLNode(Stream: TStringStream; options: TDDLOptions
end;
Stream.WriteString(')');

// fb15up
{$IFDEF FB15_UP}
if not ((FIndexName = '') or (not (ddlFull in options) and (Copy(FIndexName, 1, 4) = 'RDB$'))) then
begin
Stream.WriteString(NewLine + ' USING');
if FOrder = ioDescending then
Stream.WriteString(' DESC');
Stream.WriteString(' INDEX ' + FIndexName);
end;
{$ENDIF}

Stream.WriteString(';');
end;

Expand Down Expand Up @@ -3728,14 +3738,15 @@ procedure TMetaForeign.SaveToDDLNode(Stream: TStringStream; options: TDDLOptions
urSetDefault: Stream.WriteString(NewLine + ' ON UPDATE SET DEFAULT');
end;

// fb15up
{$IFDEF FB15_UP}
if not ((FIndexName = '') or (not (ddlFull in options) and (Copy(FIndexName, 1, 4) = 'RDB$'))) then
begin
Stream.WriteString(NewLine + ' USING');
if FOrder = ioDescending then
Stream.WriteString(' DESC');
Stream.WriteString(' INDEX ' + FIndexName);
end;
{$ENDIF}

Stream.WriteString(';');
end;
Expand Down Expand Up @@ -5072,7 +5083,7 @@ class function TMetaRoleGrant.NodeType: TMetaNodeType;
procedure TMetaRoleGrant.SaveToDDLNode(Stream: TStringStream; options: TDDLOptions);
begin
inherited SaveToDDLNode(Stream, options);
Stream.WriteString('"' + FName + '" TO ');
Stream.WriteString(MetaQuote(FName) + ' TO ');
inherited SaveGranteesToDDLNode(Stream, 'ADMIN', options);
end;

Expand Down