Skip to content

Commit

Permalink
FIX: symbol param encoder not working (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
xronos-i-am authored and SamSaffron committed Jan 16, 2020
1 parent 8edd265 commit b5e4c62
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/mini_sql/inline_param_encoder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def quote_val(value)
when BigDecimal then value.to_s("F")
when Numeric then value.to_s
when Date, Time then "'#{quoted_date(value)}'"
when Symbol then "'#{escape_string(value.to_s)}'"
when Symbol then "'#{conn.escape_string(value.to_s)}'"
else raise TypeError, "can't quote #{value.class.name}"
end
end
Expand Down
5 changes: 5 additions & 0 deletions test/mini_sql/inline_param_encoder_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ def test_string_encoding
assert_equal("select 'hello''s'", result)
end

def test_symbol_encoding
result = @encoder.encode("select :str", str: :value)
assert_equal("select 'value'", result)
end

def test_array_encoding
result = @encoder.encode("select :str", str: ["a", "a'"])
assert_equal("select 'a', 'a'''", result)
Expand Down

0 comments on commit b5e4c62

Please sign in to comment.