diff --git a/Sources/ZeeQL/Control/EntityType+Builder.swift b/Sources/ZeeQL/Control/EntityType+Builder.swift index 2a944d3..1506b92 100644 --- a/Sources/ZeeQL/Control/EntityType+Builder.swift +++ b/Sources/ZeeQL/Control/EntityType+Builder.swift @@ -135,11 +135,32 @@ public extension TypedEntityType where FullEntity: CodeEntity { _ value: V ) -> TypedFetchSpecification where V: AttributeValue + { + return `where`(key, .EqualTo, value) + } + + @inlinable + static func `where`( + _ key: Swift.KeyPath>, + _ operation: ComparisonOperation, + _ value: V? + ) -> TypedFetchSpecification + where V: AttributeValue { // if we need no attributes var fs = TypedFetchSpecification(entity: Self.entity) let attribute = Self.e[keyPath: key] - fs.qualifier = KeyValueQualifier(AttributeKey(attribute), .EqualTo, value) + fs.qualifier = KeyValueQualifier(AttributeKey(attribute), operation, value) return fs } + + @inlinable + static func `where`( + _ key: Swift.KeyPath>, + _ value: V? + ) -> TypedFetchSpecification + where V: AttributeValue + { + return `where`(key, .EqualTo, value) + } } diff --git a/Sources/ZeeQL/Control/FetchSpecification+Builder.swift b/Sources/ZeeQL/Control/FetchSpecification+Builder.swift index 8ff91d6..0d46c75 100644 --- a/Sources/ZeeQL/Control/FetchSpecification+Builder.swift +++ b/Sources/ZeeQL/Control/FetchSpecification+Builder.swift @@ -194,6 +194,8 @@ public extension DatabaseFetchSpecification // TODO: select w/ pack iteration + // MARK: - Qualifier + @inlinable func `where`(_ key: Swift.KeyPath>, _ operation: ComparisonOperation, @@ -209,9 +211,30 @@ public extension DatabaseFetchSpecification _ value: V) -> Self where V: AttributeValue { - `where`(key, .EqualTo, value) + return `where`(key, .EqualTo, value) } + @inlinable + func `where`(_ key: Swift.KeyPath>, + _ operation: ComparisonOperation, + _ value: V?) -> Self + where V: AttributeValue + { + let attribute = Object.e[keyPath: key] + return `where`(KeyValueQualifier(AttributeKey(attribute), operation, value)) + } + + @inlinable + func `where`(_ key: Swift.KeyPath>, + _ value: V?) -> Self + where V: AttributeValue + { + return `where`(key, .EqualTo, value) + } + + + // MARK: - Ordering + #if compiler(>=6) func order( by key: repeat Swift.KeyPath>, @@ -239,6 +262,9 @@ public extension DatabaseFetchSpecification } #endif // !compiler(>=6) + + // MARK: - Prefetch + #if compiler(>=6) // TODO: can we do both toOne and toMany in one? // a KeyPath that has the parent class (CodeRelationship) doesn't work?