axelor / axelor-open-platform

Open source Java framework for business application development
http://axelor.com
Other
393 stars 299 forks source link

Wrong criteria when querying json on relationship #55

Open ng-galien opened 5 years ago

ng-galien commented 5 years ago

This domain query on model com.axelor.apps.production.db.ManufOrder

self.product.code like 'PF-%' and self.product.attrs.MODEL = 'RV65'

is translated in the wrong way regarding the args indexing

SELECT self FROM ManufOrder self LEFT JOIN self.product _product WHERE ((_product.code like 'PF-%' and json_extract_text(self.product, 'attrs', 'MODEL') = 'RV65') AND (self.archived is null OR self.archived = false))

Using json_extract_text directly in the domain solve the problem

self.product.code like 'PF-%' and jsonb_extract_path_text(self.product.attrs, 'MODEL') = 'RV65'