Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
O
OHR Support
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
97
Issues
97
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
OHR Support
Commits
21b8e8b5
Commit
21b8e8b5
authored
Mar 02, 2011
by
Holger Just
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[
#250
] Allow empty sets in query value lists
parent
f2285fa9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
2 deletions
+12
-2
query.rb
app/models/query.rb
+12
-2
No files found.
app/models/query.rb
View file @
21b8e8b5
...
...
@@ -566,9 +566,19 @@ class Query < ActiveRecord::Base
sql
=
''
case
operator
when
"="
sql
=
"
#{
db_table
}
.
#{
db_field
}
IN ("
+
value
.
collect
{
|
val
|
"'
#{
connection
.
quote_string
(
val
)
}
'"
}.
join
(
","
)
+
")"
if
value
.
present?
sql
=
"
#{
db_table
}
.
#{
db_field
}
IN ("
+
value
.
collect
{
|
val
|
"'
#{
connection
.
quote_string
(
val
)
}
'"
}.
join
(
","
)
+
")"
else
# empty set of allowed values produces no result
sql
=
"0=1"
end
when
"!"
sql
=
"(
#{
db_table
}
.
#{
db_field
}
IS NULL OR
#{
db_table
}
.
#{
db_field
}
NOT IN ("
+
value
.
collect
{
|
val
|
"'
#{
connection
.
quote_string
(
val
)
}
'"
}.
join
(
","
)
+
"))"
if
value
.
present?
sql
=
"(
#{
db_table
}
.
#{
db_field
}
IS NULL OR
#{
db_table
}
.
#{
db_field
}
NOT IN ("
+
value
.
collect
{
|
val
|
"'
#{
connection
.
quote_string
(
val
)
}
'"
}.
join
(
","
)
+
"))"
else
# empty set of forbidden values allows all results
sql
=
"1=1"
end
when
"!*"
sql
=
"
#{
db_table
}
.
#{
db_field
}
IS NULL"
sql
<<
" OR
#{
db_table
}
.
#{
db_field
}
= ''"
if
is_custom_filter
...
...
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