fix(gaussdb): inherit PostgreSQL indexes(), drop 'public' from systemSchemas, add getSqlEditorHints - #13
fix(gaussdb): inherit PostgreSQL indexes(), drop 'public' from systemSchemas, add getSqlEditorHints#13HandSonic wants to merge 1 commit into
Conversation
…Schemas, add getSqlEditorHints (code review follow-up)
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 04327895cd
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| Method indexes = GaussDBMetaData.class.getMethod( | ||
| "indexes", Connection.class, String.class, String.class, String.class); | ||
|
|
||
| assertEquals(PostgreSQLMetaData.class, indexes.getDeclaringClass()); |
There was a problem hiding this comment.
Populate the referenced side of inherited foreign keys
When a GaussDB foreign key uses different local and referenced column names, such as customer_id referencing customer.id, the newly inherited PostgreSQLMetaData.indexes() selects both Column_name and Foreign_column_name but stores Column_name in foreignColumnNamelist (PostgreSQLMetaData.java:638-647). The GaussDB metadata response therefore reports the local column as the referenced column, and the table editor/SQL builder can produce an invalid REFERENCES clause. Correct the mapping and verify the local columnList with a result-set-focused GaussDB test instead of only asserting the declaring class.
AGENTS.md reference: AGENTS.md:L144-L145
Useful? React with 👍 / 👎.
| class GaussDBMetaDataTest { | ||
|
|
||
| @Test | ||
| void indexesInheritsPostgreSqlImplementationWithTypesAndForeignKeys() throws Exception { |
There was a problem hiding this comment.
Scope inherited constraint joins to the selected schema
In a GaussDB database where two schemas reuse a foreign-key constraint name, the inherited SELECT_KEY_INDEX joins key_column_usage and constraint_column_usage to the filtered constraint only by constraint_name (PostgreSQLMetaDataConstants.java:54). Rows from the other schema are consequently mixed into the selected table's foreign-key metadata, potentially changing the reported target schema/table and duplicating columns. Qualify both joins by constraint catalog/schema and name, or provide a GaussDB-specific query, and cover repeated constraint names across schemas.
AGENTS.md reference: AGENTS.md:L144-L145
Useful? React with 👍 / 👎.
|
|
||
| @Test | ||
| void indexesInheritsPostgreSqlImplementationWithTypesAndForeignKeys() throws Exception { | ||
| Method indexes = GaussDBMetaData.class.getMethod( |
There was a problem hiding this comment.
Bind inherited index-query names as parameters
For a valid quoted GaussDB schema or table whose name contains a single quote, the old JDBC metadata call accepted the name as a value, but the inherited implementation now interpolates it into the single-quoted SELECT_KEY_INDEX and SELECT_TABLE_INDEX predicates with String.format (PostgreSQLMetaData.java:628,658). Opening the index list for an object such as "team's_data" therefore produces malformed SQL, and request-supplied names can also alter the predicate. Execute both metadata queries with bound schema/table parameters and add coverage using quote-containing identifiers.
AGENTS.md reference: AGENTS.md:L144-L145
Useful? React with 👍 / 👎.
| @Test | ||
| void indexesInheritsPostgreSqlImplementationWithTypesAndForeignKeys() throws Exception { | ||
| Method indexes = GaussDBMetaData.class.getMethod( | ||
| "indexes", Connection.class, String.class, String.class, String.class); |
There was a problem hiding this comment.
Preserve null-schema index lookups
When the table-detail or index-list API identifies a GaussDB table without a schema, which TableDetailQueryRequest permits, the removed override passed null to JDBC metadata so the schema was not restricted. The inherited implementation instead formats the null value into TABLE_SCHEMA = 'null' and nspname = 'null', returning an empty index list even for a table on the connection's active search path. Retain the previous null-schema behavior or resolve the active schema before running the PostgreSQL queries, and cover this compatibility case.
AGENTS.md reference: AGENTS.md:L56-L58
Useful? React with 👍 / 👎.
Fixes verified review findings: GaussDBMetaData overrode indexes() with a stub instead of inheriting the working PostgreSQL implementation; gaussdb.json listed 'public' among system schemas, hiding user tables; the syntax plugin lacked editor hints. Regression tests added; gaussdb module tests 6/6 green. Part of OtterMind#2281.