lowka commented on code in PR #1651:
URL: https://github.com/apache/ignite-3/pull/1651#discussion_r1102406501


##########
modules/runner/src/integrationTest/java/org/apache/ignite/internal/sql/engine/ItDataTypesTest.java:
##########
@@ -86,6 +87,23 @@ public void testUnicodeStrings() {
         }
     }
 
+    /** Test correctness of char types limitation. */
+    @Test
+    public void charLimitation() {
+        sql("create table limitedChar (pk int primary key, f1 VARCHAR(5), f2 
CHAR(4))");
+        assertThrows(CalciteContextException.class, () -> sql("insert into 
limitedChar(pk, f2) values (1, 'aaaadddd')"));
+        assertThrows(CalciteContextException.class, () -> sql("insert into 
limitedChar values (2, 'aaaaabbbbb', 'aaaadddd')"));
+        assertThrows(CalciteContextException.class, () -> sql("insert into 
limitedChar values (3, '我叫什么名字', '我叫什么名字')"));
+        sql("insert into limitedChar values (4, ' aaa    ', ' bbb     ')");
+
+        List<List<Object>> res = sql("select f1, f2 from limitedChar ORDER BY 
pk");
+
+        List<Object> r = res.get(0);
+
+        assertEquals(" aaa ", r.get(0));

Review Comment:
   > Insert '...aaa..... Retrieve '.aaa.'. Do we still expect data truncation 
to occur?
   It seems that removing trailing blank characters is a correct behaviour.



##########
modules/runner/src/integrationTest/java/org/apache/ignite/internal/sql/engine/ItDataTypesTest.java:
##########
@@ -86,6 +87,23 @@ public void testUnicodeStrings() {
         }
     }
 
+    /** Test correctness of char types limitation. */
+    @Test
+    public void charLimitation() {
+        sql("create table limitedChar (pk int primary key, f1 VARCHAR(5), f2 
CHAR(4))");
+        assertThrows(CalciteContextException.class, () -> sql("insert into 
limitedChar(pk, f2) values (1, 'aaaadddd')"));
+        assertThrows(CalciteContextException.class, () -> sql("insert into 
limitedChar values (2, 'aaaaabbbbb', 'aaaadddd')"));
+        assertThrows(CalciteContextException.class, () -> sql("insert into 
limitedChar values (3, '我叫什么名字', '我叫什么名字')"));
+        sql("insert into limitedChar values (4, ' aaa    ', ' bbb     ')");
+
+        List<List<Object>> res = sql("select f1, f2 from limitedChar ORDER BY 
pk");
+
+        List<Object> r = res.get(0);
+
+        assertEquals(" aaa ", r.get(0));

Review Comment:
   > Insert '...aaa..... Retrieve '.aaa.'. Do we still expect data truncation 
to occur?
   
   It seems that removing trailing blank characters is a correct behaviour.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to