From 604cf6b52259ae24fdd4801146cd9c44358663ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Sun, 4 Jun 2017 19:57:46 +0200 Subject: [PATCH] Remove QueryInterfaceRequest.contains(_:) --- CHANGELOG.md | 1 + Documentation/ExtendingGRDB.md | 9 --------- GRDB/QueryInterface/SQLSelectQuery.swift | 20 +------------------ README.md | 9 --------- .../QueryInterfaceExpressionsTests.swift | 10 ---------- 5 files changed, 2 insertions(+), 47 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8c13c2c92..a0d3486c8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ Release Notes - `DatabaseCoder` has been removed. - `QueryInterfaceRequest.exists` has been removed. +- `QueryInterfaceRequest.contains` has been removed. ## 0.110.0 diff --git a/Documentation/ExtendingGRDB.md b/Documentation/ExtendingGRDB.md index b3c9381a5..3e9050246 100644 --- a/Documentation/ExtendingGRDB.md +++ b/Documentation/ExtendingGRDB.md @@ -483,15 +483,6 @@ Build a `value IN (...)` expression from any sequence of [values](../../../#valu ![1,2,3].contains(Column("id")) ``` -The most general way to generate an `IN` operator is from any value that adopts the [SQLCollection](http://groue.github.io/GRDB.swift/docs/0.110.0/Protocols/SQLCollection.html) protocol, like the [query interface requests](../../../#requests): - -```swift -let request = Person.select(Column("id")) - -// SQLExpression: in IN (SELECT id FROM persons) -request.contains(Column("id")) -``` - #### The BETWEEN Operator diff --git a/GRDB/QueryInterface/SQLSelectQuery.swift b/GRDB/QueryInterface/SQLSelectQuery.swift index 41f57ca4f..fc2c4b98e 100644 --- a/GRDB/QueryInterface/SQLSelectQuery.swift +++ b/GRDB/QueryInterface/SQLSelectQuery.swift @@ -8,7 +8,7 @@ /// # Low Level Query Interface /// /// SQLSelectQuery is the protocol for types that represent a full select query. -public protocol SQLSelectQuery : Request, SQLCollection { +public protocol SQLSelectQuery : Request { /// This function is an implementation detail of the query interface. /// Do not use it directly. @@ -28,24 +28,6 @@ public protocol SQLSelectQuery : Request, SQLCollection { } -// MARK: - SQLCollection adoption - -extension SQLSelectQuery { - - /// This function is an implementation detail of the query interface. - /// Do not use it directly. - /// - /// See https://github.com/groue/GRDB.swift/#the-query-interface - /// - /// # Low Level Query Interface - /// - /// See SQLCollection.collectionSQL(_) - public func collectionSQL(_ arguments: inout StatementArguments?) -> String { - return selectQuerySQL(&arguments) - } -} - - // MARK: - Request adoption extension SQLSelectQuery { diff --git a/README.md b/README.md index 042e4fc66..0167593c9 100644 --- a/README.md +++ b/README.md @@ -2927,15 +2927,6 @@ Feed [requests](#requests) with SQL expressions built from your Swift code: ``` > :point_up: **Note**: SQLite string comparison, by default, is case-sensitive and not Unicode-aware. See [string comparison](#string-comparison) if you need more control. - - To check inclusion in a subquery, call the `contains` method on another request: - - ```swift - // SELECT * FROM events - // WHERE userId IN (SELECT id FROM persons WHERE verified) - let verifiedUserIds = User.select(idColumn).filter(verifiedColumn) - Event.filter(verifiedUserIds.contains(userIdColumn)) - ``` - `LIKE` diff --git a/Tests/GRDBTests/QueryInterfaceExpressionsTests.swift b/Tests/GRDBTests/QueryInterfaceExpressionsTests.swift index 227a8d541..4000bc609 100644 --- a/Tests/GRDBTests/QueryInterfaceExpressionsTests.swift +++ b/Tests/GRDBTests/QueryInterfaceExpressionsTests.swift @@ -143,16 +143,6 @@ class QueryInterfaceExpressionsTests: GRDBTestCase { XCTAssertEqual( sql(dbQueue, tableRequest.filter(!("A"..."z").contains(Col.name))), "SELECT * FROM \"readers\" WHERE (\"name\" NOT BETWEEN 'A' AND 'z')") - - // Subquery - XCTAssertEqual( - sql(dbQueue, tableRequest.filter(tableRequest.select(Col.id).contains(Col.id))), - "SELECT * FROM \"readers\" WHERE (\"id\" IN (SELECT \"id\" FROM \"readers\"))") - - // Subquery - XCTAssertEqual( - sql(dbQueue, tableRequest.filter(!tableRequest.select(Col.id).contains(Col.id))), - "SELECT * FROM \"readers\" WHERE (\"id\" NOT IN (SELECT \"id\" FROM \"readers\"))") } func testContainsWithCollation() throws {