-
Notifications
You must be signed in to change notification settings - Fork 37
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
Support for PostgreSQL ENUM #44
Comments
Maybe this code (placed in an initializer) can be used as a workaround: module SearchCopGrammar
module Attributes
class Enum < Base
def matches(value)
eq value
end
end
end
end
module SearchCop
module Visitors
class Visitor
def visit_enum(attribute)
"CAST(#{quote_table_name attribute.table_alias}.#{quote_column_name attribute.column_name} AS VARCHAR)"
end
alias visit_SearchCopGrammar_Attributes_Enum visit_enum
end
end
end |
hi, thanks for opening this. |
Looks like you can use Custom Operators for this enum gender: {
male: 0,
female: 1,
}
search_scope :search do
attributes :gender
generator :match_gender_enum do |column_name, raw_value|
gender_int = genders[raw_value]
"#{column_name} = #{gender_int}"
end
end
Book.search(gender: {match_gender_enum: "male"}) |
Great gem, @mrkamel!
One small thing: Support for PostgreSQL enums would be great. Currently, it fails with a
NameError
. Example:The text was updated successfully, but these errors were encountered: