From 81d690e8521aa68038f658388e0092a868982084 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gild=C3=A9ric=20DERUETTE?= Date: Tue, 18 Jun 2024 10:34:00 +0200 Subject: [PATCH] =?UTF-8?q?[SQL]=20Mode=20"s=C3=A9quence",=20ajouter=20l'i?= =?UTF-8?q?nformation=20"owned=20by"=20Fixes=20#359?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TopModel.Generator.Sql/Procedural/AbstractSchemaGenerator.cs | 4 +++- samples/generators/pg/src/01_tables.sql | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/TopModel.Generator.Sql/Procedural/AbstractSchemaGenerator.cs b/TopModel.Generator.Sql/Procedural/AbstractSchemaGenerator.cs index fb43cb3a..43a9a6fa 100644 --- a/TopModel.Generator.Sql/Procedural/AbstractSchemaGenerator.cs +++ b/TopModel.Generator.Sql/Procedural/AbstractSchemaGenerator.cs @@ -504,7 +504,7 @@ private IEnumerable 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) { @@ -516,6 +516,8 @@ private IEnumerable WriteTableDeclaration(Class classe, Sql writerCrebas.Write($"{$" increment {Config.Identity.Increment}"}"); } + writerCrebas.Write($" owned by {tableName}.{classe.PrimaryKey.Single().SqlName}"); + writerCrebas.WriteLine(BatchSeparator); } diff --git a/samples/generators/pg/src/01_tables.sql b/samples/generators/pg/src/01_tables.sql index 600b1e93..5c449a72 100644 --- a/samples/generators/pg/src/01_tables.sql +++ b/samples/generators/pg/src/01_tables.sql @@ -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 **/ @@ -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 **/