riddle 1.5.11 → 1.5.12

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,7 +4,7 @@ rvm:
4
4
  - 1.9.2
5
5
  - 1.9.3
6
6
  - 2.0.0
7
- - 2.1.0
7
+ - 2.1
8
8
  - jruby-18mode
9
9
  env:
10
10
  - SPHINX_BIN=/usr/local/sphinx-2.0.9/bin SPHINX_VERSION=2.0.9
data/HISTORY CHANGED
@@ -1,3 +1,9 @@
1
+ 1.5.12 - June 1st 2015
2
+ - Adding ? as an escaped character (Alexey Nikitin).
3
+ - Adding contributor code of conduct.
4
+ - Spec fixes, and updating escape_column to not escape JSON expressions that make use of dot or bracket notation (Daniel Vandersluis).
5
+ - Fix stop action to allow exception propagation (Dejan Simic).
6
+
1
7
  1.5.11 - April 19th 2014
2
8
  - Riddle::Query.escape covers = and & characters.
3
9
  - Hold onto address and port settings when crafting the equivalent listen setting, but don't render them.
@@ -57,6 +57,8 @@ If you've installed the gem and wondering why there's no tests - check out the g
57
57
 
58
58
  h2. Contributing
59
59
 
60
+ Please note that this project now has a "Contributor Code of Conduct":http://contributor-covenant.org/version/1/0/0/. By participating in this project you agree to abide by its terms.
61
+
60
62
  Riddle uses the "git-flow":http://jeffkreeftmeijer.com/2010/why-arent-you-using-git-flow/ process for development. The "master" branch is the latest released code (in a gem). The "develop" branch is what's coming in the next release. (There may be occasional feature and hotfix branches, although these are generally not pushed to GitHub.)
61
63
 
62
64
  When submitting a patch to riddle, please submit your pull request against the "develop" branch.
@@ -4,7 +4,7 @@ require 'timeout'
4
4
 
5
5
  module Riddle #:nodoc:
6
6
  @@mutex = Mutex.new
