Permalink
Browse files

Try to fix problem with large identifiers for Postgres

  • Loading branch information...
1 parent 088d9aa commit 5e089867fd8a600734a9090a37649c4dae971781 @tonic20 committed Mar 28, 2011
Showing with 18 additions and 16 deletions.
  1. +1 −0 .gitignore
  2. +17 −16 lib/thinking_sphinx.rb
View
@@ -9,3 +9,4 @@ rdoc
database.yml
tmp
*.gem
+*~
@@ -33,7 +33,7 @@
module ThinkingSphinx
mattr_accessor :database_adapter
-
+
# A ConnectionError will get thrown when a connection to Sphinx can't be
# made.
class ConnectionError < StandardError
@@ -47,7 +47,7 @@ def initialize(ids)
self.ids = ids
end
end
-
+
# A SphinxError occurs when Sphinx responds with an error due to problematic
# queries or indexes.
class SphinxError < RuntimeError
@@ -57,23 +57,23 @@ def initialize(message = nil, results = nil)
self.results = results
end
end
-
+
# The current version of Thinking Sphinx.
- #
+ #
# @return [String] The version number as a string
- #
+ #
def self.version
open(File.join(File.dirname(__FILE__), '../VERSION')) { |f|
f.read.strip
}
end
-
+
# The collection of indexed models. Keep in mind that Rails lazily loads
# its classes, so this may not actually be populated with _all_ the models
# that have Sphinx indexes.
@@sphinx_mutex = Mutex.new
@@context = nil
-
+
def self.context
if @@context.nil?
@@sphinx_mutex.synchronize do
@@ -83,18 +83,18 @@ def self.context
end
end
end
-
+
@@context
end
-
+
def self.reset_context!
@@sphinx_mutex.synchronize do
@@context = nil
end
end
def self.unique_id_expression(offset = nil)
- "* #{context.indexed_models.size} + #{offset || 0}"
+ "* #{context.indexed_models.size}::INT8 + #{offset || 0}"
end
# Check if index definition is disabled.
@@ -103,7 +103,7 @@ def self.define_indexes?
if Thread.current[:thinking_sphinx_define_indexes].nil?
Thread.current[:thinking_sphinx_define_indexes] = true
end
-
+
Thread.current[:thinking_sphinx_define_indexes]
end
@@ -123,7 +123,7 @@ def self.deltas_enabled?
ThinkingSphinx::Configuration.environment != "test"
)
end
-
+
Thread.current[:thinking_sphinx_deltas_enabled]
end
@@ -144,7 +144,7 @@ def self.updates_enabled?
ThinkingSphinx::Configuration.environment != "test"
)
end
-
+
Thread.current[:thinking_sphinx_updates_enabled]
end
@@ -163,7 +163,7 @@ def self.suppress_delta_output?
def self.suppress_delta_output=(value)
Thread.current[:thinking_sphinx_suppress_delta_output] = value
end
-
+
# Checks to see if MySQL will allow simplistic GROUP BY statements. If not,
# or if not using MySQL, this will return false.
#
@@ -175,7 +175,7 @@ def self.use_group_by_shortcut?
).all? { |key,value| value.nil? || value[/ONLY_FULL_GROUP_BY/].nil? }
)
end
-
+
Thread.current[:thinking_sphinx_use_group_by_shortcut]
end
@@ -243,8 +243,9 @@ def self.mysql?
jruby? && ::ActiveRecord::Base.connection.config[:adapter] == "jdbcmysql"
)
end
-
+
extend ThinkingSphinx::SearchMethods::ClassMethods
end
ThinkingSphinx::AutoVersion.detect
+

0 comments on commit 5e08986

Please sign in to comment.