Sha256: 0af1deb4896b4340ff1d9a72b7693d4fa7026527c8f2d8eb23fa9b6962f25d4c
Contents?: true
Size: 975 Bytes
Versions: 2
Compression:
Stored size: 975 Bytes
Contents
class ThinkingSphinx::ActiveRecord::SimpleManyQuery < ThinkingSphinx::ActiveRecord::PropertyQuery def to_s "#{identifier} from #{source_type}; #{queries.join('; ')}" end private def reflection @reflection ||= source.model.reflections[column.__stack.first] end def quoted_foreign_key quote_with_table reflection.join_table, reflection.foreign_key end def quoted_primary_key quote_with_table reflection.join_table, reflection.association_foreign_key end def range_sql "SELECT MIN(#{quoted_foreign_key}), MAX(#{quoted_foreign_key}) FROM #{quote_column reflection.join_table}" end def to_sql selects = [ "#{quoted_foreign_key} #{offset} AS #{quote_column('id')}", "#{quoted_primary_key} AS #{quote_column(property.name)}" ] sql = "SELECT #{selects.join(', ')} FROM #{quote_column reflection.join_table}" sql += " WHERE (#{quoted_foreign_key} BETWEEN $start AND $end)" if ranged? sql end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
thinking-sphinx-3.1.2 | lib/thinking_sphinx/active_record/simple_many_query.rb |
thinking-sphinx-3.1.1 | lib/thinking_sphinx/active_record/simple_many_query.rb |