Sha256: ed0ed14a988ee34457d4cffbf7fa480c056c11da0a53cc1997ba9c8e65b14201
Contents?: true
Size: 1.63 KB
Versions: 2
Compression:
Stored size: 1.63 KB
Contents
module SearchCop module Visitors module Mysql # rubocop:disable Naming/MethodName def visit_SearchCopGrammar_Attributes_Json(attribute) "#{quote_table_name attribute.table_alias}.#{quote_column_name attribute.column_name}->#{quote "$.#{attribute.field_names.join(".")}"}" end class FulltextQuery < Visitor def visit_SearchCopGrammar_Nodes_MatchesFulltextNot(node) node.right.split(/[\s+'"<>()~-]+/).collect { |word| "-#{word}" }.join(" ") end def visit_SearchCopGrammar_Nodes_MatchesFulltext(node) words = node.right.split(/[\s+'"<>()~-]+/) words.size > 1 ? "\"#{words.join " "}\"" : words.first end def visit_SearchCopGrammar_Nodes_And_Fulltext(node) res = node.nodes.collect do |child_node| if child_node.is_a?(SearchCopGrammar::Nodes::MatchesFulltextNot) visit child_node else child_node.nodes.size > 1 ? "+(#{visit child_node})" : "+#{visit child_node}" end end res.join " " end def visit_SearchCopGrammar_Nodes_Or_Fulltext(node) node.nodes.collect { |child_node| "(#{visit child_node})" }.join(" ") end end def visit_SearchCopGrammar_Attributes_Collection(node) node.attributes.collect { |attribute| visit attribute }.join(", ") end def visit_SearchCopGrammar_Nodes_FulltextExpression(node) "MATCH(#{visit node.collection}) AGAINST(#{visit FulltextQuery.new(connection).visit(node.node)} IN BOOLEAN MODE)" end # rubocop:enable Naming/MethodName end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
search_cop-1.4.0 | lib/search_cop/visitors/mysql.rb |
search_cop-1.3.0 | lib/search_cop/visitors/mysql.rb |