From 118b006cac1b97f30d15935cb44ffd3cc688ebd4 Mon Sep 17 00:00:00 2001 From: Brendon Hogger Date: Tue, 21 Feb 2012 06:30:30 +0800 Subject: [PATCH] Handle NULL<->undefined correctly in gen_storage_odbc --- src/gen_storage_odbc.erl | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/gen_storage_odbc.erl b/src/gen_storage_odbc.erl index 5702df05f..c282f063a 100644 --- a/src/gen_storage_odbc.erl +++ b/src/gen_storage_odbc.erl @@ -423,6 +423,9 @@ rows_to_result(#tabdef{record_name = RecordName, row_to_result(Row, [], Result) -> {Row, lists:reverse(Result)}; + +row_to_result([null | Row], [_ | Types], Result) -> + row_to_result(Row, Types, [undefined | Result]); row_to_result([Field | Row], [Type | Types], Result) -> case Type of int -> @@ -649,6 +652,10 @@ format(I) when is_integer(I) -> %% escaping not needed integer_to_list(I); + +format(undefined) -> + "NULL"; + format(A) when is_atom(A) -> %% escaping usually not needed, watch atom() usage "'" ++ atom_to_list(A) ++ "'";