module DbTextSearch::QueryBuilding
Common methods for building SQL that use @scope and @column instance variables. @api private
Public Instance Methods
sanitize_sql_like(string, escape_character = '\\')
click to toggle source
@return [String] SQL-quoted string suitable for use in a LIKE statement, with % and _ escaped.
# File lib/db_text_search/query_building.rb, line 12 def sanitize_sql_like(string, escape_character = '\\') pattern = Regexp.union(escape_character, '%', '_') string.gsub(pattern) { |x| [escape_character, x].join } end
Protected Instance Methods
quoted_column()
click to toggle source
@return [String] SQL-quoted column (without the table name).
# File lib/db_text_search/query_building.rb, line 25 def quoted_column @scope.connection.quote_column_name(@column) end
quoted_scope_column()
click to toggle source
@return [String] SQL-quoted column fully-qualified with the scope table name.
# File lib/db_text_search/query_building.rb, line 30 def quoted_scope_column "#{quoted_scope_table}.#{quoted_column}" end
quoted_scope_table()
click to toggle source
@return [String] SQL-quoted scope table name.
# File lib/db_text_search/query_building.rb, line 20 def quoted_scope_table @scope.connection.quote_table_name(@scope.table_name) end