lib/riddle/query.rb in riddle-1.5.4 vs lib/riddle/query.rb in riddle-1.5.5
- old
+ new
@@ -56,10 +56,13 @@
values = "(#{values.join(', ')})" if values.is_a?(Array)
"SET#{ ' GLOBAL' if global } #{variable} = #{values}"
end
def self.snippets(data, index, query, options = nil)
+ data.gsub!("'") { |x| "\\'" }
+ query.gsub!("'") { |x| "\\'" }
+
options = ', ' + options.keys.collect { |key|
value = options[key]
value = "'#{value}'" if value.is_a?(String)
"#{value} AS #{key}"
@@ -92,9 +95,17 @@
when FalseClass
0
else
value
end
+ end
+
+ def self.escape(string)
+ string.gsub("\\") { |match|
+ "\\\\"
+ }.gsub(/[\(\)\|\-!@~"\/\^\$]/) { |match|
+ "\\\\#{match}"
+ }
end
end
require 'riddle/query/delete'
require 'riddle/query/insert'