Skip to content

Commit

Permalink
sql: fix decode of boolean binding value
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Korablev77 committed Nov 27, 2019
1 parent 6da9d39 commit abc08ca
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/box/lua/execute.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit abc08ca

Please sign in to comment.