[Tarantool-patches] [PATCH 2/3] sql: CAST(<boolean> AS TEXT) returns lowercase

Vladislav Shpilevoy v.shpilevoy at tarantool.org
Mon Oct 28 00:35:08 MSK 2019


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)



More information about the Tarantool-patches mailing list