Sha256: 6e840c6af978441318ef92522b3f79cfe65dd46487376ad7a1c5e3533c2e056d
Contents?: true
Size: 1.81 KB
Versions: 5
Compression:
Stored size: 1.81 KB
Contents
class Card class Query module Attributes def found_by val found_by_cards(val).compact.each do |c| if c && [SearchTypeID, SetID].include?(c.type_id) # FIXME: - move this check to set mods! subquery( c.wql_hash.merge(unjoined: true, context: c.name) ) else raise Card::Error::BadQuery, '"found_by" value must be valid Search, ' \ "but #{c.name} is a #{c.type_name}" end end end def found_by_cards val if val.is_a? Hash Query.run val else Array.wrap(val).map do |v| Card.fetch v.to_name.to_absolute(context), new: {} end end end def match val cxn, val = match_prep val val.gsub!(/[^#{Card::Name::OK4KEY_RE}]+/, " ") return nil if val.strip.empty? val_list = val.split(/\s+/).map do |v| name_or_content = [ "replace(#{table_alias}.name,'+',' ')", "#{table_alias}.db_content" ].map do |field| %(#{field} #{cxn.match quote("[[:<:]]#{v}[[:>:]]")}) end "(#{name_or_content.join ' OR '})" end add_condition "(#{val_list.join ' AND '})" end def complete val no_plus_card = (val =~ /\+/ ? "" : "and right_id is null") # FIXME: -- this should really be more nuanced -- # it breaks down after one plus add_condition( " lower(#{table_alias}.name) LIKE" \ " lower(#{quote(val.to_s + '%')}) #{no_plus_card}" ) end def extension_type _val # DEPRECATED LONG AGO!!! Rails.logger.info "using DEPRECATED extension_type in WQL" interpret right_plus: AccountID end end end end
Version data entries
5 entries across 5 versions & 1 rubygems