kasket 2.2.0 → 2.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/kasket/query_parser.rb +7 -4
- data/lib/kasket/version.rb +1 -1
- data/test/parser_test.rb +4 -0
- metadata +4 -4
data/lib/kasket/query_parser.rb
CHANGED
@@ -23,10 +23,13 @@ module Kasket
|
|
23
23
|
def parse(sql)
|
24
24
|
if match = @supported_query_pattern.match(sql)
|
25
25
|
where, limit = match[1], match[2]
|
26
|
-
if AR30
|
27
|
-
|
28
|
-
|
29
|
-
|
26
|
+
if AR30
|
27
|
+
return if where =~ / (order by|group by|join|having) /i
|
28
|
+
if where =~ /limit \d+\s*$/i
|
29
|
+
# limit is harder to find in rails 3.0 since where does not use surrounding braces
|
30
|
+
return unless where =~ /(.*?)(\s+limit 1)\s*$/i
|
31
|
+
where, limit = $1, $2
|
32
|
+
end
|
30
33
|
end
|
31
34
|
|
32
35
|
query = Hash.new
|
data/lib/kasket/version.rb
CHANGED
data/test/parser_test.rb
CHANGED
@@ -34,6 +34,10 @@ class ParserTest < ActiveSupport::TestCase
|
|
34
34
|
assert !parse(:conditions => "(0 = 1)")
|
35
35
|
end
|
36
36
|
|
37
|
+
should "not support :order" do
|
38
|
+
assert !parse(:conditions => "id = 1", :order => "xxx")
|
39
|
+
end
|
40
|
+
|
37
41
|
should 'not support IN queries in combination with other conditions' do
|
38
42
|
assert !parse(:conditions => {:id => [1,2,3], :is_active => true})
|
39
43
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kasket
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.2.
|
4
|
+
version: 2.2.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-12-
|
13
|
+
date: 2012-12-11 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activerecord
|
@@ -183,7 +183,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
183
183
|
version: '0'
|
184
184
|
segments:
|
185
185
|
- 0
|
186
|
-
hash:
|
186
|
+
hash: -3400740618265195569
|
187
187
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
188
188
|
none: false
|
189
189
|
requirements:
|
@@ -192,7 +192,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
192
192
|
version: '0'
|
193
193
|
segments:
|
194
194
|
- 0
|
195
|
-
hash:
|
195
|
+
hash: -3400740618265195569
|
196
196
|
requirements: []
|
197
197
|
rubyforge_project:
|
198
198
|
rubygems_version: 1.8.24
|