-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Created a single universal Mac+iOS framework #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,11 +21,8 @@ | |
| // THE SOFTWARE. | ||
| // | ||
|
|
||
| /// A dictionary mapping column names to values. | ||
| public typealias Values = [String: Datatype?] | ||
|
|
||
| /// A query object. Used to build SQL statements with a collection of chainable | ||
| /// helper functions. | ||
| /// A query object. Used to build SQL statements using a collection of | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This would also be reverting recent changes. |
||
| /// chainable helper functions. | ||
| public struct Query { | ||
|
|
||
| private var database: Database | ||
|
|
@@ -319,7 +316,7 @@ public struct Query { | |
| return database.prepare(Swift.join(" ", parts), bindings) | ||
| } | ||
|
|
||
| private func insertStatement(values: Values) -> Statement { | ||
| private func insertStatement(values: [String: Datatype?]) -> Statement { | ||
| var (parts, bindings) = (["INSERT INTO \(tableName)"], self.bindings) | ||
| let valuesClause = Swift.join(", ", map(values) { columnName, value in | ||
| bindings.append(value) | ||
|
|
@@ -330,7 +327,7 @@ public struct Query { | |
| return database.prepare(Swift.join(" ", parts), bindings) | ||
| } | ||
|
|
||
| private func updateStatement(values: Values) -> Statement { | ||
| private func updateStatement(values: [String: Datatype?]) -> Statement { | ||
| var (parts, bindings) = (["UPDATE \(tableName)"], [Datatype?]()) | ||
| let valuesClause = Swift.join(", ", map(values) { columnName, value in | ||
| bindings.append(value) | ||
|
|
@@ -388,11 +385,13 @@ public struct Query { | |
|
|
||
| // MARK: - Array | ||
|
|
||
| public typealias Element = [String: Datatype?] | ||
|
|
||
| /// The first result (or nil if the query has no results). | ||
| public var first: Values? { return limit(1).generate().next() } | ||
| public var first: Element? { return limit(1).generate().next() } | ||
|
|
||
| /// The last result (or nil if the query has no results). | ||
| public var last: Values? { return reverse(self).first } | ||
| public var last: Element? { return reverse(self).first } | ||
|
|
||
| /// Returns true if the query has no results. | ||
| public var isEmpty: Bool { return first == nil } | ||
|
|
@@ -404,21 +403,25 @@ public struct Query { | |
| /// :param: values A dictionary of column names to values. | ||
| /// | ||
| /// :returns: The statement. | ||
| public func insert(values: Values) -> Statement { return insert(values).statement } | ||
| public func insert(values: [String: Datatype?]) -> Statement { | ||
| return insert(values).statement | ||
| } | ||
|
|
||
| /// Runs an INSERT statement with the given row of values. | ||
| /// | ||
| /// :param: values A dictionary of column names to values. | ||
| /// | ||
| /// :returns: The row ID. | ||
| public func insert(values: Values) -> Int? { return insert(values).ID } | ||
| public func insert(values: [String: Datatype?]) -> Int? { | ||
| return insert(values).ID | ||
| } | ||
|
|
||
| /// Runs an INSERT statement with the given row of values. | ||
| /// | ||
| /// :param: values A dictionary of column names to values. | ||
| /// | ||
| /// :returns: The row ID and statement. | ||
| public func insert(values: Values) -> (ID: Int?, statement: Statement) { | ||
| public func insert(values: [String: Datatype?]) -> (ID: Int?, statement: Statement) { | ||
| let statement = insertStatement(values).run() | ||
| return (statement.failed ? nil : database.lastID, statement) | ||
| } | ||
|
|
@@ -428,34 +431,42 @@ public struct Query { | |
| /// :param: values A dictionary of column names to values. | ||
| /// | ||
| /// :returns: The statement. | ||
| public func update(values: Values) -> Statement { return update(values).statement } | ||
| public func update(values: [String: Datatype?]) -> Statement { | ||
| return update(values).statement | ||
| } | ||
|
|
||
| /// Runs an UPDATE statement against the query with the given values. | ||
| /// | ||
| /// :param: values A dictionary of column names to values. | ||
| /// | ||
| /// :returns: The number of updated rows. | ||
| public func update(values: Values) -> Int { return update(values).changes } | ||
| public func update(values: [String: Datatype?]) -> Int { | ||
| return update(values).changes | ||
| } | ||
|
|
||
| /// Runs an UPDATE statement against the query with the given values. | ||
| /// | ||
| /// :param: values A dictionary of column names to values. | ||
| /// | ||
| /// :returns: The number of updated rows and statement. | ||
| public func update(values: Values) -> (changes: Int, statement: Statement) { | ||
| public func update(values: [String: Datatype?]) -> (changes: Int, statement: Statement) { | ||
| let statement = updateStatement(values).run() | ||
| return (statement.failed ? 0 : database.lastChanges ?? 0, statement) | ||
| } | ||
|
|
||
| /// Runs an DELETE statement against the query. | ||
| /// | ||
| /// :returns: The statement. | ||
| public func delete() -> Statement { return delete().statement } | ||
| public func delete() -> Statement { | ||
| return delete().statement | ||
| } | ||
|
|
||
| /// Runs an DELETE statement against the query. | ||
| /// | ||
| /// :returns: The number of deleted rows. | ||
| public func delete() -> Int { return delete().changes } | ||
| public func delete() -> Int { | ||
| return delete().changes | ||
| } | ||
|
|
||
| /// Runs an DELETE statement against the query. | ||
| /// | ||
|
|
@@ -541,11 +552,13 @@ extension Query: SequenceType { | |
| // MARK: - GeneratorType | ||
| public struct QueryGenerator: GeneratorType { | ||
|
|
||
| public typealias Element = [String: Datatype?] | ||
|
|
||
| private var statement: Statement | ||
|
|
||
| private init(_ statement: Statement) { self.statement = statement } | ||
|
|
||
| public func next() -> Values? { | ||
| public func next() -> Element? { | ||
| statement.next() | ||
| return statement.values | ||
| } | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,2 @@ | ||
| PRODUCT_NAME = SQLite | ||
| PRODUCT_VERSION = 0.1 | ||
| SWIFT_OBJC_BRIDGING_HEADER = SQLite Common/SQLite-Bridging-Header.h | ||
| PRODUCT_VERSION = 0.1 |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, did my recent README changes somehow get reverted in your commit?