From 96df69b3fb2ed37058282d4588cf381663a286a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Tue, 2 Mar 2021 19:06:18 +0100 Subject: [PATCH] Add fundamental test for #929 --- Tests/GRDBTests/QueryInterfaceExpressionsTests.swift | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Tests/GRDBTests/QueryInterfaceExpressionsTests.swift b/Tests/GRDBTests/QueryInterfaceExpressionsTests.swift index 0a5ffe28c..62cfc8631 100644 --- a/Tests/GRDBTests/QueryInterfaceExpressionsTests.swift +++ b/Tests/GRDBTests/QueryInterfaceExpressionsTests.swift @@ -165,6 +165,16 @@ class QueryInterfaceExpressionsTests: GRDBTestCase { func testContainsWithCollation() throws { let dbQueue = try makeDatabaseQueue() + try dbQueue.read { db in + // Reminder of the SQLite behavior + // https://sqlite.org/datatype3.html#assigning_collating_sequences_from_sql + // > If an explicit collating sequence is required on an IN operator + // > it should be applied to the left operand, like this: + // > "x COLLATE nocase IN (y,z, ...)". + try XCTAssertFalse(Bool.fetchOne(db, sql: "SELECT 'arthur' IN ('ARTHUR') COLLATE NOCASE")!) + try XCTAssertTrue(Bool.fetchOne(db, sql: "SELECT 'arthur' COLLATE NOCASE IN ('ARTHUR')")!) + } + // Array.contains(): IN operator XCTAssertEqual( sql(dbQueue, tableRequest.filter(["arthur", "barbara"].contains(Col.name.collating(.nocase)))),