跳至内容
菜单
此问题已终结
1 回复
1428 查看

following is  a table of product_attribute and i want to search record of attribute using name like 
self.env.cr.execute("SELECT id FROM product_attribute WHERE name='Legs'")

it raises a error 
psycopg2.errors.InvalidTextRepresentation: invalid input syntax for type json

LINE 1: SELECT id FROM product_attribute WHERE name='Legs'



Any solution for this except using search() ? 

形象
丢弃
最佳答案

First off, if there is any chance avoid using the string to search any records, but you can achieve your expected output if you modify your query in this way using ILIKE :

SELECT id FROM product_attribute WHERE name ILIKE '%Legs%'

形象
丢弃
编写者

Thanks for the reply,
I understand that using string to find a record is not a good practice and i am doing it for custom script to create a records from files so i do not have another option.
I think with there is risk while using ilike, if there is similar string or it is substring of other string then it will give me a wrong id.

相关帖文 回复 查看 活动
1
3月 24
1646
1
2月 23
1943
1
12月 22
11481
6
6月 15
7797
2
2月 25
8408