From 421ae6d32e66a15946344db5970eb25438952aa3 Mon Sep 17 00:00:00 2001 From: Loic Nageleisen Date: Wed, 1 Mar 2017 16:51:07 +0100 Subject: [PATCH] extract dummy escape --- lib/rebel/sql.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/rebel/sql.rb b/lib/rebel/sql.rb index 587996b..90833e0 100644 --- a/lib/rebel/sql.rb +++ b/lib/rebel/sql.rb @@ -258,10 +258,14 @@ module Rebel::SQL items.join(', ') end + def escape_str(str) + str.tr(@string_quote, @escaped_string_quote) + end + def value(v) case v when Raw then v - when String then raw "'#{v.tr(@string_quote, @escaped_string_quote)}'" + when String then raw "'#{escape_str(v)}'" when Integer then raw v.to_s when nil then raw 'NULL' else raise NotImplementedError, v.inspect