Issue #2570 - Special variables in query language use type from queryscope variables #2598
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The special keywords
i
,ii
,key
, etc., are meant to be reserved and normallythey can't be used in the
QueryScope
. They are blocked by, e.g.,QueryScope.StandaloneImpl.putParam
. However in the Python and Groovy context,they can effectively slip into the
QueryScope
because the user may set themin the underlying session (e.g. by saying
i = 12
) and thenSynchronizedScriptSessionQueryScope
orUnsynchronizedScriptSessionQueryScope
will just pass them through to the caller. With this change, the above classes
filter out the reserved names so the caller does not see them. From the user's
point of view, it is as if the special keywords
i
,ii
,key
, etc. have an innerscope that hides any outer definition of those names.
"While I was here" I also added some entry points for name validation. Previously the only way to check
the validity of a query parameter name was to call
validateQueryParameterName
and catch the exceptionif it fails. I feel it is better style (more runtime-efficient and less verbose) to have validation methods that
simply return a true/false result rather than obligating the caller to catch an exception.
Also to reduce code repetition, I made
SynchronizedScriptSessionQueryScope
a subclass ofUnsynchronizedScriptSessionQueryScope
, delegating all calls to the parent method, but within a synchronized scope.