lib/thinking_sphinx/adapters/postgresql_adapter.rb in dpickett-thinking-sphinx-1.1.4 vs lib/thinking_sphinx/adapters/postgresql_adapter.rb in dpickett-thinking-sphinx-1.1.12

- old
+ new

@@ -9,11 +9,11 @@ "pgsql" end def concatenate(clause, separator = ' ') clause.split(', ').collect { |field| - "COALESCE(#{field}, '')" + "COALESCE(CAST(#{field} as varchar), '')" }.join(" || '#{separator}' || ") end def group_concatenate(clause, separator = ' ') "array_to_string(array_accum(#{clause}), '#{separator}')" @@ -39,11 +39,12 @@ def boolean(value) value ? 'TRUE' : 'FALSE' end - def crc(clause) + def crc(clause, blank_to_null = false) + clause = "NULLIF(#{clause},'')" if blank_to_null "crc32(#{clause})" end def utf8_query_pre nil @@ -67,10 +68,10 @@ connection.execute "release savepoint ts" connection.execute "commit" end def create_array_accum_function - if connection.raw_connection.server_version > 80200 + if connection.raw_connection.respond_to?(:server_version) && connection.raw_connection.server_version > 80200 execute <<-SQL CREATE AGGREGATE array_accum (anyelement) ( sfunc = array_append, stype = anyarray, \ No newline at end of file