Select only id from query of ModelSQL.search
Closes #13421 (grafted from c544661300ba3dc53db4378d4070b4aae8c5c32e) --HG-- branch : 7.0
This commit is contained in:
1 parent
d2a2bedeed
commit
76dc002c4b
1 file changed
+9
-6
@@ -1783,12 +1783,15 @@ class ModelSQL(ModelStorage):
|
||||
order_by = cls.__search_order(order, tables)
|
||||
# compute it here because __search_order might modify tables
|
||||
table = convert_from(None, tables)
|
||||
columns = cls.__searched_columns(main_table, eager=not query)
|
||||
if backend.name == 'sqlite':
|
||||
for column in columns:
|
||||
field = cls._fields.get(column.output_name)
|
||||
if field:
|
||||
column.output_name += ' [%s]' % field.sql_type().base
|
||||
if query:
|
||||
columns = [main_table.id.as_('id')]
|
||||
else:
|
||||
columns = cls.__searched_columns(main_table, eager=True)
|
||||
if backend.name == 'sqlite':
|
||||
for column in columns:
|
||||
field = cls._fields.get(column.output_name)
|
||||
if field:
|
||||
column.output_name += ' [%s]' % field.sql_type().base
|
||||
select = table.select(
|
||||
*columns, where=expression, limit=limit, offset=offset,
|
||||
order_by=order_by)
|
||||
|
||||
Reference in new issue
Block a user