kasket 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/kasket.rb +1 -1
- data/lib/kasket/query_parser.rb +6 -0
- data/test/parser_test.rb +5 -0
- metadata +4 -4
data/lib/kasket.rb
CHANGED
data/lib/kasket/query_parser.rb
CHANGED
@@ -21,6 +21,12 @@ module Kasket
|
|
21
21
|
query = Hash.new
|
22
22
|
query[:attributes] = sorted_attribute_value_pairs(match[1])
|
23
23
|
return nil if query[:attributes].nil?
|
24
|
+
|
25
|
+
if query[:attributes].size > 1 && query[:attributes].map(&:last).any? {|a| a.is_a?(Array)}
|
26
|
+
# this is a query with IN conditions AND other conditions
|
27
|
+
return nil
|
28
|
+
end
|
29
|
+
|
24
30
|
query[:index] = query[:attributes].map(&:first)
|
25
31
|
query[:limit] = match[2].blank? ? nil : 1
|
26
32
|
query[:key] = @model_class.kasket_key_for(query[:attributes])
|
data/test/parser_test.rb
CHANGED
@@ -8,6 +8,11 @@ class ParserTest < ActiveSupport::TestCase
|
|
8
8
|
@parser = Kasket::QueryParser.new(Post)
|
9
9
|
end
|
10
10
|
|
11
|
+
should 'not support IN queries in combination with other conditions' do
|
12
|
+
parsed_query = @parser.parse('SELECT * FROM `posts` WHERE (`posts`.`id` IN (1,2,3) AND `posts`.`is_active` = 1)')
|
13
|
+
assert(!parsed_query)
|
14
|
+
end
|
15
|
+
|
11
16
|
should "extract conditions" do
|
12
17
|
assert_equal [[:blog_id, "big"], [:title, "red"]], @parser.parse('SELECT * FROM `posts` WHERE (`posts`.`title` = red AND `posts`.`blog_id` = big)')[:attributes]
|
13
18
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kasket
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
9
|
+
- 2
|
10
|
+
version: 1.0.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Mick Staugaard
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2011-
|
19
|
+
date: 2011-07-13 00:00:00 -07:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|