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 D48C4401A42 for ; Mon, 28 Oct 2019 00:29:45 +0300 (MSK) From: Vladislav Shpilevoy Date: Sun, 27 Oct 2019 22:35:08 +0100 Message-Id: <8260c85a5b81a174b45b101c2e9ad5d251e7420f.1572211914.git.v.shpilevoy@tarantool.org> In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH 2/3] sql: CAST( AS TEXT) returns lowercase 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 Implicit cast uses lowercase, and the patch makes the explicit cast the same. No any special reason behind that. Lower case is already used much more often, so it is easier to drop the upper case. Part of #4462 --- src/box/sql/vdbemem.c | 2 +- test/sql/boolean.result | 3 ++- test/sql/boolean.test.sql | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/box/sql/vdbemem.c b/src/box/sql/vdbemem.c index dcfc59820..6964c9097 100644 --- a/src/box/sql/vdbemem.c +++ b/src/box/sql/vdbemem.c @@ -753,7 +753,7 @@ sqlVdbeMemCast(Mem * pMem, enum field_type type) assert(type == FIELD_TYPE_STRING); assert(MEM_Str == (MEM_Blob >> 3)); if ((pMem->flags & MEM_Bool) != 0) { - const char *str_bool = pMem->u.b ? "TRUE" : "FALSE"; + const char *str_bool = pMem->u.b ? "true" : "false"; sqlVdbeMemSetStr(pMem, str_bool, strlen(str_bool), 1, SQL_TRANSIENT); return 0; diff --git a/test/sql/boolean.result b/test/sql/boolean.result index ac9f7fcaf..191fa33f3 100644 --- a/test/sql/boolean.result +++ b/test/sql/boolean.result @@ -513,6 +513,7 @@ SELECT cast(true AS NUMBER), cast(false AS NUMBER); | - null | - 'Type mismatch: can not convert true to number' | ... +-- gh-4462: ensure that text representation is lowercase. SELECT cast(true AS TEXT), cast(false AS TEXT); | --- | - metadata: @@ -521,7 +522,7 @@ SELECT cast(true AS TEXT), cast(false AS TEXT); | - name: cast(false AS TEXT) | type: string | rows: - | - ['TRUE', 'FALSE'] + | - ['true', 'false'] | ... SELECT cast(true AS BOOLEAN), cast(false AS BOOLEAN); | --- diff --git a/test/sql/boolean.test.sql b/test/sql/boolean.test.sql index 68a05852f..63eb505c5 100644 --- a/test/sql/boolean.test.sql +++ b/test/sql/boolean.test.sql @@ -129,6 +129,7 @@ INSERT INTO t3 VALUES (4, false) -- Check CAST from BOOLEAN to the other types. SELECT cast(true AS INTEGER), cast(false AS INTEGER); SELECT cast(true AS NUMBER), cast(false AS NUMBER); +-- gh-4462: ensure that text representation is lowercase. SELECT cast(true AS TEXT), cast(false AS TEXT); SELECT cast(true AS BOOLEAN), cast(false AS BOOLEAN); -- 2.21.0 (Apple Git-122)