using "search" orm method querying uppercase columns, produces PostgreSQL error "column TABLE.COLUMN does not exist"

Bug #600964 reported by Lorenzo Battistini
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Odoo Server (MOVED TO GITHUB)
Fix Released
Wishlist
OpenERP's Framework R&D

Bug Description

Using upper case field name causes PostgreSQL error while searching it.

For instance, if you create a new object "custom.object" with an integer field "FIELD" and try searching it with
self.pool.get('custom.object').search(cr, uid, [('FIELD', '=', 1)])
PostgreSQL will tell "ERROR: column custom_object.field does not exist".

According to PostgreSQL documentation http://www.postgresql.org/docs/8.4/static/sql-syntax-lexical.html , "unquoted names are always folded to lower case. For example, the identifiers FOO, foo, and "foo" are considered the same by PostgreSQL, but "Foo" and "FOO" are different from these three and each other"

By first analysis, I solved modifying the "__leaf_to_sql" method of "expression" class ( http://bazaar.launchpad.net/~openerp/openobject-server/trunk/annotate/2458/bin/osv/expression.py#L342 ) replacing every
%s.%s
with
"%s"."%s"

Revision history for this message
Lorenzo Battistini (elbati) wrote :

Here is the patch for trunk series

Revision history for this message
Lorenzo Battistini (elbati) wrote :

And here is the patch for 5.0 series

Revision history for this message
xrg (xrg) wrote :

Your analysis and patch are technically correct. However, I would challenge the need to support all-uppercase field names. By convention, we tend to only use lowercase (not even mixed).

Changed in openobject-server:
status: New → Triaged
Revision history for this message
Olivier Dony (Odoo) (odo-openerp) wrote :

Thanks for the suggestion, we can keep this wishlist improvement for after v6.0.

Changed in openobject-server:
assignee: nobody → OpenERP's Framework R&D (openerp-dev-framework)
importance: Undecided → Wishlist
status: Triaged → Confirmed
Revision history for this message
Olivier Dony (Odoo) (odo-openerp) wrote :

The latest trunk contains a fix for this bug, so we can close this bug now (a patch was needed in the read() method too, in addition to expression.py).

Thanks for reporting this and for providing patches!

PS: I'm afraid such an nice-to-have improvement has very low chances to be merged in any stable version (5.0 or 6.0), as it would be against all stable policies.

Changed in openobject-server:
milestone: none → 6.1
status: Confirmed → Fix Released
Revision history for this message
Olivier Dony (Odoo) (odo-openerp) wrote :

For the record, the relevant trunk server revision is r.3619 revid: <email address hidden>

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.