Fix handling of default values
This commit is contained in:
@@ -336,12 +336,18 @@ sql_number(NumberStr) ->
|
|||||||
end
|
end
|
||||||
end.
|
end.
|
||||||
|
|
||||||
-spec sql_string(string()) -> string().
|
-spec sql_string(string()) -> binary().
|
||||||
sql_string(StringWithEscapedQuotes) ->
|
sql_string(StringWithEscapedQuotes) ->
|
||||||
re:replace(StringWithEscapedQuotes, "'(?!')", "", [global, {return, list}]).
|
Res1 = re:replace(StringWithEscapedQuotes, "''", "'", [global, {return, binary}]),
|
||||||
|
binary_part(Res1, 0, byte_size(Res1) - 1).
|
||||||
|
|
||||||
-spec sql_blob(string()) -> string().
|
-spec sql_blob(string()) -> binary().
|
||||||
sql_blob(Blob) -> Blob.
|
sql_blob([$' | Tail]) -> hex_str_to_bin(Tail, <<>>).
|
||||||
|
|
||||||
|
hex_str_to_bin("'", Acc) ->
|
||||||
|
Acc; %% single quote at the end of blob literal
|
||||||
|
hex_str_to_bin([X, Y | Tail], Acc) ->
|
||||||
|
hex_str_to_bin(Tail, <<Acc/binary, (X * 16 + Y)>>).
|
||||||
|
|
||||||
column_sql_for_create_table({Name, Type}) ->
|
column_sql_for_create_table({Name, Type}) ->
|
||||||
[atom_to_list(Name), " ", col_type_to_string(Type)];
|
[atom_to_list(Name), " ", col_type_to_string(Type)];
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ select_many_records_test() ->
|
|||||||
sqlite3:open(ct),
|
sqlite3:open(ct),
|
||||||
drop_table_if_exists(ct, many_records),
|
drop_table_if_exists(ct, many_records),
|
||||||
sqlite3:create_table(ct, many_records, [{id, integer}, {name, text}]),
|
sqlite3:create_table(ct, many_records, [{id, integer}, {name, text}]),
|
||||||
[sqlite3:write(ct, many_records, [{id, X}, {name, "bar"}]) || X <- Seq],
|
[sqlite3:write(ct, many_records, [{id, X}, {name, "bar"}]) || X <- lists:seq(1, 1024)], %% takes very long :(
|
||||||
Columns = ["id", "name"],
|
Columns = ["id", "name"],
|
||||||
?assertEqual(
|
?assertEqual(
|
||||||
[{columns, Columns}, {rows, [{1, <<"bar">>}]}],
|
[{columns, Columns}, {rows, [{1, <<"bar">>}]}],
|
||||||
|
|||||||
Reference in New Issue
Block a user