-
Notifications
You must be signed in to change notification settings - Fork 43
More flexible insert builder #135
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
Merged
Merged
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
a23d2cd
Full-text search
stephencelis 48f5817
wip
stephencelis c843352
wip
stephencelis 0606e55
Update FTS5.swift
stephencelis 2a09df9
Merge remote-tracking branch 'origin/main' into fts
stephencelis 41ecef1
wip
stephencelis 5c49141
wip
stephencelis 79d2c1d
wip
stephencelis 63284f4
Make inserts more flexible
stephencelis 3bd3299
wip
stephencelis 61ef610
Merge branch 'fts' into better-insert-builder
stephencelis b4c01ea
wip
stephencelis f725b5e
Merge branch 'fts' into better-insert-builder
stephencelis 3783b88
wip
stephencelis 29ac227
Merge branch 'fts' into better-insert-builder
stephencelis 5e6fab6
Merge remote-tracking branch 'origin/main' into fts
stephencelis 49bb4ed
Merge branch 'fts' into better-insert-builder
stephencelis 930eab1
wip
stephencelis 2437e26
Merge branch 'fts' into better-insert-builder
stephencelis d130940
wip
stephencelis 8e09c19
Merge branch 'fts' into better-insert-builder
stephencelis 3478d4d
wip
stephencelis d71b8db
fix
stephencelis 4a60641
Merge branch 'fts' into better-insert-builder
stephencelis b23fe1a
Merge branch 'main' into better-insert-builder
stephencelis a038fa8
wip
stephencelis 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
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 |
|---|---|---|
|
|
@@ -67,7 +67,7 @@ public struct Seeds: Sequence { | |
| /// [SharingGRDB]: https://github.com/pointfreeco/sharing-grdb | ||
| /// | ||
| /// - Parameter build: A result builder closure that prepares statements to insert every built row. | ||
| public init(@InsertValuesBuilder<any Table> _ build: () -> [any Table]) { | ||
| public init(@SeedsBuilder _ build: () -> [any Table]) { | ||
|
Member
Author
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. The main gotcha in this PR is that we need a simultaneous release with SharingGRDB since it defines a |
||
| self.seeds = build() | ||
| } | ||
|
|
||
|
|
@@ -103,3 +103,46 @@ public struct Seeds: Sequence { | |
| } | ||
| } | ||
| } | ||
|
|
||
| @resultBuilder | ||
| public enum SeedsBuilder { | ||
| public static func buildArray(_ components: [[any Table]]) -> [any Table] { | ||
| components.flatMap(\.self) | ||
| } | ||
|
|
||
| public static func buildBlock(_ components: [any Table]) -> [any Table] { | ||
| components | ||
| } | ||
|
|
||
| public static func buildEither(first component: [any Table]) -> [any Table] { | ||
| component | ||
| } | ||
|
|
||
| public static func buildEither(second component: [any Table]) -> [any Table] { | ||
| component | ||
| } | ||
|
|
||
| public static func buildExpression(_ expression: some Table) -> [any Table] { | ||
| [expression] | ||
| } | ||
|
|
||
| public static func buildExpression(_ expression: [any Table]) -> [any Table] { | ||
| expression | ||
| } | ||
|
|
||
| public static func buildLimitedAvailability(_ component: [any Table]) -> [any Table] { | ||
| component | ||
| } | ||
|
|
||
| public static func buildOptional(_ component: [any Table]?) -> [any Table] { | ||
| component ?? [] | ||
| } | ||
|
|
||
| public static func buildPartialBlock(first: [any Table]) -> [any Table] { | ||
| first | ||
| } | ||
|
|
||
| public static func buildPartialBlock(accumulated: [any Table], next: [any Table]) -> [any Table] { | ||
| accumulated + next | ||
| } | ||
| } | ||
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.
The
@InsertValuesBuilderis now responsible for building up an array of query fragments to insert.