.search() with like operator and underscore in search string problem

Bug #626816 reported by Erik Dannenberg (bloopark systems)
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Odoo Server (MOVED TO GITHUB)
Invalid
Undecided
Unassigned

Bug Description

The like/ilike operator seems to have problems when there are underscore(s) in the search string.

After some research i found that the underscore is special char for postgres and needs some escaping. However there seems to a problem with either openerp or psycopg.

The query i try to run:

self.pool.get('ir.model.fields').search(cr, uid, [('model_id', '=', ir_model_id), ('name', 'like', 'x\_magerp\_ebay\_damen\_' )])

After that i tried to do it via .execute():

cr.execute('select ir_model_fields.id from "ir_model_fields" where (ir_model_fields.model_id = %s) AND (ir_model_fields.name like %s)', [ir_model_id, 'x\_magerp\_ebay\_damen\_%'])

when i turn on sql logs it gets transformed to:

sql:query: select ir_model_fields.id from "ir_model_fields" where (ir_model_fields.model_id = 109) AND (ir_model_fields.name like E'x\\_magerp\\_ebay\\_damen\\_%')

I can copy that sql and execute it just fine in postgres with the expected results, however in openerp i get a empty list back.

Revision history for this message
Sharoon Thomas http://openlabs.co.in (sharoonthomas) wrote :

Hi,

I am keen to know if it affects the magento erp connector, since the example that has been cited is from the connector.

Thanks

Revision history for this message
Erik Dannenberg (bloopark systems) (edannenberg) wrote :

Hi Sharoon,

it currently doesn't affect the magento connector, the cited code is for a new feature we are developing for a customer.

Revision history for this message
Erik Dannenberg (bloopark systems) (edannenberg) wrote :

Not a bug and hence can be closed. Managed to work on a different database without noticing. ><

Revision history for this message
Jay Vora (Serpent Consulting Services) (jayvora) wrote :

Thanks Erik.

Changed in openobject-server:
status: New → Invalid
milestone: none → 5.0.13
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.