Treat atom 'undefined' as null

This commit is contained in:
Alexey Romanov
2011-03-21 11:22:34 +03:00
parent 6b9523d7d3
commit 1688f763f0

View File

@@ -72,6 +72,7 @@ value_to_sql_unsafe(X) ->
case X of case X of
_ when is_integer(X) -> integer_to_list(X); _ when is_integer(X) -> integer_to_list(X);
_ when is_float(X) -> float_to_list(X); _ when is_float(X) -> float_to_list(X);
undefined -> "NULL"
?NULL_ATOM -> "NULL"; ?NULL_ATOM -> "NULL";
{blob, Blob} -> ["x'", bin_to_hex(Blob), $']; {blob, Blob} -> ["x'", bin_to_hex(Blob), $'];
_ -> [$', unicode:characters_to_binary(X), $'] %% assumes no $' inside strings! _ -> [$', unicode:characters_to_binary(X), $'] %% assumes no $' inside strings!
@@ -92,6 +93,7 @@ value_to_sql(X) ->
case X of case X of
_ when is_integer(X) -> integer_to_list(X); _ when is_integer(X) -> integer_to_list(X);
_ when is_float(X) -> float_to_list(X); _ when is_float(X) -> float_to_list(X);
undefined -> "NULL"
?NULL_ATOM -> "NULL"; ?NULL_ATOM -> "NULL";
{blob, Blob} -> ["x'", bin_to_hex(Blob), $']; {blob, Blob} -> ["x'", bin_to_hex(Blob), $'];
_ -> [$', unicode:characters_to_binary(escape(X)), $'] _ -> [$', unicode:characters_to_binary(escape(X)), $']