Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

encode(Val, binary, _) when is_float(Val) returns list instead of binary #47

Closed
IvanYuilop opened this issue Nov 7, 2012 · 3 comments
Closed
Assignees

Comments

@IvanYuilop
Copy link

The function in line 224 of emysql_util.erl returns a list when it should return a binary. This bug makes line 240 of emysql_conn.erl to fail when updating a table with a float value:

(energyservice_node@127.0.0.1)12> emysql:execute(api_pool, update_activity_r, [0, 190.5, 293209]).
16:43:36.441 [error] Lager event handler error_logger_lager_h exited with reason {'EXIT',{function_clause,[{lager,log,[error,emulator,["Error in process <0.314.0> on node 'energyservice_node@127.0.0.1' with exit value: {badarg,[{erlang,byte_size,["190.5"],[]},{emysql_conn,set_params,4,[{file,"src/emysql_conn.erl"},{line,240}]},{emysql_conn,execute,3,[{file,"src/emysql_conn.erl"},{line,82}]},{emysql,'-monitor_work/3-fun-0-',4,[{file,"src/emysql... \n","\n"]],[{file,"src/lager.erl"},{line,86}]},{error_logger_lager_h,handle_event,2,[{file,"src/error_logger_lager_h.erl"},...]},...]}}
16:43:36.504 [debug] Lager installed handler error_logger_lager_h into error_logger
** exception exit: {{badarg,[{erlang,byte_size,["190.5"],[]},
{emysql_conn,set_params,4,
[{file,"src/emysql_conn.erl"},{line,240}]},
{emysql_conn,execute,3,
[{file,"src/emysql_conn.erl"},{line,82}]},
{emysql,'-monitor_work/3-fun-0-',4,
[{file,"src/emysql.erl"},{line,567}]}]},
{}}
in function emysql:monitor_work/3 (src/emysql.erl, line 592)

This bug can be fixed by simply changing line 226 of emysql_util.erl to:

list_to_binary(Res);

AFAIK this bug was first spotted by valinurovam:

#39

@jeremyong
Copy link

+1 Not being able to handle floats in prepared statements is somewhat of a nuisance.

@IvanYuilop
Copy link
Author

Hopefully fixed in #59

@jlouis
Copy link
Collaborator

jlouis commented Apr 24, 2013

Fixed with pull request #59, and in order to make things easier on us, let us further discuss the issue in that ticket number.

manuel-rubio pushed a commit to altenwald/Emysql that referenced this issue Apr 14, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants