kasket 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/lib/kasket.rb CHANGED
@@ -14,7 +14,7 @@ module Kasket
14
14
  class Version
15
15
  MAJOR = 1
16
16
  MINOR = 0
17
- PATCH = 1
17
+ PATCH = 2
18
18
  STRING = "#{MAJOR}.#{MINOR}.#{PATCH}"
19
19
  end
20
20
 
@@ -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: 21
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 1
10
- version: 1.0.1
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-04-26 00:00:00 -07:00
19
+ date: 2011-07-13 00:00:00 -07:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency