Skip to content

Commit

Permalink
Use uints for all timestamps.
Browse files Browse the repository at this point in the history
Sphinx 3.3 removes all the timestamp attribute types in favour for uints. Functionally, it’s the same behaviour from Thinking Sphinx’s perspective anyway, as times are being translated into UNIX timestamp integers.
  • Loading branch information
pat committed Jul 24, 2020
1 parent cb7ae4c commit 57b09c7
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class ThinkingSphinx::ActiveRecord::Attribute::SphinxPresenter
SPHINX_TYPES = {
:integer => :uint,
:boolean => :bool,
:timestamp => :timestamp,
:timestamp => :uint,
:float => :float,
:string => :string,
:bigint => :bigint,
Expand Down
4 changes: 1 addition & 3 deletions lib/thinking_sphinx/real_time/index.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,10 @@ def append_unique_attribute(collection, attribute)

def collection_for(attribute)
case attribute.type
when :integer, :boolean
when :integer, :boolean, :timestamp
attribute.multi? ? @rt_attr_multi : @rt_attr_uint
when :string
@rt_attr_string
when :timestamp
@rt_attr_timestamp
when :float
@rt_attr_float
when :bigint
Expand Down
6 changes: 3 additions & 3 deletions spec/thinking_sphinx/active_record/sql_source_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -325,14 +325,14 @@
expect(source.sql_attr_string).to include('name')
end

it "adds timestamp attributes to sql_attr_timestamp" do
it "adds timestamp attributes to sql_attr_uint" do
source.attributes << double('attribute')
allow(presenter).to receive_messages :declaration => 'created_at',
:collection_type => :timestamp
:collection_type => :uint

source.render

expect(source.sql_attr_timestamp).to include('created_at')
expect(source.sql_attr_uint).to include('created_at')
end

it "adds float attributes to sql_attr_float" do
Expand Down

0 comments on commit 57b09c7

Please sign in to comment.