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 13 years ago

Closed 13 years ago

#228 closed bug (fixed)

Problème de DAO dans un select d'un champ entier mis à NULL

Reported by: Torgan Owned by:
Priority: normal Milestone: Jelix 1.0beta3
Component: jelix:dao Version: 1.0 beta2.1
Severity: major Keywords:
Cc: Blocked By:
Blocking: Documentation needed:
Hosting Provider: Php version:

Description

J'ai une DAO avec la chose suivante

<dao xmlns="http://jelix.org/ns/dao/1.0">
  <datasources>
    <primarytable name="_directory" primarykey="id" />
  </datasources>
        
  <record>
        <property 
                name="id" 
                fieldname="id" 
                required="false"
                datatype="autoincrement" 
                sequence="ob2media._directory_id_seq" />
        <property 
                name="parent_dir_id" 
                fieldname="parent_dir_id" 
                required="false"
                datatype="int" />
        <property 
                name="name" 
                fieldname="name" 
                datatype="string"   
                required="true" />
  </record>
        
  <factory>

                <method type="selectFirst" name="findFromParentAndName">
                  <parameter name="parent_id" />
                  <parameter name="name" />
                  <conditions>
                        <eq property="parent_dir_id" expr="$parent_id" />
                        <eq property="name" expr="$name" />
                  </conditions>
                </method>

        </factory>
</dao>

En fait tout se passe bien sauf dans le cas ou j'utilise la méthode findFromParentAndName en passant null comme parametre pour parent_id. La méthode devrait mettre un "IS NULL" en lieu de test puisque le champ peut etre null (cf la définition). Hors, on retrouve un intval dans le code généré, ce qui fait que la requete recherche un parent_id = 0.

Code généré :

 function findFromParentAndName ($parent_id, $name){
    $__query =  $this->_selectClause.$this->_fromClause.$this->_whereClause;
$__query .=' WHERE  ob2media._directory.parent_dir_id = '.intval($parent_id).' AND _directory.name = '.$this->_conn->quote($name).'';
print $__query;
    $__rs = $this->_conn->limitQuery($__query,0,1);
    $__rs->setFetchMode(8,'cDaoRecord_media_Jx__directory_Jx_postgresql');
    return $__rs->fetch();
}

Change History (2)

comment:1 Changed 13 years ago by laurentj

  • Component changed from jelix to jelix:dao
  • Milestone set to Jelix 1.0beta3

comment:2 Changed 13 years ago by laurentj

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

Corrigé dans le trunk.

Note: See TracTickets for help on using tickets.