7
- @@escape_pattern = /[\(\)\|\-!@~"&\/]/
7
+ @@escape_pattern = /[\(\)\|\-!@~"&\/\?]/
8
8
  @@use_encoding = defined?(::Encoding) &&
9
9
  ::Encoding.respond_to?(:default_external)
10
10
 
@@ -63,8 +63,8 @@ module Riddle
63
63
  else
64
64
  `#{cmd}`
65
65
  end
66
- ensure
67
- return !running?
66
+
67
+ !running?
68
68
  end
69
69
 
70
70
  def pid
@@ -99,7 +99,7 @@ module Riddle::Query
99
99
  end
100
100
 
101
101
  def self.escape(string)
102
- string.gsub(/[\(\)\|\-!@~\/"\/\^\$\\><&=]/) { |match| "\\#{match}" }
102
+ string.gsub(/[\(\)\|\-!@~\/"\/\^\$\\><&=\?]/) { |match| "\\#{match}" }
103
103
  end
104
104
 
105
105
  def self.quote(string)
@@ -224,7 +224,7 @@ class Riddle::Query::Select
224
224
  end
225
225
 
226
226
  def escape_column(column)
227
- if column.to_s[/\A[`@]/] || column.to_s[/\A\w+\(/]
227
+ if column.to_s[/\A[`@]/] || column.to_s[/\A\w+\(/] || column.to_s[/\A\w+[.\[]/]
228
228
  column
229
229
  else
230
230
  column_name, *extra = column.to_s.split(' ')
@@ -3,7 +3,7 @@ $:.push File.expand_path('../lib', __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = 'riddle'
6
- s.version = '1.5.11'
6
+ s.version = '1.5.12'
7
7
  s.platform = Gem::Platform::RUBY
8
8
  s.authors = ['Pat Allan']
9
9
  s.email = ['pat@freelancing-gods.com']
@@ -10,11 +10,11 @@ describe 'SphinxQL escaping', :live => true do
10
10
  select.to_sql
11
11
  end
12
12
 
13
- ['@', "'", '"', '\\"', "\\'"].each do |string|
13
+ ['@', "'", '"', '\\"', "\\'", "?"].each do |string|
14
14
  it "escapes #{string}" do
15
15
  lambda {
16
16
  connection.query sphinxql_matching(Riddle::Query.escape(string))
17
- }.should_not raise_error(Mysql2::Error)
17
+ }.should_not raise_error
18
18
  end
19
19
  end
20
20
 
@@ -4,7 +4,7 @@ describe Riddle::AutoVersion do
4
4
  describe '.configure' do
5
5
  before :each do
6
6
  @controller = Riddle::Controller.new stub('configuration'), 'sphinx.conf'
7
- Riddle::Controller.stub!(:new => @controller)
7
+ Riddle::Controller.stub(:new => @controller)
8
8
 
9
9
  unless ENV['SPHINX_VERSION'].nil?
10
10
  @env_version, ENV['SPHINX_VERSION'] = ENV['SPHINX_VERSION'].dup, nil
@@ -18,77 +18,77 @@ describe Riddle::AutoVersion do
18
18
  it "should require 0.9.8 if that is the known version" do
19
19
  Riddle::AutoVersion.should_receive(:require).with('riddle/0.9.8')
20
20
 
21
- @controller.stub!(:sphinx_version => '0.9.8')
21
+ @controller.stub(:sphinx_version => '0.9.8')
22
22
  Riddle::AutoVersion.configure
23
23
  end
24
24
 
25
25
  it "should require 0.9.9 if that is the known version" do
26
26
  Riddle::AutoVersion.should_receive(:require).with('riddle/0.9.9')
27
27
 
28
- @controller.stub!(:sphinx_version => '0.9.9')
28
+ @controller.stub(:sphinx_version => '0.9.9')
29
29
  Riddle::AutoVersion.configure
30
30
  end
31
31
 
32
32
  it "should require 1.10 if that is the known version" do
33
33
  Riddle::AutoVersion.should_receive(:require).with('riddle/1.10')
34
34
 
35
- @controller.stub!(:sphinx_version => '1.10-beta')
35
+ @controller.stub(:sphinx_version => '1.10-beta')
36
36
  Riddle::AutoVersion.configure
37
37
  end
38
38
 
39
39
  it "should require 1.10 if using 1.10 with 64 bit IDs" do
40
40
  Riddle::AutoVersion.should_receive(:require).with('riddle/1.10')
41
41
 
42
- @controller.stub!(:sphinx_version => '1.10-id64-beta')
42
+ @controller.stub(:sphinx_version => '1.10-id64-beta')
43
43
  Riddle::AutoVersion.configure
44
44
  end
45
45
 
46
46
  it "should require 2.0.1 if that is the known version" do
47
47
  Riddle::AutoVersion.should_receive(:require).with('riddle/2.0.1')
48
48
 
49
- @controller.stub!(:sphinx_version => '2.0.1-beta')
49
+ @controller.stub(:sphinx_version => '2.0.1-beta')
50
50
  Riddle::AutoVersion.configure
51
51
  end
52
52
 
53
53
  it "should require 2.0.1 if 2.0.2-dev is being used" do
54
54
  Riddle::AutoVersion.should_receive(:require).with('riddle/2.0.1')
55
55
 
56
- @controller.stub!(:sphinx_version => '2.0.2-dev')
56
+ @controller.stub(:sphinx_version => '2.0.2-dev')
57
57
  Riddle::AutoVersion.configure
58
58
  end
59
59
 
60
60
  it "should require 2.1.0 if 2.0.3 is being used" do
61
61
  Riddle::AutoVersion.should_receive(:require).with('riddle/2.1.0')
62
62
 
63
- @controller.stub!(:sphinx_version => '2.0.3-release')
63
+ @controller.stub(:sphinx_version => '2.0.3-release')
64
64
  Riddle::AutoVersion.configure
65
65
  end
66
66
 
67
67
  it "should require 2.1.0 if 2.0.4 is being used" do
68
68
  Riddle::AutoVersion.should_receive(:require).with('riddle/2.1.0')
69
69
 
70
- @controller.stub!(:sphinx_version => '2.0.4-release')
70
+ @controller.stub(:sphinx_version => '2.0.4-release')
71
71
  Riddle::AutoVersion.configure
72
72
  end
73
73
 
74
74
  it "should require 2.1.0 if 2.0.5 is being used" do
75
75
  Riddle::AutoVersion.should_receive(:require).with('riddle/2.1.0')
76
76
 
77
- @controller.stub!(:sphinx_version => '2.0.5-release')
77
+ @controller.stub(:sphinx_version => '2.0.5-release')
78
78
  Riddle::AutoVersion.configure
79
79
  end
80
80
 
81
81
  it "should require 2.1.0 if 2.2.1 is being used" do
82
82
  Riddle::AutoVersion.should_receive(:require).with('riddle/2.1.0')
83
83
 
84
- @controller.stub!(:sphinx_version => '2.2.1-beta')
84
+ @controller.stub(:sphinx_version => '2.2.1-beta')
85
85
  Riddle::AutoVersion.configure
86
86
  end
87
87
 
88
88
  it "should require 2.1.0 if that is the known version" do
89
89
  Riddle::AutoVersion.should_receive(:require).with('riddle/2.1.0')
90
90
 
91
- @controller.stub!(:sphinx_version => '2.1.0-dev')
91
+ @controller.stub(:sphinx_version => '2.1.0-dev')
92
92
  Riddle::AutoVersion.configure
93
93
  end
94
94
  end
@@ -7,32 +7,32 @@ describe Riddle::Controller do
7
7
  end
8
8
 
9
9
  it "should return 1.10 if using 1.10-beta" do
10
- @controller.stub!(:` => 'Sphinx 1.10-beta (r2420)')
10
+ @controller.stub(:` => 'Sphinx 1.10-beta (r2420)')
11
11
  @controller.sphinx_version.should == '1.10-beta'
12
12
  end
13
13
 
14
14
  it "should return 0.9.9 if using 0.9.9" do
15
- @controller.stub!(:` => 'Sphinx 0.9.9-release (r2117)')
15
+ @controller.stub(:` => 'Sphinx 0.9.9-release (r2117)')
16
16
  @controller.sphinx_version.should == '0.9.9'
17
17
  end
18
18
 
19
19
  it "should return 0.9.9 if using 0.9.9 rc2" do
20
- @controller.stub!(:` => 'Sphinx 0.9.9-rc2 (r1785)')
20
+ @controller.stub(:` => 'Sphinx 0.9.9-rc2 (r1785)')
21
21
  @controller.sphinx_version.should == '0.9.9'
22
22
  end
23
23
 
24
24
  it "should return 0.9.9 if using 0.9.9 rc1" do
25
- @controller.stub!(:` => 'Sphinx 0.9.9-rc1 (r1566)')
25
+ @controller.stub(:` => 'Sphinx 0.9.9-rc1 (r1566)')
26
26
  @controller.sphinx_version.should == '0.9.9'
27
27
  end
28
28
 
29
29
  it "should return 0.9.8 if using 0.9.8.1" do
30
- @controller.stub!(:` => 'Sphinx 0.9.8.1-release (r1533)')
30
+ @controller.stub(:` => 'Sphinx 0.9.8.1-release (r1533)')
31
31
  @controller.sphinx_version.should == '0.9.8'
32
32
  end
33
33
 
34
34
  it "should return 0.9.8 if using 0.9.8" do
35
- @controller.stub!(:` => 'Sphinx 0.9.8-release (r1371)')
35
+ @controller.stub(:` => 'Sphinx 0.9.8-release (r1371)')
36
36
  @controller.sphinx_version.should == '0.9.8'
37
37
  end
38
38
  end
@@ -24,6 +24,16 @@ describe Riddle::Query::Select do
24
24
  should == 'SELECT @weight FROM foo_core'
25
25
  end
26
26
 
27
+ it 'handles JSON as a select value using dot notation' do
28
+ query.values('key1.key2.key3').from('foo_core').to_sql.
29
+ should == 'SELECT key1.key2.key3 FROM foo_core'
30
+ end
31
+
32
+ it 'handles JSON as a select value using bracket notation 2' do
33
+ query.values("key1['key2']['key3']").from('foo_core').to_sql.
34
+ should == "SELECT key1['key2']['key3'] FROM foo_core"
35
+ end
36
+
27
37
  it "can prepend select values" do
28
38
  query.values('@weight').prepend_values('foo').from('foo_core').to_sql.
29
39
  should == 'SELECT foo, @weight FROM foo_core'
@@ -127,6 +137,16 @@ describe Riddle::Query::Select do
127
137
  should == "SELECT * FROM foo_core WHERE (`bars` <> 1 OR `bars` <> 2)"
128
138
  end
129
139
 
140
+ it 'handles filters on JSON with dot syntax' do
141
+ query.from('foo_core').where('key1.key2.key3' => 10).to_sql.
142
+ should == "SELECT * FROM foo_core WHERE key1.key2.key3 = 10"
143
+ end
144
+
145
+ it 'handles filters on JSON with bracket syntax' do
146
+ query.from('foo_core').where("key1['key2']['key3']" => 10).to_sql.
147
+ should == "SELECT * FROM foo_core WHERE key1['key2']['key3'] = 10"
148
+ end
149
+
130
150
  it 'handles grouping' do
131
151
  query.from('foo_core').group_by('bar_id').to_sql.
132
152
  should == "SELECT * FROM foo_core GROUP BY `bar_id`"
@@ -78,7 +78,7 @@ describe Riddle::Query do
78
78
  end
79
79
 
80
80
  describe '.escape' do
81
- %w(( ) | - ! @ ~ / ^ $ " > <).each do |reserved|
81
+ %w(( ) | - ! @ ~ / ^ $ " > < ?).each do |reserved|
82
82
  it "escapes #{reserved}" do
83
83
  Riddle::Query.escape(reserved).should == "\\#{reserved}"
84
84
  end
metadata CHANGED
@@ -1,66 +1,82 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: riddle
3
- version: !ruby/object:Gem::Version
4
- version: 1.5.11
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
+ prerelease:
6
+ segments:
7
+ - 1
8
+ - 5
9
+ - 12
10
+ version: 1.5.12
5
11
  platform: ruby
6
- authors:
12
+ authors:
7
13
  - Pat Allan
8
14
  autorequire:
9
15
  bindir: bin
10
16
  cert_chain: []
11
- date: 2014-04-19 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
17
+
18
+ date: 2015-06-01 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
14
21
  name: rake
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
22
+ version_requirements: &id001 !ruby/object:Gem::Requirement
23
+ none: false
24
+ requirements:
17
25
  - - ">="
18
- - !ruby/object:Gem::Version
26
+ - !ruby/object:Gem::Version
27
+ hash: 63
28
+ segments:
29
+ - 0
30
+ - 9
31
+ - 2
19
32
  version: 0.9.2
20
- type: :development
21
33
  prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- version: 0.9.2
27
- - !ruby/object:Gem::Dependency
34
+ type: :development
35
+ requirement: *id001
36
+ - !ruby/object:Gem::Dependency
28
37
  name: rspec
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
38
+ version_requirements: &id002 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
31
41
  - - ">="
32
- - !ruby/object:Gem::Version
42
+ - !ruby/object:Gem::Version
43
+ hash: 27
44
+ segments:
45
+ - 2
46
+ - 5
47
+ - 0
33
48
  version: 2.5.0
34
- type: :development
35
49
  prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: 2.5.0
41
- - !ruby/object:Gem::Dependency
50
+ type: :development
51
+ requirement: *id002
52
+ - !ruby/object:Gem::Dependency
42
53
  name: yard
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
54
+ version_requirements: &id003 !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
45
57
  - - ">="
46
- - !ruby/object:Gem::Version
58
+ - !ruby/object:Gem::Version
59
+ hash: 7
60
+ segments:
61
+ - 0
62
+ - 7
63
+ - 2
47
64
  version: 0.7.2
48
- type: :development
49
65
  prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: 0.7.2
66
+ type: :development
67
+ requirement: *id003
55
68
  description: A Ruby API and configuration helper for the Sphinx search service.
56
- email:
69
+ email:
57
70
  - pat@freelancing-gods.com
58
71
  executables: []
72
+
59
73
  extensions: []
74
+
60
75
  extra_rdoc_files: []
61
- files:
62
- - ".gitignore"
63
- - ".travis.yml"
76
+
77
+ files:
78
+ - .gitignore
79
+ - .travis.yml
64
80
  - Gemfile
65
81
  - HISTORY
66
82
  - LICENCE
@@ -267,30 +283,39 @@ files:
267
283
  - spec/unit/response_spec.rb
268
284
  - spec/unit/riddle_spec.rb
269
285
  homepage: http://pat.github.io/riddle/
270
- licenses:
286
+ licenses:
271
287
  - MIT
272
- metadata: {}
273
288
  post_install_message:
274
289
  rdoc_options: []
275
- require_paths:
290
+
291
+ require_paths:
276
292
  - lib
277
- required_ruby_version: !ruby/object:Gem::Requirement
278
- requirements:
293
+ required_ruby_version: !ruby/object:Gem::Requirement
294
+ none: false
295
+ requirements:
279
296
  - - ">="
280
- - !ruby/object:Gem::Version
281
- version: '0'
282
- required_rubygems_version: !ruby/object:Gem::Requirement
283
- requirements:
297
+ - !ruby/object:Gem::Version
298
+ hash: 3
299
+ segments:
300
+ - 0
301
+ version: "0"
302
+ required_rubygems_version: !ruby/object:Gem::Requirement
303
+ none: false
304
+ requirements:
284
305
  - - ">="
285
- - !ruby/object:Gem::Version
286
- version: '0'
306
+ - !ruby/object:Gem::Version
307
+ hash: 3
308
+ segments:
309
+ - 0
310
+ version: "0"
287
311
  requirements: []
312
+
288
313
  rubyforge_project: riddle
289
- rubygems_version: 2.2.2
314
+ rubygems_version: 1.8.25
290
315
  signing_key:
291
- specification_version: 4
316
+ specification_version: 3
292
317
  summary: An API for Sphinx, written in and for Ruby.
293
- test_files:
318
+ test_files:
294
319
  - spec/fixtures/.gitignore
295
320
  - spec/fixtures/data/0.9.9/anchor.bin
296
321
  - spec/fixtures/data/0.9.9/any.bin
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: 55868c085e98a4ee1485e4b2b571cac9e712d7f6
4
- data.tar.gz: e9c77b9c6d818662404f86951a839df4e0358cd4
5
- SHA512:
6
- metadata.gz: 48cdfd60502df6763b278b0f64f7750554c2075ea9c66cebbf86f4a886891d1b0beb33924f04cd09f17367b8992cbef47571237396157118bee2852a7acb7815
7
- data.tar.gz: f7751e152943f0ba712132cce958ff5688524e204628e1975727cc4c978fb3ff5ded9f78d64e6f69a52ca1567b5a02048aec93749b1dffdbc89518e85a9c2e17