Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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 Sources/StructuredQueriesCore/AggregateFunctions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ public struct AggregateFunction<QueryValue>: QueryExpression, Sendable {
var order: QueryFragment?
var filter: QueryFragment?

init(
package init(
_ name: QueryFragment,
isDistinct: Bool = false,
_ arguments: [QueryFragment] = [],
Expand Down
145 changes: 0 additions & 145 deletions Sources/StructuredQueriesCore/Internal/Deprecations.swift
Original file line number Diff line number Diff line change
Expand Up @@ -126,151 +126,6 @@ extension PrimaryKeyedTable {
}
}

// NB: Deprecated after 0.3.0:

extension Date {
@available(
*,
deprecated,
message: "ISO-8601 text is the default representation and is no longer explicitly needed."
)
public struct ISO8601Representation: QueryRepresentable {
public var queryOutput: Date

public var iso8601String: String {
queryOutput.iso8601String
}

public init(queryOutput: Date) {
self.queryOutput = queryOutput
}

public init(iso8601String: String) throws {
try self.init(queryOutput: Date(iso8601String: iso8601String))
}
}
}

@available(
*,
deprecated,
message: "ISO-8601 text is the default representation and is no longer explicitly needed."
)
extension Date? {
public typealias ISO8601Representation = Date.ISO8601Representation?
}

@available(
*,
deprecated,
message: "ISO-8601 text is the default representation and is no longer explicitly needed."
)
extension Date.ISO8601Representation: QueryBindable {
public var queryBinding: QueryBinding {
.text(queryOutput.iso8601String)
}

public init?(queryBinding: QueryBinding) {
guard
case .text(let iso8601String) = queryBinding,
let queryOutput = try? Date(iso8601String: iso8601String)
else { return nil }
self.init(queryOutput: queryOutput)
}
}

@available(
*,
deprecated,
message: "ISO-8601 text is the default representation and is no longer explicitly needed."
)
extension Date.ISO8601Representation: QueryDecodable {
public init(decoder: inout some QueryDecoder) throws {
try self.init(queryOutput: Date(iso8601String: String(decoder: &decoder)))
}
}

@available(
*,
deprecated,
message: "ISO-8601 text is the default representation and is no longer explicitly needed."
)
extension Date.ISO8601Representation: SQLiteType {
public static var typeAffinity: SQLiteTypeAffinity {
String.typeAffinity
}
}

@available(
*,
deprecated,
message: "Lowercased text is the default representation and is no longer explicitly needed."
)
extension UUID {
public struct LowercasedRepresentation: QueryRepresentable {
public var queryOutput: UUID

public init(queryOutput: UUID) {
self.queryOutput = queryOutput
}
}
}

@available(
*,
deprecated,
message: "Lowercased text is the default representation and is no longer explicitly needed."
)
extension UUID? {
public typealias LowercasedRepresentation = UUID.LowercasedRepresentation?
}

@available(
*,
deprecated,
message: "Lowercased text is the default representation and is no longer explicitly needed."
)
extension UUID.LowercasedRepresentation: QueryBindable {
public var queryBinding: QueryBinding {
.text(queryOutput.uuidString.lowercased())
}

public init?(queryBinding: QueryBinding) {
guard
case .text(let uuidString) = queryBinding,
let uuid = UUID(uuidString: uuidString)
else { return nil }
self.init(queryOutput: uuid)
}
}

@available(
*,
deprecated,
message: "Lowercased text is the default representation and is no longer explicitly needed."
)
extension UUID.LowercasedRepresentation: QueryDecodable {
public init(decoder: inout some QueryDecoder) throws {
guard let uuid = try UUID(uuidString: String(decoder: &decoder)) else {
throw InvalidString()
}
self.init(queryOutput: uuid)
}

private struct InvalidString: Error {}
}

@available(
*,
deprecated,
message: "Lowercased text is the default representation and is no longer explicitly needed."
)
extension UUID.LowercasedRepresentation: SQLiteType {
public static var typeAffinity: SQLiteTypeAffinity {
String.typeAffinity
}
}

// NB: Deprecated after 0.1.1:

@available(*, deprecated, message: "Use 'MyCodableType.JSONRepresentation', instead.")
Expand Down
6 changes: 3 additions & 3 deletions Sources/StructuredQueriesCore/Internal/PrettyPrinting.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import IssueReporting
extension QueryFragment {
@inlinable
@inline(__always)
static var newlineOrSpace: Self {
package static var newlineOrSpace: Self {
#if DEBUG
return isTesting ? "\n" : " "
#else
Expand All @@ -14,7 +14,7 @@ extension QueryFragment {

@inlinable
@inline(__always)
static var newline: Self {
package static var newline: Self {
#if DEBUG
return isTesting ? "\n" : ""
#else
Expand All @@ -26,7 +26,7 @@ extension QueryFragment {
@inlinable
@inline(__always)
#endif
func indented() -> Self {
package func indented() -> Self {
#if DEBUG
guard isTesting else { return self }
var query = self
Expand Down
3 changes: 3 additions & 0 deletions Sources/StructuredQueriesCore/QueryFragment.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ public struct QueryFragment: Hashable, Sendable {
/// An array of segments backing this query fragment.
public internal(set) var segments: [Segment] = []

/// Initializes an empty query fragment.
public init() {}

fileprivate init(segments: [Segment]) {
self.segments = segments
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,6 @@ extension _CodableJSONRepresentation: QueryDecodable {
}
}

extension _CodableJSONRepresentation: SQLiteType {
public static var typeAffinity: SQLiteTypeAffinity {
String.typeAffinity
}
}

private let jsonDecoder: JSONDecoder = {
var decoder = JSONDecoder()
decoder.dateDecodingStrategy = .custom {
Expand Down
5 changes: 4 additions & 1 deletion Sources/StructuredQueriesCore/ScalarFunctions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,10 @@ public struct QueryFunction<QueryValue>: QueryExpression {
let name: QueryFragment
let arguments: [QueryFragment]

init<each Argument: QueryExpression>(_ name: QueryFragment, _ arguments: repeat each Argument) {
package init<each Argument: QueryExpression>(
_ name: QueryFragment,
_ arguments: repeat each Argument
) {
self.name = name
self.arguments = Array(repeat each arguments)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,9 @@ private struct Cast<QueryValue: SQLiteType, Base: QueryExpression>: QueryExpress
extension RawRepresentable where RawValue: SQLiteType {
public static var typeAffinity: SQLiteTypeAffinity { RawValue.typeAffinity }
}

extension _CodableJSONRepresentation: SQLiteType {
public static var typeAffinity: SQLiteTypeAffinity {
String.typeAffinity
}
}
147 changes: 147 additions & 0 deletions Sources/StructuredQueriesSQLiteCore/Internal/Deprecations.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
import Foundation
import StructuredQueriesCore

// NB: Deprecated after 0.3.0:

extension Date {
@available(
*,
deprecated,
message: "ISO-8601 text is the default representation and is no longer explicitly needed."
)
public struct ISO8601Representation: QueryRepresentable {
public var queryOutput: Date

public var iso8601String: String {
queryOutput.iso8601String
}

public init(queryOutput: Date) {
self.queryOutput = queryOutput
}

public init(iso8601String: String) throws {
try self.init(queryOutput: Date(iso8601String: iso8601String))
}
}
}

@available(
*,
deprecated,
message: "ISO-8601 text is the default representation and is no longer explicitly needed."
)
extension Date? {
public typealias ISO8601Representation = Date.ISO8601Representation?
}

@available(
*,
deprecated,
message: "ISO-8601 text is the default representation and is no longer explicitly needed."
)
extension Date.ISO8601Representation: QueryBindable {
public var queryBinding: QueryBinding {
.text(queryOutput.iso8601String)
}

public init?(queryBinding: QueryBinding) {
guard
case .text(let iso8601String) = queryBinding,
let queryOutput = try? Date(iso8601String: iso8601String)
else { return nil }
self.init(queryOutput: queryOutput)
}
}

@available(
*,
deprecated,
message: "ISO-8601 text is the default representation and is no longer explicitly needed."
)
extension Date.ISO8601Representation: QueryDecodable {
public init(decoder: inout some QueryDecoder) throws {
try self.init(queryOutput: Date(iso8601String: String(decoder: &decoder)))
}
}

@available(
*,
deprecated,
message: "ISO-8601 text is the default representation and is no longer explicitly needed."
)
extension Date.ISO8601Representation: SQLiteType {
public static var typeAffinity: SQLiteTypeAffinity {
String.typeAffinity
}
}

@available(
*,
deprecated,
message: "Lowercased text is the default representation and is no longer explicitly needed."
)
extension UUID {
public struct LowercasedRepresentation: QueryRepresentable {
public var queryOutput: UUID

public init(queryOutput: UUID) {
self.queryOutput = queryOutput
}
}
}

@available(
*,
deprecated,
message: "Lowercased text is the default representation and is no longer explicitly needed."
)
extension UUID? {
public typealias LowercasedRepresentation = UUID.LowercasedRepresentation?
}

@available(
*,
deprecated,
message: "Lowercased text is the default representation and is no longer explicitly needed."
)
extension UUID.LowercasedRepresentation: QueryBindable {
public var queryBinding: QueryBinding {
.text(queryOutput.uuidString.lowercased())
}

public init?(queryBinding: QueryBinding) {
guard
case .text(let uuidString) = queryBinding,
let uuid = UUID(uuidString: uuidString)
else { return nil }
self.init(queryOutput: uuid)
}
}

@available(
*,
deprecated,
message: "Lowercased text is the default representation and is no longer explicitly needed."
)
extension UUID.LowercasedRepresentation: QueryDecodable {
public init(decoder: inout some QueryDecoder) throws {
guard let uuid = try UUID(uuidString: String(decoder: &decoder)) else {
throw InvalidString()
}
self.init(queryOutput: uuid)
}

private struct InvalidString: Error {}
}

@available(
*,
deprecated,
message: "Lowercased text is the default representation and is no longer explicitly needed."
)
extension UUID.LowercasedRepresentation: SQLiteType {
public static var typeAffinity: SQLiteTypeAffinity {
String.typeAffinity
}
}
1 change: 1 addition & 0 deletions Tests/StructuredQueriesTests/FTSTests.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Foundation
import InlineSnapshotTesting
import StructuredQueries
import StructuredQueriesSQLite
import StructuredQueriesTestSupport
import Testing

Expand Down
1 change: 1 addition & 0 deletions Tests/StructuredQueriesTests/OperatorsTests.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Foundation
import InlineSnapshotTesting
import StructuredQueries
import StructuredQueriesSQLite
import StructuredQueriesTestSupport
import Testing

Expand Down
Loading