Skip to content

Conversation

@gmagnu
Copy link
Contributor

@gmagnu gmagnu commented Oct 15, 2025

  • Always use common command substitution in sql.
  • Consolidate command substitution logic.

@github-actions
Copy link

Junit Tests - Summary

4 329 tests  ±0   4 164 ✅ ±0   11m 16s ⏱️ +16s
  457 suites +1     165 💤 ±0 
  457 files   +1       0 ❌ ±0 

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.
gorsat.process.UTestGorJavaUtilities ‑ testProjectIdReplacement
gorsat.process.UTestGorJavaUtilities ‑ testProjectReplacement
org.gorpipe.gor.util.UTestCommandSubstitutions ‑ testUpdateMapFromSecurityContext
org.gorpipe.gor.util.UTestCommandSubstitutions ‑ testUpdateMapWithProjectInfo

Copy link

@rickbowman-dev63 rickbowman-dev63 left a 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

Comment on lines 21 to 22
public static final String KEY_PROJECT_ID = "project_id"; // Project id
public static final String KEY_DB_PROJECT_ID = "project-id"; // project id

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How are these different?

Copy link
Contributor Author

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.

Comment on lines 20 to 24
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

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.

Copy link
Contributor Author

@gmagnu gmagnu Oct 20, 2025

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());

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?

Copy link
Contributor Author

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);

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.

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) {

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?

Copy link
Contributor Author

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.

@gmagnu gmagnu merged commit ac9d1f8 into main Oct 20, 2025
1 check passed
@gmagnu gmagnu deleted the ENGKNOW-2760-norsql-add-project-id-support-like-we-have-for-db-links branch October 20, 2025 22:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants