+
+-- Collation is set in space format and also in position() -
+-- for both arguments. Arguments have different explicit
+-- collations thus an error is expected.
+
+test:do_catchsql_test(
+ "position-1.75",
+ [[
+ CREATE TABLE test1 (s1 VARCHAR(5) PRIMARY KEY COLLATE "unicode_ci");
+ INSERT INTO test1 VALUES('à');
+ SELECT POSITION('a' COLLATE "unicode_ci", s1 COLLATE "unicode") FROM test1;
+ ]], {
+ 1, "Illegal mix of collations"
+ }
+)
+
+test:do_catchsql_test(
+ "position-1.76",
+ [[
+ DROP TABLE test1;
+ CREATE TABLE test1 (s1 VARCHAR(5) PRIMARY KEY COLLATE "unicode_ci");
+ INSERT INTO test1 VALUES('qwèrty');
+ SELECT POSITION('er' COLLATE "unicode_ci", s1 COLLATE "unicode") FROM test1;
+ DROP TABLE test1;
+ ]], {
+ 1, "Illegal mix of collations"
+ }
+)
+
+test:do_catchsql_test(
+ "position-1.77",
+ [[
+ DROP TABLE test1;
+ CREATE TABLE test1 (s1 VARCHAR(5) PRIMARY KEY COLLATE "unicode_ci");
+ INSERT INTO test1 VALUES('qwèrtÿ');
+ SELECT POSITION('Y' COLLATE "unicode_ci", s1 COLLATE "unicode") FROM test1;
+ ]], {
+ 1, "Illegal mix of collations"
+ }
+)
Add test cases on: explicitly set incompatible collations,
explicitly set compatible collations.
Don’t we already have such tests? From the end of position.test.lua:-- Collation is set in space format and also in position() --- for both arguments. Arguments have the same collations.
Oh, I meant ‘implicitly set’. Still can’t find such tests.