From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtpng1.m.smailru.net (smtpng1.m.smailru.net [94.100.181.251]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 4B82D4003E9 for ; Mon, 28 Oct 2019 00:29:45 +0300 (MSK) From: Vladislav Shpilevoy Date: Sun, 27 Oct 2019 22:35:07 +0100 Message-Id: <1d9e23e51b37ba689da164526807bdab3e097649.1572211914.git.v.shpilevoy@tarantool.org> In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH 1/3] sql: LENGTH function accepts boolean List-Id: Tarantool development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: tarantool-patches@dev.tarantool.org, korablev@tarantool.org Cc: tarantool-patches@freelists.org Before the patch LENGTH didn't take boolean argument into account. Now it does and treats like any other non-string argument - stringify and calculate length. It is worth mentioning, that in future LENGTH will discard any non-string argument, see #3929. Part of #4462 --- src/box/sql/func.c | 1 + test/sql/boolean.result | 5 +++-- test/sql/boolean.test.sql | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/box/sql/func.c b/src/box/sql/func.c index d5ea0fe6a..12a4bee04 100644 --- a/src/box/sql/func.c +++ b/src/box/sql/func.c @@ -458,6 +458,7 @@ lengthFunc(sql_context * context, int argc, sql_value ** argv) case MP_BIN: case MP_INT: case MP_UINT: + case MP_BOOL: case MP_DOUBLE:{ sql_result_uint(context, sql_value_bytes(argv[0])); break; diff --git a/test/sql/boolean.result b/test/sql/boolean.result index 352649136..ac9f7fcaf 100644 --- a/test/sql/boolean.result +++ b/test/sql/boolean.result @@ -311,14 +311,15 @@ SELECT quote(a) FROM t0; | - ['NULL'] | - ['NULL'] | ... +-- gh-4462: LENGTH didn't take BOOLEAN arguments. SELECT length(a) FROM t0; | --- | - metadata: | - name: length(a) | type: integer | rows: - | - [null] - | - [null] + | - [5] + | - [4] | - [null] | - [null] | ... diff --git a/test/sql/boolean.test.sql b/test/sql/boolean.test.sql index 9d71139fd..68a05852f 100644 --- a/test/sql/boolean.test.sql +++ b/test/sql/boolean.test.sql @@ -82,6 +82,7 @@ SELECT abs(a) FROM t0; SELECT lower(a) FROM t0; SELECT upper(a) FROM t0; SELECT quote(a) FROM t0; +-- gh-4462: LENGTH didn't take BOOLEAN arguments. SELECT length(a) FROM t0; SELECT typeof(a) FROM t0; -- 2.21.0 (Apple Git-122)