Skip to content

Commit

Permalink
Fix pattern-sql bug in model loader
Browse files Browse the repository at this point in the history
Did report %% patterns as regular SQL hint.
  • Loading branch information
helje5 committed Nov 27, 2024
1 parent 88c66c1 commit 3724bdf
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions Sources/ZeeQL/Access/ModelLoader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -398,15 +398,19 @@ open class CoreDataModelLoader : ModelLoader {
}
}
if let xml = xml.firstChildElementWithName("sql") {
// TODO: pattern (it IS being used!)
//<sql>%(select)s %(columns)s FROM %(tables)s %(where)s
// GROUP BY object_id;</sql>
let attrs = xml.attributesAsDict
// <sql>%(select)s %(columns)s FROM %(tables)s %(where)s
// GROUP BY object_id;</sql>
// <sql pattern="true">%%(select)s %%(columns)s
if let v = xml.textContent, !v.isEmpty {
// TODO: put into hints?
// TODO: Constants for the hints, make them Environment like?
// Or at least an `enum`.
let isPattern = boolValue(attrs["pattern"])
let key = isPattern
? "CustomQueryExpressionHintKeyBindPattern"
: "CustomQueryExpressionHintKey"
assert(isPattern || !v.contains("%%"),
"Using pattern %% in non-pattern binding?")
fs.hints[key] = v
}
else {
Expand Down

0 comments on commit 3724bdf

Please sign in to comment.