Changeset 375
- Timestamp:
- 03/01/07 11:30:06 (2 years ago)
- Files:
-
- trunk/lib/jelix-modules/jelix/locales/en_EN/dao.ISO-8859-1.properties (modified) (1 diff)
- trunk/lib/jelix-modules/jelix/locales/en_EN/dao.UTF-8.properties (modified) (1 diff)
- trunk/lib/jelix-modules/jelix/locales/en_EN/daoxml.ISO-8859-1.properties (modified) (1 diff)
- trunk/lib/jelix-modules/jelix/locales/en_EN/daoxml.UTF-8.properties (modified) (1 diff)
- trunk/lib/jelix-modules/jelix/locales/en_US/dao.ISO-8859-1.properties (modified) (1 diff)
- trunk/lib/jelix-modules/jelix/locales/en_US/dao.UTF-8.properties (modified) (1 diff)
- trunk/lib/jelix-modules/jelix/locales/en_US/daoxml.ISO-8859-1.properties (modified) (1 diff)
- trunk/lib/jelix-modules/jelix/locales/en_US/daoxml.UTF-8.properties (modified) (1 diff)
- trunk/lib/jelix-modules/jelix/locales/fr_FR/dao.ISO-8859-1.properties (modified) (1 diff)
- trunk/lib/jelix-modules/jelix/locales/fr_FR/dao.UTF-8.properties (modified) (1 diff)
- trunk/lib/jelix-modules/jelix/locales/fr_FR/daoxml.ISO-8859-1.properties (modified) (1 diff)
- trunk/lib/jelix-modules/jelix/locales/fr_FR/daoxml.UTF-8.properties (modified) (2 diffs)
- trunk/lib/jelix/core/jConfigCompiler.class.php (modified) (2 diffs)
- trunk/lib/jelix/dao/jDaoGenerator.class.php (modified) (1 diff)
- trunk/lib/jelix/dao/jDaoParser.class.php (modified) (3 diffs)
- trunk/lib/jelix/utils/jDatatype.class.php (modified) (1 diff)
- trunk/testapp/modules/unittest/classes/utdao2.class.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/lib/jelix-modules/jelix/locales/en_EN/dao.ISO-8859-1.properties
r354 r375 6 6 7 7 error.keys.missing=(501) Identifier is missing 8 error.update.impossible=(502)Update is impossible with this dao because table contains only primary keys (DAO: %1$s, file: %2$s) trunk/lib/jelix-modules/jelix/locales/en_EN/dao.UTF-8.properties
r354 r375 6 6 7 7 error.keys.missing=(501) Identifier is missing 8 error.update.impossible=(502)Update is impossible with this dao because table contains only primary keys (DAO: %1$s, file: %2$s) trunk/lib/jelix-modules/jelix/locales/en_EN/daoxml.ISO-8859-1.properties
r364 r375 46 46 method.condition.driver.notallowed= (561)DAO %1$s, method %3$, the driver of the database used here is not allowed accordind to the definition of the condition (file %2$s) 47 47 method.orderitem.parameter.unknow= (563)DAO %1$s, method %3$, unknow parameter %4$s in the orderitem tag (file %2$s) 48 method.update.forbidden= (564)DAO %1$s, update method %3$s is forbidden because the main table contains only primary keys (file %2$s) trunk/lib/jelix-modules/jelix/locales/en_EN/daoxml.UTF-8.properties
r364 r375 46 46 method.condition.driver.notallowed= (561)DAO %1$s, method %3$, the driver of the database used here is not allowed accordind to the definition of the condition (file %2$s) 47 47 method.orderitem.parameter.unknow= (563)DAO %1$s, method %3$, unknow parameter %4$s in the orderitem tag (file %2$s) 48 method.update.forbidden= (564)DAO %1$s, update method %3$s is forbidden because the main table contains only primary keys (file %2$s) trunk/lib/jelix-modules/jelix/locales/en_US/dao.ISO-8859-1.properties
r23 r375 6 6 7 7 error.keys.missing=(501) Identifier is missing 8 error.update.impossible=(502)Update is impossible with this dao because table contains only primary keys (DAO: %1$s, file: %2$s) trunk/lib/jelix-modules/jelix/locales/en_US/dao.UTF-8.properties
r354 r375 6 6 7 7 error.keys.missing=(501) Identifier is missing 8 error.update.impossible=(502)Update is impossible with this dao because table contains only primary keys (DAO: %1$s, file: %2$s) trunk/lib/jelix-modules/jelix/locales/en_US/daoxml.ISO-8859-1.properties
r364 r375 46 46 method.condition.driver.notallowed= (561)DAO %1$s, method %3$, the driver of the database used here is not allowed accordind to the definition of the condition (file %2$s) 47 47 method.orderitem.parameter.unknow= (563)DAO %1$s, method %3$, unknow parameter %4$s in the orderitem tag (file %2$s) 48 method.update.forbidden= (564)DAO %1$s, update method %3$s is forbidden because the main table contains only primary keys (file %2$s) trunk/lib/jelix-modules/jelix/locales/en_US/daoxml.UTF-8.properties
r364 r375 46 46 method.condition.driver.notallowed= (561)DAO %1$s, method %3$, the driver of the database used here is not allowed accordind to the definition of the condition (file %2$s) 47 47 method.orderitem.parameter.unknow= (563)DAO %1$s, method %3$, unknow parameter %4$s in the orderitem tag (file %2$s) 48 method.update.forbidden= (564)DAO %1$s, update method %3$s is forbidden because the main table contains only primary keys (file %2$s) trunk/lib/jelix-modules/jelix/locales/fr_FR/dao.ISO-8859-1.properties
r23 r375 6 6 7 7 error.keys.missing=(501)Identifiant(s) manquant(s) 8 error.update.impossible=(502)Update impossible sur une table ne contenant que des cl�primaires (DAO %1$s, fichier %2$s) 8 9 trunk/lib/jelix-modules/jelix/locales/fr_FR/dao.UTF-8.properties
r112 r375 6 6 7 7 error.keys.missing=(501)Identifiant(s) manquant(s) 8 8 error.update.impossible=(502)Update impossible sur une table ne contenant que des clés primaires (DAO %1$s, fichier %2$s) trunk/lib/jelix-modules/jelix/locales/fr_FR/daoxml.ISO-8859-1.properties
r364 r375 46 46 method.condition.driver.notallowed= (561)DAO %1$s, m�ode %3$, le driver de base de donn� utilis�'est pas autoris�'apr�la d�nition de la condition (fichier %2$s) 47 47 method.orderitem.parameter.unknow= (563)DAO %1$s, nom de param�e %4$s inconnu dans la balise orderitem de la m�ode %3$s (fichier %2$s) 48 49 method.update.forbidden= (564)DAO %1$s, la m�ode %3$s de type update est interdite car la table principale ne contient que des cl�primaires (fichier %2$s) trunk/lib/jelix-modules/jelix/locales/fr_FR/daoxml.UTF-8.properties
r364 r375 28 28 method.duplicate= (545)DAO %1$s, la méthode %3$s est déjà définie (fichier %2$s) 29 29 30 31 30 method.condition.unknown= (546)DAO %1$s, méthode %3$s, la condition %4$s n'est pas reconnu (fichier %2$s) 32 31 method.property.unknown= (547)DAO %1$s, la méthode %3$s utilise une propriété (%4$s) qui n'existe pas dans la DAO (fichier %2$s) … … 46 45 method.condition.driver.notallowed= (561)DAO %1$s, méthode %3$, le driver de base de données utilisé n'est pas autorisé d'après la définition de la condition (fichier %2$s) 47 46 method.orderitem.parameter.unknow= (563)DAO %1$s, nom de paramètre %4$s inconnu dans la balise orderitem de la méthode %3$s (fichier %2$s) 47 method.update.forbidden= (564)DAO %1$s, la méthode %3$s de type update est interdite car la table principale ne contient que des clés primaires (fichier %2$s) trunk/lib/jelix/core/jConfigCompiler.class.php
r367 r375 158 158 exit; 159 159 } 160 if(substr($p,-1) !='/') 161 $p.='/'; 160 162 $allBasePath[]=$p; 161 163 if ($handle = opendir($p)) { … … 188 190 exit; 189 191 } 192 if(substr($p,-1) !='/') 193 $p.='/'; 190 194 #if ENABLE_PHP_JELIX 191 195 $config->_allBasePath[]=$p; trunk/lib/jelix/dao/jDaoGenerator.class.php
r368 r375 185 185 186 186 $src[] = 'public function update ($record){'; 187 $src[] = ' $query = \'UPDATE '.$pTableRealName.' SET ';188 189 187 list($fields, $values) = $this->_prepareValues($this->_getPropertiesBy('PrimaryFieldsExcludePk'),'updateMotif', 'record->'); 190 191 $sqlSet=''; 192 foreach($fields as $k=> $fname){ 193 $sqlSet.= ', '.$fname. '= '. $values[$k]; 194 } 195 $src[] = substr($sqlSet,1); 196 197 $sqlCondition = $this->_buildSimpleConditions($pkFields, 'record->', false); 198 if($sqlCondition!='') 199 $src[] = ' where '.$sqlCondition; 200 201 $src[] = "';"; 202 $src[] = ' return $this->_conn->exec ($query);'; 203 $src[] = " }";//ends the update function 204 205 188 if(count($fields)){ 189 $src[] = ' $query = \'UPDATE '.$pTableRealName.' SET '; 190 $sqlSet=''; 191 foreach($fields as $k=> $fname){ 192 $sqlSet.= ', '.$fname. '= '. $values[$k]; 193 } 194 $src[] = substr($sqlSet,1); 195 196 $sqlCondition = $this->_buildSimpleConditions($pkFields, 'record->', false); 197 if($sqlCondition!='') 198 $src[] = ' where '.$sqlCondition; 199 200 $src[] = "';"; 201 $src[] = ' return $this->_conn->exec ($query);'; 202 $src[] = " }";//ends the update function 203 }else{ 204 //the dao is mapped on a table which contains only primary key : update is impossible 205 // so we will generate an error on update 206 $src[] = " throw new jException('jelix~dao.error.update.impossible',array('".jDaoCompiler::$daoId."','".jDaoCompiler::$daoPath."'));"; 207 $src[] = " }"; 208 } 206 209 //----- other user methods 207 210 trunk/lib/jelix/dao/jDaoParser.class.php
r364 r375 63 63 private $_methods = array(); 64 64 65 public $hasOnlyPrimaryKeys = false; 65 66 /** 66 67 * Constructor … … 93 94 94 95 if($debug == 2) return; 95 96 $countprop = 0; 96 97 //add the record properties 97 98 if(isset($xml->record) && isset($xml->record[0]->property)){ 98 99 foreach ($xml->record[0]->property as $prop){ 99 $p = new jDaoProperty ($prop->attributes(), $this); 100 $this->_properties[$p->name] = $p; 101 $this->_tables[$p->table]['fields'][] = $p->name; 102 } 100 $p = new jDaoProperty ($prop->attributes(), $this); 101 $this->_properties[$p->name] = $p; 102 $this->_tables[$p->table]['fields'][] = $p->name; 103 if(($p->table == $this->_primaryTable) && !$p->isPK) 104 $countprop ++; 105 } 106 $this->hasOnlyPrimaryKeys = ($countprop == 0); 103 107 }else 104 108 throw new jDaoXmlException ('properties.missing'); … … 401 405 402 406 if($this->type == 'update'){ 407 if($this->_def->hasOnlyPrimaryKeys) 408 throw new jDaoXmlException ('method.update.forbidden',array($this->name)); 409 403 410 if(isset($method->values) && isset($method->values[0]->value)){ 404 411 foreach ($method->values[0]->value as $val){ trunk/lib/jelix/utils/jDatatype.class.php
r335 r375 281 281 * @experimental 282 282 */ 283 class jDatatype Mail extends jDatatype {283 class jDatatypeEmail extends jDatatype { 284 284 public function check($value){ 285 285 return jFilter::isEmail($value); trunk/testapp/modules/unittest/classes/utdao2.class.php
r276 r375 335 335 } 336 336 337 337 function testBadUpdateMethod() { 338 $dao ='<?xml version="1.0"?> 339 <dao xmlns="http://jelix.org/ns/dao/1.0"> 340 <datasources> 341 <primarytable name="news" primarykey="news_id,foo_id" /> 342 </datasources> 343 <record> 344 <property name="id" fieldname="news_id" datatype="autoincrement" /> 345 <property name="id2" fieldname="foo_id" datatype="integer" /> 346 </record> 347 </dao>'; 348 349 $parser = new jDaoParser(); 350 $parser->parse(simplexml_load_string($dao),1); 351 352 $this->sendMessage("test bad update method "); 353 $xml= simplexml_load_string('<?xml version="1.0"?> 354 <method name="tryupdate" type="update"> 355 <parameter name="something" /> 356 <values> 357 <value property="foo_id" expr="$something" /> 358 </values> 359 </method>'); 360 361 try{ 362 $p = new jDaoMethod($xml, $parser); 363 $this->fail("Pas d'exception survenue !"); 364 }catch(jDaoXmlException $e){ 365 $this->assertEqual($e->getMessage(), 'jelix~daoxml.method.update.forbidden'); 366 $this->assertEqual($e->localeParams, array('','','tryupdate')); 367 }catch(Exception $e){ 368 $this->fail("Exception inconnue : ".$e->getMessage()); 369 } 370 } 338 371 } 339 372
