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

Opened 12 years ago

Closed 12 years ago

#586 closed bug (fixed)

Bug creating sqlite record (autoincrement)

Reported by: maurice Owned by: laurentj
Priority: high Milestone: Jelix 1.0.4
Component: jelix:dao Version: 1.0.3
Severity: major Keywords:
Cc: Maurice.Diamantini@… Blocked By:
Blocking: Documentation needed: no
Hosting Provider: Php version: 5.2.5

Description

Testing the full tutorial with sqlite3 (pdo) instead of mySql doesn't work.

(php 5.2.5 with sqlite or 3.3.17 on osx (MAMP) or 3.3.6 (on linux)

At most one record can be inserted because Jelix try to add all records with the same uniq id ("id_news" field) with value 0 instead of the value (or string?) NULL which should be used for the autoincrement feature.

One can make a hacking correction by directly modifing the Jelix generated file

jelix-1.0.3-dev/temp/actu.org/compiled/daos/modules/news~news~sqlite.php

 // For autoincrementation feature value 0 should be replaced by
 // sqlite value NULL
 //
 public function insert ($record){
     if($record->id_news > 0 ){
         // ok... on utilise intval($record->id_news) : pas touché
     } else {
         // il faudrait remplacer ici :
         .intval($record->id_news)
         //  par :
         .'NULL'
     }
 }

For testing the tutorial with sqlite, I use the following dbprofiles.ini.php config.

       default = actu.org.sqlite
  
       [actu.org.mysql]
       
       driver="mysql"
       database="actu"
       host= "localhost"
       user= "root"
       password="root"
       persistent= off
       force_encoding = off
       
       [actu.org.sqlite]
       
       driver=pdo
       ; TODO : one should be able to build the absolute path instead of wiring it!
       ;dsn=sqlite:var/data/actu.org.sqlite3
       dsn=sqlite:/home/.../.../var/data/actu.org.sqlite3

and the following sql for sqlite3 base initialisation :

       -- sqlite3 var/data/actu.org.sqlite3 \
       --            < init_actu_news_table-sqlite3.sql
       DROP table if exists `news`;
       
       CREATE TABLE news (
           id_news  INTEGER PRIMARY KEY,
           sujet varchar(255) not null ,
           texte text not null ,
           news_date date not null 
       );   
       
       INSERT INTO news VALUES (
           NULL, 
           'première news', 
           'Ceci est une première news. In commodo ... end.', 
           '2006-01-15'
       );
        
       INSERT INTO news VALUES (
           NULL, 
           'Lorem Ipsum', 
           'Lorem ipsum dolor sit amet, consectetuer adipiscing elit.', 
           '0007-10-10'
       );

(database and it's directory should be world writable for testing)

-- Maurice

Change History (5)

comment:1 Changed 12 years ago by maurice

  • Cc Maurice.Diamantini@… added
  • Priority changed from normal to high

comment:2 Changed 12 years ago by laurentj

  • Component changed from jelix to jelix:dao
  • Milestone set to Jelix 1.0.4

comment:3 Changed 12 years ago by laurentj

  • Owner set to laurentj
  • Status changed from new to assigned

In fact, this bug was already fixed by Bballizlife on the trunk (svn 872) and backported by me on the 1.0.x branch (svn 894).

Could you download a nightly build of jelix 1.0.4, and could you verify that your bug doesn't exists anymore ? Thanks.

comment:4 Changed 12 years ago by maurice

The original bug doesn't exists anymore, thank you very much. You can close this ticket

comment:5 Changed 12 years ago by laurentj

  • Resolution set to fixed
  • Status changed from assigned to closed

Thank you.

Note: See TracTickets for help on using tickets.