[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: GDL2 & Postgres defining a sequence differently?
From: |
Matt Rice |
Subject: |
Re: GDL2 & Postgres defining a sequence differently? |
Date: |
Sun, 21 Jun 2015 23:32:38 -0700 |
On Sun, Jun 21, 2015 at 8:11 AM, Edwin Ancaer <eancaer@gmail.com> wrote:
> Hello,
> is it possible that GDL2 names a sequence as <tablename_seq>, while
> postgresl names a sequence as <tablename_fieldname_seq>?
Hello,
Are you using +[EOSchemaGeneration
dropPrimaryKeySupportStatementsForEntityGroup:]
to generate the 'CREATE SEQUENCE' statement?
and if you do,
do the names then match the one the 'SELECT nextval' statement generated in
-[PostgreSQLChannel primaryKeyForNewRowWithEntity]
>
> Is there a way to influence the naming of the sequence in GDL2?
Yes, in the EOModel connection dictionary, here is an excerpt from
PostgreSQLAdaptor.h:
/* The following keys are meaningful in the connectionDictionary in a model:
...
primaryKeySequenceNameFormat - Format for pk sequence name; like
@"%@_SEQ" or @"EOSEQ_%@", "%@" is replaced by external table name
(default: @"%@_SEQ")
> Whith psql, I get
>
> psql (9.3.6)
> Type "help" for help.
>
> MultiDB=> \d
> List of relations
> Schema | Name | Type | Owner
> --------+----------------+----------+----------
> public | persons | table | postgres
> public | persons_id_seq | sequence | postgres
> (2 rows)
>
> MultiDB=>
>
> When adding a record to the table persons, with a sequence defined on the
> field 'id' I got the following error:
>
> 2015-06-21 16:37:18.150 Crud2[10423:10423] clicked to add an item in channel
> 2015-06-21 16:37:18.151 Crud2[10423:10423] EAN -- PostgreSQLAdaptor.m --
> createPGconn --localhost 5432 MultiDB edwin edwin
> 2015-06-21 16:37:18.233 Crud2[10423:10423] localhost 5432 MultiDB edwin
> edwin
> 2015-06-21 16:37:18.359 Crud2[10423:10423] File NSKeyValueCoding.m: 915. In
> -[NSObject(KeyValueCoding) valuesForKeys:] This method is deprecated, use
> -dictionaryWithValuesForKeys:
> 2015-06-21 16:37:18.360 Crud2[10423:10423] EAN -- PostgreSQLAdaptor.m --
> createPGconn --localhost 5432 MultiDB edwin edwin
> 2015-06-21 16:37:18.462 Crud2[10423:10423] localhost 5432 MultiDB edwin
> edwin
> 2015-06-21 16:37:18.471 Crud2[10423:10423] <NSException: 0xa456ec8>
> NAME:PostgreSQLException REASON:SQL expression 'SELECT
> nextval('persons_SEQ')' caused ERROR: relation "persons_seq" does not exist
> LINE 1: SELECT nextval('persons_SEQ')
> ^
> INFO:(null) (SQL expression 'SELECT nextval('persons_SEQ')' caused ERROR:
> relation "persons_seq" does not exist
> LINE 1: SELECT nextval('persons_SEQ')