Skip to content

Commit

Permalink
New model tag for ExternalTableName, can now differ from internal tab…
Browse files Browse the repository at this point in the history
…le name. #20
  • Loading branch information
bero committed Dec 7, 2024
1 parent b9a331f commit 0e66b32
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Source/BoldAbstractPartiallyExternalPC.pas
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ function TBoldAbstractPartiallyExternalPC.ExternalKeysToInternalSQL(
raise EBold.CreateFmt(sNotSupportedWithNoKeys, [classname, MoldClass.ExpandedExpressionName]);

result := format('%s.%s in (', [
BoldExpandName(ExternalKey.MoldClass.Tablename, ExternalKey.MoldClass.Name, xtSQL, -1, nccFalse),
BoldExpandName(ExternalKey.MoldClass.ExternalTableName, ExternalKey.MoldClass.Name, xtSQL, -1, nccFalse),
BoldExpandName(ExternalKey.ColumnName, ExternalKey.name, xtSQL, -1, nccFalse)]);
Mapping := TypeNameDictionary.MappingForModelName[ExternalKey.BoldType];
KeyIsString := assigned(Mapping) and SameText(Mapping.ExpandedContentsName, BoldContentName_String);
Expand Down
2 changes: 2 additions & 0 deletions Source/BoldDefaultTaggedValues.pas
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ interface
TAG_ROOTCLASS: String = 'RootClass';

TAG_TABLENAME: String = 'TableName';
TAG_EXTERNALTABLENAME: String = 'ExternalTableName';
TAG_TYPELIBVERSION = 'TypeLibVersion';

TAG_UNITNAME: String = 'UnitName';
Expand Down Expand Up @@ -214,6 +215,7 @@ procedure AddDefaultTaggedValues;
Add('String', TAG_CPPNAME, TV_NAME);
Add('String', TAG_EXPRESSIONNAME, TV_NAME);
Add('String', TAG_TABLENAME, TV_NAME);
Add('String', TAG_EXTERNALTABLENAME, TV_NAME);
Add('EvolutionStateEnum',
TAG_EVOLUTIONSTATE, TV_EVOLUTIONSTATE_NORMAL);
Add('String', TAG_PMAPPERNAME, DEFAULTNAMELITERAL);
Expand Down
2 changes: 1 addition & 1 deletion Source/BoldExternalPersistenceControllerSQL.pas
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ implementation

function _GetTableName(MoldClass: TMoldClass): String;
begin
Result := BoldExpandName(MoldClass.TableName, MoldClass.name, xtSQL, -1, nccFalse);
Result := BoldExpandName(MoldClass.ExternalTableName, MoldClass.name, xtSQL, -1, nccFalse);
end;

function _GetColumnName(BoldMember: TMoldMember): String;
Expand Down
7 changes: 7 additions & 0 deletions Source/BoldMeta.pas
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,7 @@ TMoldClass = class(TMoldElement)
function GetBoldUnitName: string;
function GetImported: Boolean;
function GetTableName: string;
function GetExternalTableName: string;
procedure SetBoldUnitName(const Value: string);
procedure SetIncFileName(const Value: string);
function GetDefaultStringRepresentation: String;
Expand Down Expand Up @@ -450,6 +451,7 @@ TMoldClass = class(TMoldElement)
function EffectiveIncFileName(const DefaultExtension: String): String;
property TableMapping: TTableMapping read GetTablemapping;
property TableName: string read GetTableName;
property ExternalTableName: string read GetExternalTableName;
property IsRootClass: Boolean read GetIsRootClass;
property SuperClass: TMoldClass read FSuperClass write SetSuperClass;
property SubClasses: TMoldClassList read FSubClasses;
Expand Down Expand Up @@ -2009,6 +2011,11 @@ function TMoldClass.GetTableName: string;
result := BoldTVByName[TAG_TABLENAME];
end;

function TMoldClass.GetExternalTableName: string;
begin
result := BoldTVByName[TAG_EXTERNALTABLENAME];
end;

procedure TMoldClass.SetBoldUnitName(const Value: string);
begin
BoldTVByName[TAG_UNITNAME] := Value;
Expand Down

0 comments on commit 0e66b32

Please sign in to comment.