Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
ta_ransack_mongo
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open-source
ta_ransack_mongo
Commits
63aafb98
Commit
63aafb98
authored
Feb 13, 2022
by
liyijie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 增加trans_value,支持特殊值
parent
6b7e5cd3
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
2 deletions
+15
-2
query.rb
lib/ransack_mongo/query.rb
+15
-2
No files found.
lib/ransack_mongo/query.rb
View file @
63aafb98
...
...
@@ -20,7 +20,7 @@ module RansackMongo
or_query
(
db_adapter
,
attr
,
value
,
p
)
else
# attr => name
db_adapter
.
send
(
"
#{
p
}
_matcher"
,
attr
,
value
)
db_adapter
.
send
(
"
#{
p
}
_matcher"
,
attr
,
trans_value
(
value
)
)
end
rescue
NoMethodError
=>
e
raise
MatcherNotFound
,
"The matcher
#{
p
}
`
#{
p
}
_matcher` was not found in the
#{
db_adapter_class
.
name
}
. Check `
#{
db_adapter_class
}
.predicates`"
...
...
@@ -44,10 +44,23 @@ module RansackMongo
def
or_query
(
db_adapter
,
attr
,
value
,
p
)
db_adapter
.
or_op
do
attr
.
split
(
'_or_'
).
each
do
|
or_attr
|
db_adapter
.
send
(
"
#{
p
}
_matcher"
,
or_attr
,
value
)
db_adapter
.
send
(
"
#{
p
}
_matcher"
,
or_attr
,
trans_value
(
value
)
)
end
end
end
def
trans_value
value
case
value
when
'true'
true
when
'false'
false
when
'null'
,
'nil'
nil
else
value
end
end
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment