Comments (5)
I think this would be a nice feature. I'm not sure whether or not the naming :mapper => ...
is fully self explanatory, but we'll find a proper solution.
The actual mapping should probably happen in https://github.com/mrkamel/search_cop/blob/master/lib/search_cop_grammar/attributes.rb
Wanna create a PR?
from search_cop.
Sure! Are you ok with the Proc within the options hash?
from search_cop.
Sure, i'm fine with it
from search_cop.
+1
from search_cop.
This feature was added as part of #35
Example usage:
class Book
include SearchCop
enum types: {
foo: 0,
bar: 1,
}
search_scope :search do
attributes :number, :my_enum
generator :like_string do |column_name, raw_value|
pattern = quote("%#{raw_value}%")
"#{column_name} LIKE #{pattern}"
end
generator :match_type_enum do |column_name, raw_value|
type_int = types[raw_value]
"#{column_name} = #{type_int}"
end
end
end
Book.search(number: {like_string: "123"}, my_enum: {match_type_enum: "foo"})
from search_cop.
Related Issues (20)
- globalize with search_cop - unknown attribute HOT 2
- Ignoring MySQL stop words for full-text search HOT 5
- Support for PostgreSQL ENUM HOT 3
- Matching multiple in a has_many HOT 1
- multiple where conditions and concatenated with AND HOT 3
- Attribute (case insensitive / ILIKE) HOT 3
- generator for attribute options HOT 3
- Error when using with non-standard pluralization in class name HOT 2
- DEPRECATION WARNING HOT 2
- How to handle special search logic / virtual attributes HOT 4
- Suggestion: Option for `exact: true` (or `right_wildcard: false`) HOT 1
- Can search_cop work with Postgres hstore? HOT 8
- Suggestion: Add support for sort in the free text search HOT 4
- Searching for empty or non empty with the free text expression HOT 2
- RAILS 6 - Search in ActionText HOT 3
- Search word that include % does not work correctly HOT 2
- Ability to apply Custom Operators or Options to entire project HOT 1
- ActiveRecord::ConfigurationError in v1.2.1 HOT 10
- README error? HOT 6
- Words containing brackets HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from search_cop.