Tarantool development patches archive
 help / color / mirror / Atom feed
From: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
To: tarantool-patches@dev.tarantool.org, korablev@tarantool.org
Cc: tarantool-patches@freelists.org
Subject: [Tarantool-patches] [PATCH 2/3] sql: CAST(<boolean> AS TEXT) returns lowercase
Date: Sun, 27 Oct 2019 22:35:08 +0100	[thread overview]
Message-ID: <8260c85a5b81a174b45b101c2e9ad5d251e7420f.1572211914.git.v.shpilevoy@tarantool.org> (raw)
In-Reply-To: <cover.1572211914.git.v.shpilevoy@tarantool.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)

  parent reply	other threads:[~2019-10-27 21:29 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-27 21:35 [Tarantool-patches] [PATCH 0/3] Booleans and lower vs upper Vladislav Shpilevoy
2019-10-27 21:35 ` [Tarantool-patches] [PATCH 1/3] sql: LENGTH function accepts boolean Vladislav Shpilevoy
2019-10-27 21:35 ` Vladislav Shpilevoy [this message]
2019-10-28 14:08   ` [Tarantool-patches] [PATCH 2/3] sql: CAST(<boolean> AS TEXT) returns lowercase Nikita Pettik
2019-10-28 21:48     ` Vladislav Shpilevoy
2019-10-27 21:35 ` [Tarantool-patches] [PATCH 3/3] sql: make type string case lower everywhere Vladislav Shpilevoy
2019-10-28 14:23   ` Nikita Pettik
2019-10-28 21:45     ` Vladislav Shpilevoy
2019-11-07 12:40       ` Nikita Pettik
2019-10-30 23:28 ` [Tarantool-patches] [PATCH 0/3] Booleans and lower vs upper Nikita Pettik

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8260c85a5b81a174b45b101c2e9ad5d251e7420f.1572211914.git.v.shpilevoy@tarantool.org \
    --to=v.shpilevoy@tarantool.org \
    --cc=korablev@tarantool.org \
    --cc=tarantool-patches@dev.tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='Re: [Tarantool-patches] [PATCH 2/3] sql: CAST(<boolean> AS TEXT) returns lowercase' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox