Skip to content

Commit

Permalink
Update Swift-Kuery dependency to 2.0.0 (#58)
Browse files Browse the repository at this point in the history
  • Loading branch information
AnthonyAmanse authored and EnriqueL8 committed Jun 26, 2018
1 parent a814cd0 commit d1b3588
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 27 deletions.
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ let package = Package(
],
dependencies: [
// Dependencies declare other packages that this package depends on.
.package(url:"https://github.com/IBM-Swift/Swift-Kuery.git", from: "1.3.0"),
.package(url:"https://github.com/IBM-Swift/Swift-Kuery.git", from: "2.0.0"),
.package(url:"https://github.com/IBM-Swift/KituraContracts.git", from: "1.0.0"),
.package(url:"https://github.com/IBM-Swift/TypeDecoder.git", from: "1.0.0")
],
Expand Down
4 changes: 2 additions & 2 deletions Tests/SwiftKueryORMTests/CommonUtils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class TestConnection: Connection {
case returnValue
}

init(result: Result, withDeleteRequiresUsing: Bool = false, withUpdateRequiresFrom: Bool = false, createAutoIncrement: ((String) -> String)? = nil) {
init(result: Result, withDeleteRequiresUsing: Bool = false, withUpdateRequiresFrom: Bool = false, createAutoIncrement: ((String, Bool) -> String)? = nil) {
self.queryBuilder = QueryBuilder(withDeleteRequiresUsing: withDeleteRequiresUsing, withUpdateRequiresFrom: withUpdateRequiresFrom, createAutoIncrement: createAutoIncrement)
self.result = result
}
Expand Down Expand Up @@ -165,7 +165,7 @@ func createConnection(_ result: TestConnection.Result) -> TestConnection {
return TestConnection(result: result)
}

func createConnection(withDeleteRequiresUsing: Bool = false, withUpdateRequiresFrom: Bool = false, createAutoIncrement: ((String) -> String)? = nil) -> TestConnection {
func createConnection(withDeleteRequiresUsing: Bool = false, withUpdateRequiresFrom: Bool = false, createAutoIncrement: ((String, Bool) -> String)? = nil) -> TestConnection {
return TestConnection(result: .returnEmpty, withDeleteRequiresUsing: withDeleteRequiresUsing, withUpdateRequiresFrom: withUpdateRequiresFrom, createAutoIncrement: createAutoIncrement)
}

Expand Down
8 changes: 4 additions & 4 deletions Tests/SwiftKueryORMTests/TestDelete.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class TestDelete: XCTestCase {
XCTAssertNil(error, "Delete Failed: \(String(describing: error))")
XCTAssertNotNil(connection.query, "Delete Failed: Query is nil")
if let query = connection.query {
let expectedQuery = "DELETE FROM People WHERE People.id = ?1"
let expectedQuery = "DELETE FROM \"People\" WHERE \"People\".\"id\" = ?1"
let resultQuery = connection.descriptionOf(query: query)
XCTAssertEqual(resultQuery, expectedQuery, "Expected query \(String(describing: expectedQuery)) did not match result query: \(String(describing: resultQuery))")
}
Expand All @@ -50,7 +50,7 @@ class TestDelete: XCTestCase {
XCTAssertNil(error, "Delete Failed: \(String(describing: error))")
XCTAssertNotNil(connection.query, "Delete Failed: Query is nil")
if let query = connection.query {
let expectedQuery = "DELETE FROM People"
let expectedQuery = "DELETE FROM \"People\""
let resultQuery = connection.descriptionOf(query: query)
XCTAssertEqual(resultQuery, expectedQuery, "Expected query \(String(describing: expectedQuery)) did not match result query: \(String(describing: resultQuery))")
}
Expand All @@ -76,8 +76,8 @@ class TestDelete: XCTestCase {
XCTAssertNil(error, "Delete Failed: \(String(describing: error))")
XCTAssertNotNil(connection.query, "Delete Failed: Query is nil")
if let query = connection.query {
let expectedPrefix = "DELETE FROM People WHERE"
let expectedClauses = [["People.name = ?1", "People.name = ?2"], ["People.age = ?1", "People.age = ?2"]]
let expectedPrefix = "DELETE FROM \"People\" WHERE"
let expectedClauses = [["\"People\".\"name\" = ?1", "\"People\".\"name\" = ?2"], ["\"People\".\"age\" = ?1", "\"People\".\"age\" = ?2"]]
let expectedOperator = "AND"
let resultQuery = connection.descriptionOf(query: query)
XCTAssertTrue(resultQuery.hasPrefix(expectedPrefix))
Expand Down
8 changes: 4 additions & 4 deletions Tests/SwiftKueryORMTests/TestFind.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class TestFind: XCTestCase {
XCTAssertNil(error, "Find Failed: \(String(describing: error))")
XCTAssertNotNil(connection.query, "Find Failed: Query is nil")
if let query = connection.query {
let expectedQuery = "SELECT * FROM People WHERE People.id = ?1"
let expectedQuery = "SELECT * FROM \"People\" WHERE \"People\".\"id\" = ?1"
let resultQuery = connection.descriptionOf(query: query)
XCTAssertEqual(resultQuery, expectedQuery, "Find Failed: Invalid query")
}
Expand All @@ -57,7 +57,7 @@ class TestFind: XCTestCase {
XCTAssertNil(error, "Find Failed: \(String(describing: error))")
XCTAssertNotNil(connection.query, "Find Failed: Query is nil")
if let query = connection.query {
let expectedQuery = "SELECT * FROM People"
let expectedQuery = "SELECT * FROM \"People\""
let resultQuery = connection.descriptionOf(query: query)
XCTAssertEqual(resultQuery, expectedQuery, "Find Failed: Invalid query")
}
Expand Down Expand Up @@ -88,8 +88,8 @@ class TestFind: XCTestCase {
XCTAssertNil(error, "Find Failed: \(String(describing: error))")
XCTAssertNotNil(connection.query, "Find Failed: Query is nil")
if let query = connection.query {
let expectedPrefix = "SELECT * FROM People WHERE"
let expectedClauses = [["People.name = ?1", "People.name = ?2"], ["People.age = ?1", "People.age = ?2"]]
let expectedPrefix = "SELECT * FROM \"People\" WHERE"
let expectedClauses = [["\"People\".\"name\" = ?1", "\"People\".\"name\" = ?2"], ["\"People\".\"age\" = ?1", "\"People\".\"age\" = ?2"]]
let expectedOperator = "AND"
let resultQuery = connection.descriptionOf(query: query)
XCTAssertTrue(resultQuery.hasPrefix(expectedPrefix))
Expand Down
10 changes: 5 additions & 5 deletions Tests/SwiftKueryORMTests/TestId.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class TestId: XCTestCase {
XCTAssertNil(error, "Find Failed: \(String(describing: error))")
XCTAssertNotNil(connection.query, "Find Failed: Query is nil")
if let query = connection.query {
let expectedQuery = "SELECT * FROM People WHERE People.name = ?1"
let expectedQuery = "SELECT * FROM \"People\" WHERE \"People\".\"name\" = ?1"
let resultQuery = connection.descriptionOf(query: query)
XCTAssertEqual(resultQuery, expectedQuery, "Find Failed: Invalid query")
}
Expand All @@ -62,9 +62,9 @@ class TestId: XCTestCase {
XCTAssertNil(error, "Update Failed: \(String(describing: error))")
XCTAssertNotNil(connection.query, "Update Failed: Query is nil")
if let query = connection.query {
let expectedPrefix = "UPDATE People SET"
let expectedSuffix = "WHERE People.name = ?3"
let expectedUpdates = [["name = ?1", "name = ?2"], ["age = ?1", "age = ?2"]]
let expectedPrefix = "UPDATE \"People\" SET"
let expectedSuffix = "WHERE \"People\".\"name\" = ?3"
let expectedUpdates = [["\"name\" = ?1", "\"name\" = ?2"], ["\"age\" = ?1", "\"age\" = ?2"]]
let resultQuery = connection.descriptionOf(query: query)
XCTAssertTrue(resultQuery.hasPrefix(expectedPrefix))
XCTAssertTrue(resultQuery.hasSuffix(expectedSuffix))
Expand Down Expand Up @@ -97,7 +97,7 @@ class TestId: XCTestCase {
XCTAssertNil(error, "Delete Failed: \(String(describing: error))")
XCTAssertNotNil(connection.query, "Delete Failed: Query is nil")
if let query = connection.query {
let expectedQuery = "DELETE FROM People WHERE People.name = ?1"
let expectedQuery = "DELETE FROM \"People\" WHERE \"People\".\"name\" = ?1"
let resultQuery = connection.descriptionOf(query: query)
XCTAssertEqual(resultQuery, expectedQuery, "Expected query \(String(describing: expectedQuery)) did not match result query: \(String(describing: resultQuery))")
}
Expand Down
8 changes: 4 additions & 4 deletions Tests/SwiftKueryORMTests/TestSave.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ class TestSave: XCTestCase {
XCTAssertNil(error, "Save Failed: \(String(describing: error))")
XCTAssertNotNil(connection.query, "Save Failed: Query is nil")
if let query = connection.query {
let expectedPrefix = "INSERT INTO People"
let expectedPrefix = "INSERT INTO \"People\""
let expectedSQLStatement = "VALUES"
let expectedDictionary = ["name": "?1,?2", "age": "?1,?2"]
let expectedDictionary = ["\"name\"": "?1,?2", "\"age\"": "?1,?2"]

let resultQuery = connection.descriptionOf(query: query)
XCTAssertTrue(resultQuery.hasPrefix(expectedPrefix))
Expand Down Expand Up @@ -94,9 +94,9 @@ class TestSave: XCTestCase {
XCTAssertNil(error, "Save Failed: \(String(describing: error))")
XCTAssertNotNil(connection.query, "Save Failed: Query is nil")
if let query = connection.query {
let expectedPrefix = "INSERT INTO People"
let expectedPrefix = "INSERT INTO \"People\""
let expectedSQLStatement = "VALUES"
let expectedDictionary = ["name": "?1,?2", "age": "?1,?2"]
let expectedDictionary = ["\"name\"": "?1,?2", "\"age\"": "?1,?2"]

let resultQuery = connection.descriptionOf(query: query)
XCTAssertTrue(resultQuery.hasPrefix(expectedPrefix))
Expand Down
8 changes: 4 additions & 4 deletions Tests/SwiftKueryORMTests/TestTable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class TestTable: XCTestCase {
XCTAssertNil(error, "Table Creation Failed: \(String(describing: error))")
XCTAssertNotNil(connection.raw, "Table Creation Failed: Query is nil")
if let raw = connection.raw {
let expectedQuery = "CREATE TABLE Users (username text NOT NULL, password text NOT NULL, id bigint AUTO_INCREMENT PRIMARY KEY)"
let expectedQuery = "CREATE TABLE \"Users\" (\"username\" text NOT NULL, \"password\" text NOT NULL, \"id\" bigint AUTO_INCREMENT PRIMARY KEY)"
XCTAssertEqual(raw, expectedQuery, "Table Creation Failed: Invalid query")
}
expectation.fulfill()
Expand All @@ -49,7 +49,7 @@ class TestTable: XCTestCase {
XCTAssertNil(error, "Table Drop Failed: \(String(describing: error))")
XCTAssertNotNil(connection.query, "Table Drop Failed: Query is nil")
if let query = connection.query {
let expectedQuery = "DROP TABLE Users"
let expectedQuery = "DROP TABLE \"Users\""
let resultQuery = connection.descriptionOf(query: query)
XCTAssertEqual(resultQuery, expectedQuery, "Table Drop Failed: Invalid query")
}
Expand All @@ -75,7 +75,7 @@ class TestTable: XCTestCase {
XCTAssertNil(error, "Table Creation Failed: \(String(describing: error))")
XCTAssertNotNil(connection.raw, "Table Creation Failed: Query is nil")
if let raw = connection.raw {
let expectedQuery = "CREATE TABLE Meals (name text PRIMARY KEY NOT NULL, rating bigint NOT NULL)"
let expectedQuery = "CREATE TABLE \"Meals\" (\"name\" text PRIMARY KEY NOT NULL, \"rating\" bigint NOT NULL)"
XCTAssertEqual(raw, expectedQuery, "Table Creation Failed: Invalid query")
}
expectation.fulfill()
Expand All @@ -101,7 +101,7 @@ class TestTable: XCTestCase {
XCTAssertNil(error, "Table Creation Failed: \(String(describing: error))")
XCTAssertNotNil(connection.raw, "Table Creation Failed: Query is nil")
if let raw = connection.raw {
let expectedQuery = "CREATE TABLE Grades (grade double NOT NULL, course text NOT NULL, MyId integer AUTO_INCREMENT PRIMARY KEY)"
let expectedQuery = "CREATE TABLE \"Grades\" (\"grade\" double NOT NULL, \"course\" text NOT NULL, \"MyId\" integer AUTO_INCREMENT PRIMARY KEY)"
XCTAssertEqual(raw, expectedQuery, "Table Creation Failed: Invalid query")
}
expectation.fulfill()
Expand Down
6 changes: 3 additions & 3 deletions Tests/SwiftKueryORMTests/TestUpdate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ class TestUpdate: XCTestCase {
XCTAssertNil(error, "Update Failed: \(String(describing: error))")
XCTAssertNotNil(connection.query, "Update Failed: Query is nil")
if let query = connection.query {
let expectedPrefix = "UPDATE People SET"
let expectedSuffix = "WHERE People.id = ?3"
let expectedUpdates = [["name = ?1", "name = ?2"], ["age = ?1", "age = ?2"]]
let expectedPrefix = "UPDATE \"People\" SET"
let expectedSuffix = "WHERE \"People\".\"id\" = ?3"
let expectedUpdates = [["\"name\" = ?1", "\"name\" = ?2"], ["\"age\" = ?1", "\"age\" = ?2"]]
let resultQuery = connection.descriptionOf(query: query)
XCTAssertTrue(resultQuery.hasPrefix(expectedPrefix))
XCTAssertTrue(resultQuery.hasSuffix(expectedSuffix))
Expand Down

0 comments on commit d1b3588

Please sign in to comment.