Skip to content

Commit

Permalink
Merge pull request #362 from klee-contrib/gideruette/issue359
Browse files Browse the repository at this point in the history
[SQL] Mode "séquence", ajouter l'information "owned by"
  • Loading branch information
gideruette authored Jun 18, 2024
2 parents 3293bd8 + 81d690e commit 31f4df6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion TopModel.Generator.Sql/Procedural/AbstractSchemaGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ private IEnumerable<AssociationProperty> WriteTableDeclaration(Class classe, Sql
writerCrebas.WriteLine("/**");
writerCrebas.WriteLine($" * Création de la séquence pour la clé primaire de la table {tableName}");
writerCrebas.WriteLine(" **/");
writerCrebas.Write($"create sequence SEQ_{tableName}");
writerCrebas.Write($"create sequence SEQ_{tableName} as {_config.GetType(classe.PrimaryKey.Single()).ToUpper()}");

if (Config.Identity.Start != null)
{
Expand All @@ -516,6 +516,8 @@ private IEnumerable<AssociationProperty> WriteTableDeclaration(Class classe, Sql
writerCrebas.Write($"{$" increment {Config.Identity.Increment}"}");
}

writerCrebas.Write($" owned by {tableName}.{classe.PrimaryKey.Single().SqlName}");

writerCrebas.WriteLine(BatchSeparator);
}

Expand Down
4 changes: 2 additions & 2 deletions samples/generators/pg/src/01_tables.sql
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ create table DROIT (
/**
* Création de la séquence pour la clé primaire de la table PROFIL
**/
create sequence SEQ_PROFIL start 1000 increment 50;
create sequence SEQ_PROFIL as INT start 1000 increment 50 owned by PROFIL.PRO_ID;
/**
* Création de la table PROFIL
**/
Expand Down Expand Up @@ -62,7 +62,7 @@ create table TYPE_UTILISATEUR (
/**
* Création de la séquence pour la clé primaire de la table UTILISATEUR
**/
create sequence SEQ_UTILISATEUR start 1000 increment 50;
create sequence SEQ_UTILISATEUR as INT start 1000 increment 50 owned by UTILISATEUR.UTI_ID;
/**
* Création de la table UTILISATEUR
**/
Expand Down

0 comments on commit 31f4df6

Please sign in to comment.