riddle 1.5.6 → 1.5.7

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/HISTORY CHANGED
@@ -1,3 +1,11 @@
1
+ 1.5.7 - July 9th 2013
2
+ - Respect Riddle::OutOfBoundsError instances, instead of wrapping them in ResponseError.
3
+ - Handle boolean values for snippets options.
4
+ - Don't modify snippets parameters (Demian Ferreiro).
5
+ - rt_attr_multi and rt_attr_multi_64 settings for real-time indices.
6
+ - Arrays in INSERT/REPLACE statements are wrapped in parentheses with values separated by commas. Required for MVA values in real-time indices.
7
+ - Clear out the query queue before running a single query.
8
+
1
9
  1.5.6 - May 7th 2013
2
10
  - Wrap underlying parse errors within Riddle::ResponseError instances when parsing responses.
3
11
  - Add lemmatization options (Kirill Lazarev).
@@ -89,4 +97,4 @@
89
97
  - Using Bundler, MySQL2 and Ruby 1.9.2 in development
90
98
  - Allow for Sphinx versions compiled from source and SVN (Greg Weber)
91
99
 
92
- 1.2.2 - December 22nd 2011
100
+ 1.2.2 - December 22nd 2011
data/lib/riddle/client.rb CHANGED
@@ -292,6 +292,8 @@ module Riddle
292
292
 
293
293
  @queue.clear
294
294
  results
295
+ rescue Riddle::OutOfBoundsError => error
296
+ raise error
295
297
  rescue => original
296
298
  error = ResponseError.new original.message
297
299
  error.original = original
@@ -340,6 +342,7 @@ module Riddle
340
342
  # will be described under <tt>:error</tt>.
341
343
  #
342
344
  def query(search, index = '*', comments = '')
345
+ @queue.clear
343
346
  @queue << query_message(search, index, comments)
344
347
  self.run.first
345
348
  end
@@ -6,12 +6,14 @@ module Riddle
6
6
  def self.settings
7
7
  Riddle::Configuration::IndexSettings.settings + [
8
8
  :rt_mem_limit, :rt_field, :rt_attr_uint, :rt_attr_bigint,
9
- :rt_attr_float, :rt_attr_timestamp, :rt_attr_string
9
+ :rt_attr_float, :rt_attr_timestamp, :rt_attr_string, :rt_attr_multi,
10
+ :rt_attr_multi_64
10
11
  ]
11
12
  end
12
13
 
13
14
  attr_accessor :rt_mem_limit, :rt_field, :rt_attr_uint, :rt_attr_bigint,
14
- :rt_attr_float, :rt_attr_timestamp, :rt_attr_string
15
+ :rt_attr_float, :rt_attr_timestamp, :rt_attr_string, :rt_attr_multi,
16
+ :rt_attr_multi_64
15
17
 
16
18
  def initialize(name)
17
19
  @name = name
@@ -21,6 +23,8 @@ module Riddle
21
23
  @rt_attr_float = []
22
24
  @rt_attr_timestamp = []
23
25
  @rt_attr_string = []
26
+ @rt_attr_multi = []
27
+ @rt_attr_multi_64 = []
24
28
 
25
29
  initialize_settings
26
30
  end
data/lib/riddle/query.rb CHANGED
@@ -58,11 +58,11 @@ module Riddle::Query
58
58
  end
59
59
 
60
60
  def self.snippets(data, index, query, options = nil)
61
- data.gsub!("'") { |x| "\\'" }
62
- query.gsub!("'") { |x| "\\'" }
61
+ data = data.gsub("'") { |x| "\\'" }
62
+ query = query.gsub("'") { |x| "\\'" }
63
63
 
64
64
  options = ', ' + options.keys.collect { |key|
65
- value = options[key]
65
+ value = translate_value options[key]
66
66
  value = "'#{value}'" if value.is_a?(String)
67
67
 
68
68
  "#{value} AS #{key}"
@@ -1,32 +1,32 @@
1
1
  class Riddle::Query::Insert
2
2
  attr_reader :columns, :values
3
-
3
+
4
4
  def initialize(index, columns = [], values = [])
5
5
  @index = index
6
6
  @columns = columns
7
7
  @values = values.first.is_a?(Array) ? values : [values]
8
8
  @replace = false
9
9
  end
10
-
10
+
11
11
  def replace!
12
12
  @replace = true
13
13
  self
14
14
  end
15
-
15
+
16
16
  def to_sql
17
17
  "#{command} INTO #{@index} (#{columns_to_s}) VALUES (#{values_to_s})"
18
18
  end
19
-
19
+
20
20
  private
21
-
21
+
22
22
  def command
23
23
  @replace ? 'REPLACE' : 'INSERT'
24
24
  end
25
-
25
+
26
26
  def columns_to_s
27
27
  columns.join(', ')
28
28
  end
29
-
29
+
30
30
  def values_to_s
31
31
  values.collect { |value_set|
32
32
  value_set.collect { |value|
@@ -34,7 +34,7 @@ class Riddle::Query::Insert
34
34
  }.join(', ')
35
35
  }.join('), (')
36
36
  end
37
-
37
+
38
38
  def translated_value(value)
39
39
  case value
40
40
  when String
@@ -43,6 +43,8 @@ class Riddle::Query::Insert
43
43
  value ? 1 : 0
44
44
  when Time
45
45
  value.to_i
46
+ when Array
47
+ "(#{value.join(',')})"
46
48
  else
47
49
  value
48
50
  end
data/riddle.gemspec CHANGED
@@ -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.6'
6
+ s.version = '1.5.7'
7
7
  s.platform = Gem::Platform::RUBY
8
8
  s.authors = ['Pat Allan']
9
9
  s.email = ['pat@freelancing-gods.com']
@@ -42,6 +42,14 @@ describe 'Sphinx Client', :live => true do
42
42
  should raise_error(Riddle::ResponseError)
43
43
  end
44
44
 
45
+ it "should not override OutOfBoundsError instances" do
46
+ client.connection = lambda { |client|
47
+ raise Riddle::OutOfBoundsError
48
+ }
49
+ lambda { client.query('smith') }.
50
+ should raise_error(Riddle::OutOfBoundsError)
51
+ end
52
+
45
53
  it "should prioritise instance over class connection" do
46
54
  Riddle::Client.connection = lambda { |client|
47
55
  raise RiddleSpecConnectionProcError
@@ -47,6 +47,11 @@ describe Riddle::Query do
47
47
  :before_match => '<strong>').should == "CALL SNIPPETS('foo bar baz', 'foo_core', 'foo', '<strong>' AS before_match)"
48
48
  end
49
49
 
50
+ it "handles boolean options" do
51
+ Riddle::Query.snippets('foo bar baz', 'foo_core', 'foo',
52
+ :exact_phrase => true).should == "CALL SNIPPETS('foo bar baz', 'foo_core', 'foo', 1 AS exact_phrase)"
53
+ end
54
+
50
55
  it "escapes quotes in the text data" do
51
56
  Riddle::Query.snippets("foo bar 'baz", 'foo_core', 'foo').
52
57
  should == "CALL SNIPPETS('foo bar \\'baz', 'foo_core', 'foo')"
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: riddle
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
4
+ hash: 13
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 5
9
- - 6
10
- version: 1.5.6
9
+ - 7
10
+ version: 1.5.7
11
11
  platform: ruby
12
12
  authors:
13
13
  - Pat Allan
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2013-05-07 00:00:00 -07:00
18
+ date: 2013-07-09 00:00:00 +10:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency