-
Notifications
You must be signed in to change notification settings - Fork 14
fix(ENGKNOW-2746): Always use common command substitution in sql. #73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(ENGKNOW-2746): Always use common command substitution in sql. #73
Conversation
gmagnu
commented
Oct 15, 2025
- Always use common command substitution in sql.
- Consolidate command substitution logic.
…solidate command substitution logic.
Junit Tests - Summary4 329 tests ±0 4 164 ✅ ±0 11m 16s ⏱️ +16s Results for commit e0e219c. ± Comparison against base commit c18b082. This pull request removes 2 and adds 2 tests. Note that renamed tests count towards both. |
rickbowman-dev63
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had a few comments and questions
| public static final String KEY_PROJECT_ID = "project_id"; // Project id | ||
| public static final String KEY_DB_PROJECT_ID = "project-id"; // project id |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How are these different?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question, each version has been used in different parts of GOR. Ofcourse it would be good do use either version but that means tracking down the use of the other and change it.
| public static final String KEY_PROJECT = "project"; // Project name | ||
| public static final String KEY_PROJECT_ID = "project_id"; // Project id | ||
| public static final String KEY_DB_PROJECT_ID = "project-id"; // project id | ||
| public static final String KEY_ORGANIZATION_ID = "organization_id"; // Organization name | ||
| public static final String KEY_DB_ORGANIZATION_ID = "organization-id"; // organization id |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you need the comment? It seems redundant with the variable name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it is as the comments look now.
| var key = entry.getKey(); | ||
| var value = entry.getValue(); | ||
| if (value != null) { | ||
| command = command.replace("#{" + key + "}", value.toString()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to update the GOR documentation for this? Or is it a known feature in GOR query language?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe it is already documented for SQL commands, but it could be documented better. We could also pick a format (project_id vs project-id), but that is a big project as we need to track town all queries using this (including sql link files).
| map.put(KEY_REQUEST_ID, session.getRequestId()); | ||
|
|
||
| return updateMapFromProjectContext(session.getProjectContext(), map); | ||
| //updateMapFromSecurityContext(session.getProjectContext().getFileReader().getSecurityContext(), map); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this comment be removed?
| import java.util.Map; | ||
| import java.util.stream.Collectors; | ||
|
|
||
| // TODO: Should be synced with CommandSubstitutions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know if I understand what this comment was suggesting, but did these changes accomplish that?
| return query; | ||
| } | ||
|
|
||
| public static String[] splitResourceHints(String query, String validStart) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Were all of these unused?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved those into the CommandSubstitution class.
…solidate command substitution logic.