-
Notifications
You must be signed in to change notification settings - Fork 380
Open
Description
I noticed that updating from 2.3.6 to 2.3.7 breaks queries using sort_only: true by adding a subquery with a WHERE clause with no condition.
See my example:
pg_search_scope :sort_by_address,
->(query, options = nil) {
search_options = {
query: query,
against: [:address],
using: {
tsearch: {
prefix: true,
any_word: true,
sort_only: true,
dictionary: 'simple'
}
},
ignoring: :accents,
ranked_by: ':tsearch'
}
search_options = search_options.merge(options) if options.is_a?(Hash)
search_options
}
...
Item.sort_by_address('foo', order_within_rank: 'items.address')
This produces:
SELECT
"items"."id"
FROM
"items"
INNER JOIN (
SELECT
"items"."id" AS pg_search_id,
(ts_rank((to_tsvector('simple', f_unaccent (coalesce(("items"."address")::text, '')))), (to_tsquery('simple', ''' ' || f_unaccent ('foo') || ' ''' || ':*')), 0)) AS RANK
FROM
"items"
WHERE
) AS pg_search_3ae62594b1830faf2c5da4 ON "items"."id" = pg_search_3ae62594b1830faf2c5da4.pg_search_id
ORDER BY
pg_search_3ae62594b1830faf2c5da4.rank DESC,
items.address
Where the corrupted part is this part:
FROM
"items"
WHERE
)
ovinix
Metadata
Metadata
Assignees
Labels
No labels