-
-
Notifications
You must be signed in to change notification settings - Fork 810
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ransack search not working for float fields #1183
Comments
Please use
|
Thanks @itsalongstory Closing this @Ezhil-cj, please re-open if still an issue. |
@seanfcarroll, @itsalongstory I'm reopening this because of below reasons, Ex: col 1 (int) col2 (date) col3 (str) col4 (float) Need to search - While searching above string for a common field with |
Ransack Float search
Here i had tried to search float data type, but not found the result as expected and inspected the query generation. Finally found it's not generating for float fields.
searching for float field (paid - float field)
search = 4.2
filter = {}
@purchases = Purchase.all
filter["paid_matches"] = "%#{search}%"
@q = @purchases.ransack(filter)
@purchases = @q.result
Ransack::Search<class: Purchase, base: Grouping <conditions: [Condition <attributes: ["paid"], predicate: cont, values: ["%4.2%"]>], combinator: and>>
will generates sql query like
SELECT
purchases.* FROM
purchasesWHERE
purchases.
deleted= 0 AND (
purchases.
paidLIKE 0.0) LIMIT 10 OFFSET 0
but expected
SELECT
purchases.* FROM
purchasesWHERE
purchases.
deleted= 0 AND (
purchases.
paidLIKE %4.2%) LIMIT 10 OFFSET 0
The text was updated successfully, but these errors were encountered: