Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SQL] Mode "séquence", ajouter l'information "owned by" #362

Merged
merged 1 commit into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
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
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
Loading