From ab8f79ae37222aa35f6a950df651f3d74e189fbc Mon Sep 17 00:00:00 2001 From: "tiffany.cheng" Date: Thu, 14 May 2026 14:36:36 +0100 Subject: [PATCH 1/2] Fix: clean parameter name in query_builder --- mario/query_builder.py | 4 +++- setup.py | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/mario/query_builder.py b/mario/query_builder.py index 1dd3c03..84ad1c0 100644 --- a/mario/query_builder.py +++ b/mario/query_builder.py @@ -1,4 +1,5 @@ import logging +import re from copy import copy from typing import List @@ -172,7 +173,8 @@ def create_constraints(self, q): column = self.mapping.as_physical[constraint.item] placeholders = [] for i in range(len(constraint.allowed_values)): - parameter_name = column.replace(" ", "_") + str(i) + safe_column = re.sub(r'[^a-zA-Z0-9]', '_', column) + parameter_name = safe_column + str(i) # Postgres style. # TODO Probably need some way of identifying which parameter style to apply. parameter = Parameter('%('+parameter_name+')s') diff --git a/setup.py b/setup.py index 310aff7..24a3869 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ setup( name='mario-pipeline-tools', - version='0.62', + version='0.63', packages=['mario'], url='https://github.com/JiscDACT/mario', license='all rights reserved', From cb66a63dc663c273f8b47442dd7d13d189e7772b Mon Sep 17 00:00:00 2001 From: "tiffany.cheng" Date: Thu, 14 May 2026 14:40:24 +0100 Subject: [PATCH 2/2] Fix: use to_snake_case function to clean parameter name in query_builder --- mario/query_builder.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/mario/query_builder.py b/mario/query_builder.py index 84ad1c0..c5110c9 100644 --- a/mario/query_builder.py +++ b/mario/query_builder.py @@ -1,5 +1,4 @@ import logging -import re from copy import copy from typing import List @@ -9,6 +8,7 @@ from mario.dataset_specification import DatasetSpecification from mario.metadata import Metadata from mario.mapping import FieldMapping +from mario.utils import to_snake_case logger = logging.getLogger(__name__) @@ -173,8 +173,7 @@ def create_constraints(self, q): column = self.mapping.as_physical[constraint.item] placeholders = [] for i in range(len(constraint.allowed_values)): - safe_column = re.sub(r'[^a-zA-Z0-9]', '_', column) - parameter_name = safe_column + str(i) + parameter_name = to_snake_case(column) + str(i) # Postgres style. # TODO Probably need some way of identifying which parameter style to apply. parameter = Parameter('%('+parameter_name+')s')