Skip to content

Commit

Permalink
Rename fetchSpecificiationWith(bindings:) to resolvingBindings
Browse files Browse the repository at this point in the history
Was misspelled and using an old Swift style.
  • Loading branch information
helje5 committed Dec 7, 2024
1 parent af3f209 commit 4f45fc6
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 45 deletions.
26 changes: 6 additions & 20 deletions Sources/ZeeQL/Access/AccessDataSource.swift
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@ public extension AccessDataSourceType {
* }
* ```
*
* This calls ``FetchSpecification/fetchSpecificiationWith(bindings:)-585ip``
* and passes in the given key/value pair (contactId=12345).
* This calls ``FetchSpecification/resolvingBindings(_:)`` and passes in the
* given key/value pair (contactId=12345).
*
* Finally the fetch will be performed using
* ``_primaryFetchObjects``.
Expand All @@ -174,13 +174,7 @@ public extension AccessDataSourceType {
yield: ( Object ) throws -> Void) throws
{
if !binds.isEmpty {
guard let fs = try fetchSpecification
.fetchSpecificiationWith(bindings: binds) else
{
throw AccessDataSourceError
.CouldNotResolveBindings(fetchSpecification: fetchSpecification,
bindings: binds)
}
let fs = try fetchSpecification.resolvingBindings(binds)
try _primaryFetchObjects(fs) { try yield($0) }
}
else {
Expand All @@ -202,8 +196,8 @@ public extension AccessDataSourceType {
*
* This will lookup the `FetchSpecification` named "myContacts" in
* the `Entity` of the datasource. It then calls
* ``FetchSpecification/fetchSpecificiationWith(bindings:)-585ip``
* and passes in the given key/value pair (contactId=12345).
* ``FetchSpecification/resolvingBindings(_:)`` and passes in the given
* key/value pair (contactId=12345).
*
* Finally the fetch will be performed using
* ``_primaryFetchObjects``.
Expand Down Expand Up @@ -351,15 +345,7 @@ public extension AccessDataSourceType {
}

/* apply bindings */
if let qb = qb {
guard let fs = try fs.fetchSpecificiationWith(bindings: qb) else {
throw AccessDataSourceError
.CannotConstructFetchSpecification(.bindingFailed)
}
return fs
}

return fs
return try fs.resolvingBindings(qb)
}

}
11 changes: 2 additions & 9 deletions Sources/ZeeQL/Access/AccessDataSourceFinders.swift
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ public extension AccessDataSource { // Finders
*
* Example:
* ```swift
* let a = personDataSource.find("firstCustomer")
* let a = personDataSource.find("firstCustomer") // fetchspec
* ```
* or:
* ```swift
Expand All @@ -260,14 +260,7 @@ public extension AccessDataSource { // Finders
func find(_ name: String, _ bindings: Any? = nil) throws -> Object? {
guard let entity = entity else { return nil }
guard var fs = entity[fetchSpecification: name] else { return nil }

if let bindings = bindings {
guard let cfs = try fs.fetchSpecificiationWith(bindings: bindings) else {
return nil
}
fs = cfs
}

fs = try fs.resolvingBindings(bindings)
return try find(fs)
}
/**
Expand Down
25 changes: 9 additions & 16 deletions Sources/ZeeQL/Control/FetchSpecification.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public protocol FetchSpecification : SmartDescription {
var hints : [ String : Any ] { get set }
subscript(hint h: String) -> Any? { get set }

func fetchSpecificiationWith(bindings: Any?) throws -> FetchSpecification?
func resolvingBindings(_ bindings: Any?) throws -> FetchSpecification
}

public protocol AdaptorRecordFetchSpecification : FetchSpecification {
Expand Down Expand Up @@ -111,18 +111,18 @@ extension FetchSpecification { // Default Imp
}

/**
* Return a copy of the fetch specification which has the qualifier bindings
* resolved against the given argument. Plus all xyzBindPattern hints.
* Return a copy of the ``FetchSpecification`` which has the qualifier
* bindings resolved against the given argument. Plus all xyzBindPattern
* hints.
* If the fetch spec has no bindings, the exisiting object is returned.
*
* The syntax for bindings in string qualifiers is $binding (e.g.
* lastname = $lastname).
* The syntax for bindings in string qualifiers is `$binding` (e.g.
* `lastname = $lastname`).
*
* The syntax for bind-pattern hints is '%(binding)s'.
* The syntax for bind-pattern hints is `%(binding)s` (note the trailing
* format specifier!).
*/
public func fetchSpecificiationWithBindings(_ bindings: Any?) throws
-> FetchSpecification?
{
public func resolvingBindings(_ bindings: Any?) throws -> FetchSpecification {
var boundFS = self

boundFS.hints = resolveHintBindPatternsWith(bindings: bindings)
Expand All @@ -135,13 +135,6 @@ extension FetchSpecification { // Default Imp

return boundFS
}

@inlinable // TODO: deprecate
public func fetchSpecificiationWith(bindings: Any?) throws
-> FetchSpecification?
{
return try fetchSpecificiationWithBindings(bindings)
}
}


Expand Down

0 comments on commit 4f45fc6

Please sign in to comment.