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

Closed 9 years ago

Last modified 9 years ago

#838 closed bug (fixed)

jDao conditions: field names should be enclosed in some db engines

Reported by: Julien Owned by: Julien
Priority: high Milestone: Jelix 1.1.1
Component: jelix:dao Version: trunk
Severity: major Keywords:
Cc: Blocked By:
Blocking: Documentation needed: no
Hosting Provider: Php version:

Description

In a table, I wanted to use a field named "order", but I had errors when using it in jDaoConditions.

So in some db engines, we need to escape those field names, like the way they are with generated dao methods with jDaoGenerator.

So I propose a new method: jDbConnection::encloseFieldName($fieldName) to deal with this.

Attachments (2)

838-jDaoConditions-enclose-field-names.diff (14.4 KB) - added by Julien 9 years ago.
838-jDaoConditions-enclose-field-names-followup.diff (3.3 KB) - added by Julien 9 years ago.

Download all attachments as: .zip

Change History (11)

Changed 9 years ago by Julien

comment:1 Changed 9 years ago by Julien

  • Status changed from new to assigned

Please note: lib/jelix/plugins/db/mysql/mysql.dbconnection.php seems to have lots of change, but that's because indentation was not correct (3 spaces instead of 4).

The only thing that is new is:

/**
 * enclose the field name
 * @param string $fieldName the field name
 * @return string the enclosed field name
 * @since 1.1
 */
public function encloseFieldName($fieldName){
    return '`'.$fieldName.'`';
}

comment:2 follow-up: Changed 9 years ago by laurentj

  • review changed from review? to review+

bad version in @since tags : it is 1.1.1, not 1.1

comment:3 in reply to: ↑ 2 Changed 9 years ago by Julien

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

Replying to laurentj:

bad version in @since tags : it is 1.1.1, not 1.1

oops, changed this ;)

committed in the trunk and 1.1.x, r1315

should I do something similar in 1.0.x ?

comment:4 Changed 9 years ago by thomas

  • Resolution fixed deleted
  • Status changed from closed to reopened

Il faut rajouter la méthode encloseFieldName dans la classe jDbPDOConnection aussi.

comment:5 Changed 9 years ago by Julien

ok, done it, works fine. I'm also writing unit tests, then submit a patch

comment:6 Changed 9 years ago by Julien

  • review changed from review+ to review?

here it is

comment:7 Changed 9 years ago by laurentj

  • review changed from review? to review+

ok

comment:8 Changed 9 years ago by Julien

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

committed in the trunk and 1.1.x, r1338

comment:9 Changed 9 years ago by laurentj

I just renamed the method to encloseName, because it can be use to enclose table name too. r1340

Note: See TracTickets for help on using tickets.