Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
1 ตอบกลับ
1558 มุมมอง

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.

Related Posts ตอบกลับ มุมมอง กิจกรรม
1
มี.ค. 24
1783
How can I recover ownership? แก้ไขแล้ว
1
ก.พ. 23
2082
Odoo database failed แก้ไขแล้ว
1
ธ.ค. 22
11663
Edit Company data Powered by Odoo แก้ไขแล้ว
6
มิ.ย. 15
7938
2
ก.พ. 25
8552