is not used any more and exists only for history. Post new tickets on the Github account. n'est plus utilisée, et existe uniquement pour son historique. Postez les nouveaux tickets sur le compte github.

Opened 8 years ago

Last modified 8 years ago

#1516 confirmed enhancement

Jelix and PostgreSQL : createdao should be able to guess the sequence

Reported by: yan_vn Owned by:
Priority: normal Milestone:
Component: jelix-scripts Version: 1.5.2
Severity: normal Keywords: PostgreSQL, CRUD, sequence
Cc: Blocked By:
Blocking: Documentation needed: no
Hosting Provider: Php version: 5.4


In PostgreSQL 8.4, I created the following table :

CREATE TABLE costa_contests
  contest_id serial NOT NULL,
  usr_login character varying(50) NOT NULL,
  contest_name character varying(50) NOT NULL,
  CONSTRAINT contests_pkey PRIMARY KEY (contest_id),
  CONSTRAINT contests_usr_login_fkey FOREIGN KEY (usr_login)
      REFERENCES costa_jlx_user (usr_login) MATCH SIMPLE
  CONSTRAINT costa_contests_usr_login_key UNIQUE (usr_login, contest_name)

PostgreSQL automatically create the following sequence :

CREATE SEQUENCE costa_contests_contest_id_seq
  MAXVALUE 9223372036854775807
  CACHE 1;

With the CRUD controller in Jelix, when creating a new record and submitting it, Jelix produces the following error (returned by the Debug bar) :

invalid query (ERROR: relation "contests_contest_id_seq" does not exist
Code: 403
File: /Users/yan/Sites/jelix/lib-1.5.2/jelix/plugins/db/pgsql/pgsql.dbconnection.php 154
0	pgsqlDbConnection->_doQuery()	lib:jelix/db/jDbConnection.class.php	115
1	jDbConnection->query()	lib:jelix/plugins/db/pgsql/pgsql.dbconnection.php	181
2	pgsqlDbConnection->lastInsertId()	temp:compiled/daos/modules/logs~contests~pgsql_15.php	150
3	cDao_logs_Jx_contests_Jx_pgsql->insert()	lib:jelix/controllers/jControllerDaoCrud.class.php	326
4	jControllerDaoCrud->savecreate()	lib:jelix/core/jCoordinator.class.php	207
5	jCoordinator->process()	app:www/index.php	19

The record is actually correctly created in the database as it should be. Viewing, modifying and deleting records work correctly.

Change History (3)

comment:1 Changed 8 years ago by laurentj

  • Component changed from jelix to jelix:db
  • Milestone set to Jelix 1.5.3
  • Status changed from new to confirmed

comment:2 Changed 8 years ago by yan_vn

Well, in fact the online documentation covers it. On the jDAO pages, it specifies that for PosgreSQL you have to manually provide the sequence name. Once added to the <property> element in the XML file, things worked flawlessly.

I don't know if I should close the ticket or if it is justified to spend time on this matter... The truth is that sequences being automatically generated by PGSQL, that should be easy and user-friendly to handle it automatically in jelix "createdao" script...


comment:3 Changed 8 years ago by laurentj

  • Component changed from jelix:db to jelix-scripts
  • Milestone Jelix 1.5.3 deleted
  • Summary changed from Jelix and PostgreSQL : CRUD controller not adding table prefix when calling a sequence to Jelix and PostgreSQL : createdao should be able to guess the sequence
  • Type changed from bug to enhancement
Note: See TracTickets for help on using tickets.