Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Examples/Reminders/RemindersListDetail.swift
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ struct RemindersListDetailView: View {
let remindersList: RemindersList
let isPastDue: Bool
let notes: String
@Column(as: JSONRepresentation<[String]>.self)
@Column(as: [String].JSONRepresentation.self)
let tags: [String]
}
}
Expand Down
2 changes: 1 addition & 1 deletion Examples/Reminders/Schema.swift
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ extension Tag {
}

extension Tag.TableColumns {
var jsonNames: some QueryExpression<JSONRepresentation<[String]>> {
var jsonNames: some QueryExpression<[String].JSONRepresentation> {
self.title.jsonGroupArray(filter: self.title.isNot(nil))
}
}
Expand Down
2 changes: 1 addition & 1 deletion Examples/Reminders/SearchReminders.swift
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ struct SearchRemindersView: View {
let notes: String
let reminder: Reminders.Reminder
let remindersList: RemindersList
@Column(as: JSONRepresentation<[String]>.self)
@Column(as: [String].JSONRepresentation.self)
let tags: [String]
}
}
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ let package = Package(
.package(url: "https://github.com/pointfreeco/swift-dependencies", from: "1.9.0"),
.package(url: "https://github.com/pointfreeco/xctest-dynamic-overlay", from: "1.5.0"),
.package(url: "https://github.com/pointfreeco/swift-sharing", from: "2.3.0"),
.package(url: "https://github.com/pointfreeco/swift-structured-queries", from: "0.1.1"),
.package(url: "https://github.com/pointfreeco/swift-structured-queries", from: "0.2.0"),
],
targets: [
.target(
Expand Down
6 changes: 3 additions & 3 deletions SharingGRDB.xcworkspace/xcshareddata/swiftpm/Package.resolved

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 2 additions & 22 deletions Sources/StructuredQueriesGRDBCore/Seed.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,28 +53,8 @@ extension Database {
@InsertValuesBuilder<any StructuredQueriesCore.Table>
_ build: () -> [any StructuredQueriesCore.Table]
) throws {
var seeds = build()
while !seeds.isEmpty {
guard let first = seeds.first else { break }
let firstType = type(of: first)

if let firstType = firstType as? any TableDraft.Type {
func insertBatch<T: TableDraft>(_: T.Type) throws {
let batch = Array(seeds.lazy.prefix { $0 is T }.compactMap { $0 as? T })
defer { seeds.removeFirst(batch.count) }
try T.PrimaryTable.insert(batch).execute(self)
}

try insertBatch(firstType)
} else {
func insertBatch<T: StructuredQueriesCore.Table>(_: T.Type) throws {
let batch = Array(seeds.lazy.prefix { $0 is T }.compactMap { $0 as? T })
defer { seeds.removeFirst(batch.count) }
try T.insert(batch).execute(self)
}

try insertBatch(firstType)
}
for insert in Seeds(build) {
try insert.execute(self)
}
}
}
1 change: 0 additions & 1 deletion Tests/SharingGRDBTests/FetchTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import GRDB
import Sharing
import SharingGRDB
import StructuredQueries
import SwiftUI
import Testing

@Suite(.dependency(\.defaultDatabase, try .database()))
Expand Down