From 3724bdf28e8578169d70ea47d791de987bf024ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Helge=20He=C3=9F?= Date: Wed, 27 Nov 2024 22:51:51 +0100 Subject: [PATCH] Fix pattern-sql bug in model loader Did report %% patterns as regular SQL hint. --- Sources/ZeeQL/Access/ModelLoader.swift | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Sources/ZeeQL/Access/ModelLoader.swift b/Sources/ZeeQL/Access/ModelLoader.swift index d4274f1..b32b003 100644 --- a/Sources/ZeeQL/Access/ModelLoader.swift +++ b/Sources/ZeeQL/Access/ModelLoader.swift @@ -398,15 +398,19 @@ open class CoreDataModelLoader : ModelLoader { } } if let xml = xml.firstChildElementWithName("sql") { - // TODO: pattern (it IS being used!) - //%(select)s %(columns)s FROM %(tables)s %(where)s - // GROUP BY object_id; + let attrs = xml.attributesAsDict + // %(select)s %(columns)s FROM %(tables)s %(where)s + // GROUP BY object_id; + // %%(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 {