Skip to content
Snippets Groups Projects
Commit abc08ca7 authored by Nikita Pettik's avatar Nikita Pettik
Browse files

sql: fix decode of boolean binding value

Some time ago, when there was no support of boolean type in SQL, boolean
values passed as parameters to be bound were converted to integer values
0 and 1. It takes place in lua_sql_bind_decode(). However, now we can
avoid this conversion and store booleans as booleans. Note that patch
does not include test case since type of value is preserved correctly,
so when binding is extracted from struct sql_bind it will assigned to
the right value.
parent 6da9d395
No related branches found
No related tags found
No related merge requests found
......@@ -173,9 +173,8 @@ lua_sql_bind_decode(struct lua_State *L, struct sql_bind *bind, int idx, int i)
bind->bytes = 1;
break;
case MP_BOOL:
/* SQLite doesn't support boolean. Use int instead. */
bind->i64 = field.bval ? 1 : 0;
bind->bytes = sizeof(bind->i64);
bind->b = field.bval;
bind->bytes = sizeof(bind->b);
break;
case MP_BIN:
bind->s = mp_decode_bin(&field.sval.data, &bind->bytes);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment