thinking-sphinx 3.1.3 → 3.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c17f93cf2e09238f8df63a50264d09abe50051ba
4
- data.tar.gz: 90d74a5a5d8f5b7edc71826ec67adeb9ae4550b3
3
+ metadata.gz: c37a8158a4baca6cab0f26af120eeb5465ee53fc
4
+ data.tar.gz: 875569737b2a9456c28302c2bfd5a06b9571f3ea
5
5
  SHA512:
6
- metadata.gz: c861cf2251899f29b7f82d7c471918f9147042792f5856e5205f4dc431dfac38e1e41204e74415710848ce8d1ce72333c296cf695250930d3070aa55f629ff48
7
- data.tar.gz: af1e25122e4710693c232f98e1ffd9a03092222417a2b5f20a274dcabc30785047f05bade7212689de939ee2724ce47161a665b14b6b14731ef8220d76bf75c1
6
+ metadata.gz: 8409e713da894877707dfd5d0bad3fc6454b1c1b21edce294778fedad926d04e6947db05d938fb9473af59f4636c57d65b9ffc682e9afdfde467ab86a552bf6c
7
+ data.tar.gz: 486a6e944456d0d007e44759259d915e32c09bbd8e263699762d56be1a5ad736de8576f41a2ceb6b035552bb6cf0baf44c7d8c440a54d0c1dff470d159bfba64
@@ -6,18 +6,16 @@ rvm:
6
6
  - jruby-19mode
7
7
  before_install:
8
8
  - gem update --system
9
+ - gem install bundler
9
10
  before_script:
10
11
  - "mysql -e 'create database thinking_sphinx;' > /dev/null"
11
12
  - "psql -c 'create database thinking_sphinx;' -U postgres >/dev/null"
13
+ - bundle exec appraisal install
14
+ script: bundle exec appraisal rspec
12
15
  env:
13
16
  - DATABASE=mysql2 SPHINX_BIN=/usr/local/sphinx-2.0.10/bin/ SPHINX_VERSION=2.0.10
14
17
  - DATABASE=postgresql SPHINX_BIN=/usr/local/sphinx-2.0.10/bin/ SPHINX_VERSION=2.0.10
15
- - DATABASE=mysql2 SPHINX_BIN=/usr/local/sphinx-2.1.8/bin/ SPHINX_VERSION=2.1.8
16
- - DATABASE=postgresql SPHINX_BIN=/usr/local/sphinx-2.1.8/bin/ SPHINX_VERSION=2.1.8
17
- - DATABASE=mysql2 SPHINX_BIN=/usr/local/sphinx-2.2.2-beta/bin/ SPHINX_VERSION=2.2.2
18
- - DATABASE=postgresql SPHINX_BIN=/usr/local/sphinx-2.2.2-beta/bin/ SPHINX_VERSION=2.2.2
19
- gemfile:
20
- - gemfiles/rails_3_2.gemfile
21
- - gemfiles/rails_4_0.gemfile
22
- - gemfiles/rails_4_1.gemfile
23
- - gemfiles/rails_4_2.gemfile
18
+ - DATABASE=mysql2 SPHINX_BIN=/usr/local/sphinx-2.1.9/bin/ SPHINX_VERSION=2.1.9
19
+ - DATABASE=postgresql SPHINX_BIN=/usr/local/sphinx-2.1.9/bin/ SPHINX_VERSION=2.1.9
20
+ - DATABASE=mysql2 SPHINX_BIN=/usr/local/sphinx-2.2.6/bin/ SPHINX_VERSION=2.2.6
21
+ - DATABASE=postgresql SPHINX_BIN=/usr/local/sphinx-2.2.6/bin/ SPHINX_VERSION=2.2.6
data/HISTORY CHANGED
@@ -1,3 +1,16 @@
1
+ 2015-06-01: 3.1.4
2
+ * [FIX] Kaminari expects prev_page to be available.
3
+ * [CHANGE] Add a contributor code of conduct.
4
+ * [FEATURE] Add JSON as a Sphinx type for attributes (Daniel Vandersluis).
5
+ * [CHANGE] Remove polymorphic association and HABTM query support (when related to Thinking Sphinx) when ActiveRecord 3.2 is involved.
6
+ * [FIX] Don't try to delete guard files if they don't exist (@exAspArk).
7
+ * [FEATURE] minimal_group_by? can now be set in config/thinking_sphinx.yml to automatically apply to all index definitions.
8
+ * [FIX] Handle database settings reliably, now that ActiveRecord 4.2 uses strings all the time.
9
+ * [FIX] More consistent with escaping table names.
10
+ * [CHANGE] Remove default charset_type - no longer required for Sphinx 2.2.
11
+ * [FIX] Bug fix for association creation (with polymophic fields/attributes).
12
+ * [CHANGE] Removing sql_query_info setting, as it's no longer used by Sphinx (nor is it actually used by Thinking Sphinx).
13
+
1
14
  2015-01-21: 3.1.3
2
15
  * [CHANGE] Log excerpt SphinxQL queries just like the search queries.
3
16
  * [CHANGE] Load Railtie if Rails::Railtie is defined, instead of just Rails (Andrew Cone).
@@ -1,11 +1,12 @@
1
1
  h1. Thinking Sphinx
2
2
 
3
- Thinking Sphinx is a library for connecting ActiveRecord to the Sphinx full-text search tool, and integrates closely with Rails (but also works with other Ruby web frameworks). The current release is v3.1.3.
3
+ Thinking Sphinx is a library for connecting ActiveRecord to the Sphinx full-text search tool, and integrates closely with Rails (but also works with other Ruby web frameworks). The current release is v3.1.4.
4
4
 
5
5
  h2. Upgrading
6
6
 
7
7
  Please refer to the release notes for any changes you need to make when upgrading:
8
8
 
9
+ * "v3.1.4":https://github.com/pat/thinking-sphinx/releases/tag/v3.1.4
9
10
  * "v3.1.3":https://github.com/pat/thinking-sphinx/releases/tag/v3.1.3
10
11
  * "v3.1.2":https://github.com/pat/thinking-sphinx/releases/tag/v3.1.2
11
12
  * "v3.1.1":https://github.com/pat/thinking-sphinx/releases/tag/v3.1.1
@@ -18,9 +19,9 @@ h2. Installation
18
19
 
19
20
  It's a gem, so install it like you would any other gem. You will also need to specify the mysql2 gem if you're using MRI, or jdbc-mysql if you're using JRuby:
20
21
 
21
- <pre><code>gem 'mysql2', '~> 0.3.13', :platform => :ruby
22
- gem 'jdbc-mysql', '~> 5.1.28', :platform => :jruby
23
- gem 'thinking-sphinx', '~> 3.1.3'</code></pre>
22
+ <pre><code>gem 'mysql2', '~> 0.3.18', :platform => :ruby
23
+ gem 'jdbc-mysql', '~> 5.1.35', :platform => :jruby
24
+ gem 'thinking-sphinx', '~> 3.1.4'</code></pre>
24
25
 
25
26
  The MySQL gems mentioned are required for connecting to Sphinx, so please include it even when you're using PostgreSQL for your database.
26
27
 
@@ -44,6 +45,8 @@ h3. Rails and ActiveRecord
44
45
 
45
46
  Currently Thinking Sphinx 3 is built to support Rails/ActiveRecord 3.2 or newer. If you're using Sinatra and ActiveRecord instead of Rails, that's fine - just make sure you add the @:require => 'thinking_sphinx/sinatra'@ option when listing @thinking-sphinx@ in your Gemfile.
46
47
 
48
+ Please note that if you're referring to polymorphic associations in your index definitions, you'll want to be using Rails/ActiveRecord 4.0 or newer. Supporting polymorphic associations and Rails/ActiveRecord 3.2 is problematic, and likely will not be addressed in the future.
49
+
47
50
  If you want ActiveRecord 3.1 support, then refer to the 3.0.x releases of Thinking Sphinx. Anything older than that, then you're stuck with Thinking Sphinx v2.x (for Rails/ActiveRecord 3.0) or v1.x (Rails 2.3). Please note that these older versions are no longer actively supported.
48
51
 
49
52
  h3. Ruby
@@ -58,6 +61,8 @@ MySQL 5.x and Postgres 8.4 or better are supported.
58
61
 
59
62
  h2. Contributing
60
63
 
64
+ 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.
65
+
61
66
  To contribute, clone this repository and have a good look through the specs - you'll notice the distinction between acceptance tests that actually use Sphinx and go through the full stack, and unit tests (everything else) which use liberal test doubles to ensure they're only testing the behaviour of the class in question. I've found this leads to far better code design.
62
67
 
63
68
  All development is done on the @develop@ branch; please base any pull requests off of that branch. Please write the tests and then the code to get them passing, and send through a pull request.
@@ -2,10 +2,10 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "mysql2", "~> 0.3.12b4", :platform=>:ruby
6
- gem "pg", "~> 0.16.0", :platform=>:ruby
7
- gem "activerecord-jdbcmysql-adapter", "~> 1.3.4", :platform=>:jruby
8
- gem "activerecord-jdbcpostgresql-adapter", "~> 1.3.4", :platform=>:jruby
5
+ gem "mysql2", "~> 0.3.12b4", :platform => :ruby
6
+ gem "pg", "~> 0.16.0", :platform => :ruby
7
+ gem "activerecord-jdbcmysql-adapter", "~> 1.3.4", :platform => :jruby
8
+ gem "activerecord-jdbcpostgresql-adapter", "~> 1.3.4", :platform => :jruby
9
9
  gem "rails", "~> 3.2.21"
10
10
 
11
- gemspec :path=>"../"
11
+ gemspec :path => "../"
@@ -2,10 +2,10 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "mysql2", "~> 0.3.12b4", :platform=>:ruby
6
- gem "pg", "~> 0.16.0", :platform=>:ruby
7
- gem "activerecord-jdbcmysql-adapter", "~> 1.3.4", :platform=>:jruby
8
- gem "activerecord-jdbcpostgresql-adapter", "~> 1.3.4", :platform=>:jruby
5
+ gem "mysql2", "~> 0.3.12b4", :platform => :ruby
6
+ gem "pg", "~> 0.16.0", :platform => :ruby
7
+ gem "activerecord-jdbcmysql-adapter", "~> 1.3.4", :platform => :jruby
8
+ gem "activerecord-jdbcpostgresql-adapter", "~> 1.3.4", :platform => :jruby
9
9
  gem "rails", "~> 4.0.12"
10
10
 
11
- gemspec :path=>"../"
11
+ gemspec :path => "../"
@@ -2,10 +2,10 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "mysql2", "~> 0.3.12b4", :platform=>:ruby
6
- gem "pg", "~> 0.16.0", :platform=>:ruby
7
- gem "activerecord-jdbcmysql-adapter", "~> 1.3.4", :platform=>:jruby
8
- gem "activerecord-jdbcpostgresql-adapter", "~> 1.3.4", :platform=>:jruby
5
+ gem "mysql2", "~> 0.3.12b4", :platform => :ruby
6
+ gem "pg", "~> 0.16.0", :platform => :ruby
7
+ gem "activerecord-jdbcmysql-adapter", "~> 1.3.4", :platform => :jruby
8
+ gem "activerecord-jdbcpostgresql-adapter", "~> 1.3.4", :platform => :jruby
9
9
  gem "rails", "~> 4.1.8"
10
10
 
11
- gemspec :path=>"../"
11
+ gemspec :path => "../"
@@ -2,10 +2,10 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "mysql2", "~> 0.3.12b4", :platform=>:ruby
6
- gem "pg", "~> 0.16.0", :platform=>:ruby
7
- gem "activerecord-jdbcmysql-adapter", "~> 1.3.4", :platform=>:jruby
8
- gem "activerecord-jdbcpostgresql-adapter", "~> 1.3.4", :platform=>:jruby
5
+ gem "mysql2", "~> 0.3.12b4", :platform => :ruby
6
+ gem "pg", "~> 0.16.0", :platform => :ruby
7
+ gem "activerecord-jdbcmysql-adapter", "~> 1.3.4", :platform => :jruby
8
+ gem "activerecord-jdbcpostgresql-adapter", "~> 1.3.4", :platform => :jruby
9
9
  gem "rails", "~> 4.2.0"
10
10
 
11
- gemspec :path=>"../"
11
+ gemspec :path => "../"
@@ -7,7 +7,8 @@ class ThinkingSphinx::ActiveRecord::Attribute::SphinxPresenter
7
7
  :string => :string,
8
8
  :bigint => :bigint,
9
9
  :ordinal => :str2ordinal,
10
- :wordcount => :str2wordcount
10
+ :wordcount => :str2wordcount,
11
+ :json => :json
11
12
  }
12
13
 
13
14
  def initialize(attribute, source)
@@ -13,7 +13,9 @@ class ThinkingSphinx::ActiveRecord::ColumnSQLPresenter
13
13
  return __name if string?
14
14
  return nil unless exists?
15
15
 
16
- "#{associations.alias_for(__stack)}.#{adapter.quote __name}"
16
+ quoted_table = escape_table? ? adapter.quote(table) : table
17
+
18
+ "#{quoted_table}.#{adapter.quote __name}"
17
19
  end
18
20
 
19
21
  private
@@ -22,6 +24,10 @@ class ThinkingSphinx::ActiveRecord::ColumnSQLPresenter
22
24
 
23
25
  delegate :__stack, :__name, :string?, :to => :column
24
26
 
27
+ def escape_table?
28
+ table[/[`"]/].nil?
29
+ end
30
+
25
31
  def exists?
26
32
  path.model.column_names.include?(column.__name.to_s)
27
33
  rescue Joiner::AssociationNotFound
@@ -31,4 +37,12 @@ class ThinkingSphinx::ActiveRecord::ColumnSQLPresenter
31
37
  def path
32
38
  Joiner::Path.new model, column.__stack
33
39
  end
40
+
41
+ def table
42
+ associations.alias_for __stack
43
+ end
44
+
45
+ def version
46
+ ActiveRecord::VERSION
47
+ end
34
48
  end
@@ -6,8 +6,9 @@ class ThinkingSphinx::ActiveRecord::FilterReflection
6
6
  def self.call(reflection, name, class_name)
7
7
  filter = new(reflection, class_name)
8
8
  klass = reflection.class
9
+ arity = klass.instance_method(:initialize).arity
9
10
 
10
- if defined?(ActiveRecord::Reflection::MacroReflection)
11
+ if defined?(ActiveRecord::Reflection::MacroReflection) && arity == 4
11
12
  klass.new name, filter.scope, filter.options, reflection.active_record
12
13
  elsif reflection.respond_to?(:scope)
13
14
  klass.new reflection.macro, name, filter.scope, filter.options,
@@ -39,10 +39,10 @@ class ThinkingSphinx::ActiveRecord::Interpreter <
39
39
  end
40
40
 
41
41
  def set_database(hash_or_key)
42
- configuration = hash_or_key.is_a?(::Hash) ? hash_or_key.symbolize_keys :
42
+ configuration = hash_or_key.is_a?(::Hash) ? hash_or_key :
43
43
  ::ActiveRecord::Base.configurations[hash_or_key.to_s]
44
44
 
45
- __source.set_database_settings configuration
45
+ __source.set_database_settings configuration.symbolize_keys
46
46
  end
47
47
 
48
48
  def set_property(properties)
@@ -16,10 +16,6 @@ module ThinkingSphinx
16
16
  statement.to_query_range_relation.to_sql
17
17
  end
18
18
 
19
- def sql_query_info
20
- statement.to_query_info_relation.to_sql
21
- end
22
-
23
19
  def sql_query_pre
24
20
  query.to_query
25
21
  end
@@ -96,10 +92,6 @@ module ThinkingSphinx
96
92
  "#{column} AS #{quoted_alias}"
97
93
  end
98
94
 
99
- def reversed_document_id
100
- "($id - #{source.offset}) / #{config.indices.count}"
101
- end
102
-
103
95
  def range_condition
104
96
  condition = []
105
97
  condition << "#{quoted_primary_key} BETWEEN $start AND $end" unless source.disable_range?
@@ -20,12 +20,6 @@ module ThinkingSphinx
20
20
  scope
21
21
  end
22
22
 
23
- def to_query_info_relation
24
- filter_by_query_info
25
-
26
- scope
27
- end
28
-
29
23
  def to_query_pre
30
24
  filter_by_query_pre
31
25
 
@@ -49,10 +43,6 @@ module ThinkingSphinx
49
43
  )
50
44
  end
51
45
 
52
- def filter_by_query_info
53
- @scope = scope.where("#{quoted_primary_key} = #{reversed_document_id}")
54
- end
55
-
56
46
  def filter_by_scopes
57
47
  scope_by_select
58
48
  scope_by_where_clause
@@ -140,10 +130,16 @@ module ThinkingSphinx
140
130
  builder.compose(
141
131
  presenters_to_group(field_presenters),
142
132
  presenters_to_group(attribute_presenters)
143
- ) unless source.options[:minimal_group_by?]
133
+ ) unless minimal_group_by?
144
134
 
145
135
  builder.compose(groupings).separated
146
136
  end
137
+
138
+ def minimal_group_by?
139
+ source.options[:minimal_group_by?] ||
140
+ config.settings['minimal_group_by?'] ||
141
+ config.settings['minimal_group_by']
142
+ end
147
143
  end
148
144
  end
149
145
  end
@@ -118,7 +118,6 @@ module ThinkingSphinx
118
118
  def build_sql_query
119
119
  @sql_query = builder.sql_query
120
120
  @sql_query_range ||= builder.sql_query_range
121
- @sql_query_info ||= builder.sql_query_info
122
121
  @sql_query_pre += builder.sql_query_pre
123
122
  @sql_query_post_index += builder.sql_query_post_index
124
123
  end
@@ -10,7 +10,6 @@ module ThinkingSphinx::Core::Index
10
10
  def initialize(reference, options = {})
11
11
  @reference = reference.to_sym
12
12
  @docinfo = :extern
13
- @charset_type = 'utf-8'
14
13
  @options = options
15
14
  @offset = config.next_offset(options[:offset_as] || reference)
16
15
  @type = 'plain'
@@ -21,6 +21,6 @@ class ThinkingSphinx::Guard::File
21
21
  end
22
22
 
23
23
  def unlock
24
- FileUtils.rm path
24
+ FileUtils.rm(path) if locked?
25
25
  end
26
26
  end
@@ -37,6 +37,8 @@ class ThinkingSphinx::Masks::PaginationMask
37
37
  search.current_page == 1 ? nil : search.current_page - 1
38
38
  end
39
39
 
40
+ alias_method :prev_page, :previous_page
41
+
40
42
  def total_entries
41
43
  search.meta['total_found'].to_i
42
44
  end
@@ -50,7 +50,7 @@ describe '64 bit document ids', :live => true do
50
50
  context 'with Real-Time' do
51
51
  it 'handles large 32 bit integers with an offset multiplier' do
52
52
  product = Product.create! :name => "Widget"
53
- product.update_attribute :id, 980190962
53
+ product.update_attributes :id => 980190962
54
54
  expect(
55
55
  Product.search('widget', :indices => ['product_core']).to_a
56
56
  ).to eq([product])
@@ -23,7 +23,7 @@ describe 'Accessing excerpts for methods on a search result', :live => true do
23
23
 
24
24
  search.first.excerpts.title.
25
25
  should == 'Война и <span class="match">миръ</span>'
26
- end
26
+ end if ENV['SPHINX_VERSION'].try :[], /2.2.\d/
27
27
 
28
28
  it "does not include class names in excerpts" do
29
29
  Book.create! :title => 'The Graveyard Book'
@@ -125,8 +125,8 @@ describe 'specifying SQL for index definitions' do
125
125
  query = index.sources.first.sql_query
126
126
  query.should match(/LEFT OUTER JOIN .articles. ON .articles.\..id. = .events.\..eventable_id. AND .events.\..eventable_type. = 'Article'/)
127
127
  query.should match(/LEFT OUTER JOIN .books. ON .books.\..id. = .events.\..eventable_id. AND .events.\..eventable_type. = 'Book'/)
128
- query.should match(/articles\..title., books\..title./)
129
- end
128
+ query.should match(/.articles.\..title., .books.\..title./)
129
+ end if ActiveRecord::VERSION::MAJOR > 3
130
130
 
131
131
  it "concatenates references that have column" do
132
132
  index = ThinkingSphinx::ActiveRecord::Index.new(:event)
@@ -139,8 +139,8 @@ describe 'specifying SQL for index definitions' do
139
139
  query = index.sources.first.sql_query
140
140
  query.should match(/LEFT OUTER JOIN .articles. ON .articles.\..id. = .events.\..eventable_id. AND .events.\..eventable_type. = 'Article'/)
141
141
  query.should_not match(/articles\..title., users\..title./)
142
- query.should match(/articles\..title./)
143
- end
142
+ query.should match(/.articles.\..title./)
143
+ end if ActiveRecord::VERSION::MAJOR > 3
144
144
 
145
145
  it "respects deeper associations through polymorphic joins" do
146
146
  index = ThinkingSphinx::ActiveRecord::Index.new(:event)
@@ -153,9 +153,9 @@ describe 'specifying SQL for index definitions' do
153
153
  query = index.sources.first.sql_query
154
154
  query.should match(/LEFT OUTER JOIN .articles. ON .articles.\..id. = .events.\..eventable_id. AND .events.\..eventable_type. = 'Article'/)
155
155
  query.should match(/LEFT OUTER JOIN .users. ON .users.\..id. = .articles.\..user_id./)
156
- query.should match(/users\..name./)
156
+ query.should match(/.users.\..name./)
157
157
  end
158
- end
158
+ end if ActiveRecord::VERSION::MAJOR > 3
159
159
 
160
160
  describe 'separate queries for MVAs' do
161
161
  let(:index) { ThinkingSphinx::ActiveRecord::Index.new(:article) }
@@ -244,7 +244,7 @@ describe 'separate queries for MVAs' do
244
244
 
245
245
  declaration.should == 'uint genre_ids from query'
246
246
  query.should match(/^SELECT .books_genres.\..book_id. \* #{count} \+ #{source.offset} AS .id., .books_genres.\..genre_id. AS .genre_ids. FROM .books_genres.\s?$/)
247
- end
247
+ end if ActiveRecord::VERSION::MAJOR > 3
248
248
 
249
249
  it "generates an appropriate range SQL queries for an MVA" do
250
250
  index.definition_block = Proc.new {
@@ -297,7 +297,7 @@ describe 'separate queries for MVAs' do
297
297
  declaration.should == 'uint genre_ids from ranged-query'
298
298
  query.should match(/^SELECT .books_genres.\..book_id. \* #{count} \+ #{source.offset} AS .id., .books_genres.\..genre_id. AS .genre_ids. FROM .books_genres. WHERE \(.books_genres.\..book_id. BETWEEN \$start AND \$end\)$/)
299
299
  range.should match(/^SELECT MIN\(.books_genres.\..book_id.\), MAX\(.books_genres.\..book_id.\) FROM .books_genres.$/)
300
- end
300
+ end if ActiveRecord::VERSION::MAJOR > 3
301
301
 
302
302
  it "respects custom SQL snippets as the query value" do
303
303
  index.definition_block = Proc.new {
@@ -139,6 +139,12 @@ describe ThinkingSphinx::ActiveRecord::Attribute::Type do
139
139
  type.type.should == :bigint
140
140
  end
141
141
 
142
+ it "detects JSON" do
143
+ db_column.stub :type => :json
144
+
145
+ type.type.should == :json
146
+ end
147
+
142
148
  it "respects provided type setting" do
143
149
  attribute.options[:type] = :timestamp
144
150
 
@@ -7,7 +7,9 @@ describe ThinkingSphinx::ActiveRecord::FilterReflection do
7
7
  :foreign_type => :foo_type, :class => reflection_klass) }
8
8
  let(:options) { {:polymorphic => true} }
9
9
  let(:filtered_reflection) { double 'filtered reflection' }
10
- let(:reflection_klass) { double :new => filtered_reflection }
10
+ let(:reflection_klass) { double :new => filtered_reflection,
11
+ :instance_method => initialize_method }
12
+ let(:initialize_method) { double :arity => 4 }
11
13
 
12
14
  before :each do
13
15
  reflection.active_record.stub_chain(:connection, :quote_column_name).
@@ -223,7 +223,7 @@ describe ThinkingSphinx::ActiveRecord::Interpreter do
223
223
  source.stub :set_database_settings => true
224
224
 
225
225
  stub_const 'ActiveRecord::Base',
226
- double(:configurations => {'other' => {:baz => :qux}})
226
+ double(:configurations => {'other' => {'baz' => 'qux'}})
227
227
  end
228
228
 
229
229
  it "sends through a hash if provided" do
@@ -233,13 +233,13 @@ describe ThinkingSphinx::ActiveRecord::Interpreter do
233
233
  end
234
234
 
235
235
  it "finds the environment settings if given a string key" do
236
- source.should_receive(:set_database_settings).with(:baz => :qux)
236
+ source.should_receive(:set_database_settings).with(:baz => 'qux')
237
237
 
238
238
  instance.set_database 'other'
239
239
  end
240
240
 
241
241
  it "finds the environment settings if given a symbol key" do
242
- source.should_receive(:set_database_settings).with(:baz => :qux)
242
+ source.should_receive(:set_database_settings).with(:baz => 'qux')
243
243
 
244
244
  instance.set_database :other
245
245
  end
@@ -415,6 +415,55 @@ describe ThinkingSphinx::ActiveRecord::SQLBuilder do
415
415
  end
416
416
  end
417
417
 
418
+ context 'group by shortcut in global configuration' do
419
+ before :each do
420
+ config.settings['minimal_group_by'] = true
421
+ end
422
+
423
+ it "groups by the primary key" do
424
+ relation.should_receive(:group) do |string|
425
+ string.should match(/"users"."id"/)
426
+ relation
427
+ end
428
+
429
+ builder.sql_query
430
+ end
431
+
432
+ it "does not group by fields" do
433
+ source.fields << double('field')
434
+
435
+ relation.should_receive(:group) do |string|
436
+ string.should_not match(/"name"/)
437
+ relation
438
+ end
439
+
440
+ builder.sql_query
441
+ end
442
+
443
+ it "does not group by attributes" do
444
+ source.attributes << double('attribute')
445
+ presenter.stub!(:to_group => '"created_at"')
446
+
447
+ relation.should_receive(:group) do |string|
448
+ string.should_not match(/"created_at"/)
449
+ relation
450
+ end
451
+
452
+ builder.sql_query
453
+ end
454
+
455
+ it "groups by source groupings" do
456
+ source.groupings << '"latitude"'
457
+
458
+ relation.should_receive(:group) do |string|
459
+ string.should match(/"latitude"/)
460
+ relation
461
+ end
462
+
463
+ builder.sql_query
464
+ end
465
+ end
466
+
418
467
  context 'STI model' do
419
468
  before :each do
420
469
  model.column_names << 'type'
@@ -469,22 +518,6 @@ describe ThinkingSphinx::ActiveRecord::SQLBuilder do
469
518
  end
470
519
  end
471
520
 
472
- describe 'sql_query_info' do
473
- it "filters on the reversed document id" do
474
- relation.should_receive(:where).
475
- with("`users`.`id` = ($id - #{source.offset}) / #{indices.count}").
476
- and_return(relation)
477
-
478
- builder.sql_query_info
479
- end
480
-
481
- it "returns the generated SQL query" do
482
- relation.stub(:to_sql).and_return('SELECT * FROM people WHERE id = $id')
483
-
484
- builder.sql_query_info.should == 'SELECT * FROM people WHERE id = $id'
485
- end
486
- end
487
-
488
521
  describe 'sql_query_post_index' do
489
522
  let(:processor) { double('processor', :reset_query => 'RESET DELTAS') }
490
523
 
@@ -186,14 +186,6 @@ describe ThinkingSphinx::ActiveRecord::SQLSource do
186
186
  source.sql_query_range.should == 'select 0, 10 from table'
187
187
  end
188
188
 
189
- it "uses the builder's sql_query_info value" do
190
- builder.stub! :sql_query_info => 'select * from table where id = ?'
191
-
192
- source.render
193
-
194
- source.sql_query_info.should == 'select * from table where id = ?'
195
- end
196
-
197
189
  it "appends the builder's sql_query_pre value" do
198
190
  builder.stub! :sql_query_pre => ['Change Setting']
199
191
 
@@ -333,6 +325,15 @@ describe ThinkingSphinx::ActiveRecord::SQLSource do
333
325
  source.sql_attr_str2wordcount.should include('name')
334
326
  end
335
327
 
328
+ it "adds json attributes to sql_attr_json" do
329
+ source.attributes << double('attribute')
330
+ presenter.stub :declaration => 'json', :collection_type => :json
331
+
332
+ source.render
333
+
334
+ source.sql_attr_json.should include('json')
335
+ end
336
+
336
337
  it "adds relevant settings from thinking_sphinx.yml" do
337
338
  config.settings['mysql_ssl_cert'] = 'foo.cert'
338
339
  config.settings['morphology'] = 'stem_en' # should be ignored
@@ -3,11 +3,11 @@ $:.push File.expand_path('../lib', __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = 'thinking-sphinx'
6
- s.version = '3.1.3'
6
+ s.version = '3.1.4'
7
7
  s.platform = Gem::Platform::RUBY
8
8
  s.authors = ["Pat Allan"]
9
9
  s.email = ["pat@freelancing-gods.com"]
10
- s.homepage = 'http://pat.github.io/thinking-sphinx/'
10
+ s.homepage = 'https://pat.github.io/thinking-sphinx/'
11
11
  s.summary = 'A smart wrapper over Sphinx for ActiveRecord'
12
12
  s.description = %Q{An intelligent layer for ActiveRecord (via Rails and Sinatra) for the Sphinx full-text search tool.}
13
13
  s.license = 'MIT'
@@ -28,7 +28,7 @@ Gem::Specification.new do |s|
28
28
  s.add_runtime_dependency 'innertube', '>= 1.0.2'
29
29
  s.add_runtime_dependency 'riddle', '>= 1.5.11'
30
30
 
31
- s.add_development_dependency 'appraisal', '~> 0.5.2'
31
+ s.add_development_dependency 'appraisal', '~> 1.0.2'
32
32
  s.add_development_dependency 'combustion', '~> 0.4.0'
33
33
  s.add_development_dependency 'database_cleaner', '~> 1.2.0'
34
34
  s.add_development_dependency 'rspec', '~> 2.13.0'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thinking-sphinx
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.3
4
+ version: 3.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pat Allan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-21 00:00:00.000000000 Z
11
+ date: 2015-06-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -100,14 +100,14 @@ dependencies:
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: 0.5.2
103
+ version: 1.0.2
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: 0.5.2
110
+ version: 1.0.2
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: combustion
113
113
  requirement: !ruby/object:Gem::Requirement
@@ -423,7 +423,7 @@ files:
423
423
  - spec/thinking_sphinx/wildcard_spec.rb
424
424
  - spec/thinking_sphinx_spec.rb
425
425
  - thinking-sphinx.gemspec
426
- homepage: http://pat.github.io/thinking-sphinx/
426
+ homepage: https://pat.github.io/thinking-sphinx/
427
427
  licenses:
428
428
  - MIT
429
429
  metadata: {}