From abc08ca7165d9d5a430e9240a7cfeee0849edbe1 Mon Sep 17 00:00:00 2001 From: Nikita Pettik <korablev@tarantool.org> Date: Wed, 27 Nov 2019 12:34:05 +0300 Subject: [PATCH] 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. --- src/box/lua/execute.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/box/lua/execute.c b/src/box/lua/execute.c index 76ecdd541b..ffa3d4d2e3 100644 --- a/src/box/lua/execute.c +++ b/src/box/lua/execute.c @@ -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); -- GitLab