1#include "catch.hpp"
2#include "test_helpers.hpp"
3
4using namespace duckdb;
5using namespace std;
6
7TEST_CASE("Unicode schema", "[catalog]") {
8 unique_ptr<QueryResult> result;
9 DuckDB db(nullptr);
10 Connection con(db);
11
12 // create schema
13 REQUIRE_NO_FAIL(con.Query("CREATE TABLE 👤(🔑 INTEGER PRIMARY KEY, 🗣 varchar(64), 🗓 DATE);"));
14 REQUIRE_NO_FAIL(con.Query("CREATE TABLE ✍(🔑 INTEGER PRIMARY KEY, 🗣 varchar(64));"));
15 REQUIRE_NO_FAIL(con.Query("CREATE TABLE 📕(🔑 INTEGER PRIMARY KEY, 💬 varchar(64), 🔖 varchar(64), ✍ INTEGER);"));
16 REQUIRE_NO_FAIL(con.Query("CREATE TABLE 👤🏠📕(👤 INTEGER, 📕 INTEGER, ⭐ TEXT);"));
17 // insert data
18 REQUIRE_NO_FAIL(con.Query("INSERT INTO 👤 VALUES (1, 'Jeff', '2019-01-01'), (2, 'Annie', '2019-01-01');"));
19 REQUIRE_NO_FAIL(con.Query("INSERT INTO ✍ VALUES (1, 'Herman Melville'), (2, 'Lewis Carroll');"));
20 REQUIRE_NO_FAIL(con.Query("INSERT INTO 📕 VALUES (1, 'Alice in Wonderland', '🔮', 2), (2, 'Moby Dick', '📖', 1), (3, "
21 "'Through the Looking-Glass', '🔮', 2);"));
22 REQUIRE_NO_FAIL(con.Query("INSERT INTO 👤🏠📕 VALUES (1, 1, '😍'), (1, 2, '🤢'), (2, 2, '🙂');"));
23
24 result = con.Query(
25 "SELECT 👤.🗣 AS 👤, 📕.💬 AS 📕 FROM 👤 JOIN 👤🏠📕 ON 👤.🔑 = 👤🏠📕.👤 JOIN "
26 "📕 "
27 "ON "
28 "📕.🔑 "
29 "= "
30 "👤🏠📕.📕 "
31 "ORDER "
32 "BY "
33 "👤, "
34 "📕;");
35 REQUIRE(CHECK_COLUMN(result, 0, {"Annie", "Jeff", "Jeff"}));
36 REQUIRE(CHECK_COLUMN(result, 1, {"Moby Dick", "Alice in Wonderland", "Moby Dick"}));
37
38 result = con.Query(
39 "SELECT 👤.🗣, 👤🏠📕.⭐ FROM 👤🏠📕 JOIN 📕 ON 👤🏠📕.📕 = 📕.🔑 JOIN 👤 ON "
40 "👤🏠📕.👤=👤.🔑 "
41 "WHERE "
42 "📕.💬 "
43 "= "
44 "'Moby "
45 "Dick' ORDER BY 👤.🗣;");
46 REQUIRE(CHECK_COLUMN(result, 0, {"Annie", "Jeff"}));
47 REQUIRE(CHECK_COLUMN(result, 1, {"🙂", "🤢"}));
48
49 result = con.Query("SELECT type, name FROM sqlite_master() WHERE name='👤' ORDER BY name;");
50 REQUIRE(CHECK_COLUMN(result, 0, {"table"}));
51 REQUIRE(CHECK_COLUMN(result, 1, {"👤"}));
52}
53