AQL quotes for parameter substitution (decision)

Add your comments directly to the page. Include links to any relevant research, data, or feedback.

Status

In progress

Impact

Low

Driver

@Pablo Pazos 

Approver

 

Contributors

Informed

 

Due date

Outcome

Background

When using parameters in AQL queries, there is no specification about the use of quotes: if the substitution will or not check for quotes to be present and add if not, or if parameter substitution will not add the queries around the substituted value.

PP:

About this issue, IIRC I detected inconsistencies between implementations on the quotes applied to the parameters, for instance:

Option 1) explicit quotes, substitution doesn’t check or add quotes

select e/ehr_id, e/time_created, e/system_id from EHR e CONTAINS COMPOSITION c WHERE c/archetype_node_id=’$archetype_id’

vs.

Option 2) implicit quotes, substitution check and adds quotes if missing

select e/ehr_id, e/time_created, e/system_id from EHR e CONTAINS COMPOSITION c WHERE c/archetype_node_id=$archetype_id

 

If the implementation does a simple substitution of values, option 1 would be correct, since what finishes in the WHERE condition is a string constant. But if the replacement already considers adding the quotes if those are missing, the second example will work as well.

The issue is: there is no specification around this, or at least I didn’t find it.

This might also be considered as one of those processing rules that we need to define, maybe a “pre-processing” rule in this case.

 

Further reading on discourse: https://discourse.openehr.org/t/aql-3-rules-for-parameter-substitution-on-aql-which-types-will-add-or-not-quotes/251

Options considered

 

Option 1:

Option 2:

 

Option 1:

Option 2:

Pablo

 

Ian

 

Christian

 

Thomas

 

Sebastian I

 

 

 

 

 

 

 

 

 

 

 

 

Action items

Choose which option feels better
Specify in the AQL spec
Adapt REST API specs

Outcome

The quote criteria for parameters should be added to the spec.