Skip to content

Commit

Permalink
[tmdgen db] classNameOverrides
Browse files Browse the repository at this point in the history
  • Loading branch information
JabX committed Dec 20, 2024
1 parent 75ba587 commit e5cb2ec
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
10 changes: 9 additions & 1 deletion TopModel.Core/schema.tmdgen.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,14 @@
"description": "Tag à ajouter aux fichiers générés"
}
},
"classNameOverrides": {
"type": "object",
"description": "Surcharge de nom de classes à générer. N'a pas d'impact sur le nom SQL de la classe.",
"additionalProperties": {
"type": "string",
"description": "Surcharge à utiliser."
}
},
"modules": {
"type": "array",
"description": "Liste des modules et des classes qui devront en faire partie",
Expand Down Expand Up @@ -157,7 +165,7 @@
"type": "object",
"description": "Informations de connexion à la base de données",
"additionalProperties": false,
"required": ["dbType"],
"required": [ "dbType" ],
"properties": {
"host": {
"type": "string",
Expand Down
5 changes: 5 additions & 0 deletions TopModel.ModelGenerator/Database/DatabaseTmdGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,11 @@ private void InitClasses(IEnumerable<IGrouping<string, DbColumn>> classGroups)
className = group.Key;
}

if (_config.ClassNameOverrides.TryGetValue(className, out var classNameOverride))
{
className = classNameOverride;
}

_classes.Add(group.Key, new TmdClass() { Name = className, SqlName = group.Key });
}
}
Expand Down
2 changes: 2 additions & 0 deletions TopModel.ModelGenerator/Database/config/DatabaseConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ public class DatabaseConfig

public List<string> ExtractValues { get; set; } = [];

public Dictionary<string, string> ClassNameOverrides { get; set; } = [];

public List<ModuleConfig> Modules { get; set; } = [];

public string ConnectionString => Source.DbType switch
Expand Down

0 comments on commit e5cb2ec

Please sign in to comment.