fix(plugins): populate referenced schema for SQL Server and Oracle foreign keys#1760
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: efa33538cc
ℹ️ 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".
| referencedTable: refTable, | ||
| referencedColumn: refColumn | ||
| referencedColumn: refColumn, | ||
| referencedSchema: row[safe: 4] ?? nil |
There was a problem hiding this comment.
Pass the parsed schema to mobile FK results
Because this shared parser is also used by TableProMobile/TableProMobile/Drivers/MSSQLDriver.swift, and that call still constructs ForeignKeyInfo without forwarding $0.referencedSchema, SQL Server mobile FK navigation continues to receive a nil schema even though this query now returns it. Please thread the parsed schema through that mapping too; otherwise the cross-schema FK fix only applies to the plugin path.
Useful? React with 👍 / 👎.
Signed-off-by: Ngô Quốc Đạt <datlechin@gmail.com>
Problem
Following a foreign key (FK navigation in the data grid, FK preview) into a table that lives in a different schema opened the wrong table or failed, on SQL Server and Oracle. Found while reviewing #1754.
Root cause
The app already plumbs a referenced schema end to end:
PluginForeignKeyInfo.referencedSchemaexists, andPluginDriverAdaptermaps it into the app'sForeignKeyInfo, which FK navigation reads. But the MSSQL and Oracle FK introspection queries never selected the referenced table's owner/schema, soreferencedSchemawas always nil. FK navigation then fell back to the current schema and qualified against the wrong table.Fix
sr.name AS ref_schema(joiningsys.schemason the referenced table'sschema_id). The single-table path was a duplicate of the unused, testedMSSQLSchemaQueries.foreignKeys, so it now calls that shared query andparseForeignKeyRowinstead of inline SQL.MSSQLForeignKeyRowandparseForeignKeyRowcarryreferencedSchema.rc.OWNER AS REF_SCHEMAand map it intoreferencedSchema.PluginForeignKeyInfo.referencedSchemaalready exists with a defaulted init parameter, so this is additive with no PluginKit ABI change.Tests
TableProMSSQLCoreTests: the FK query selectsref_schema, andparseForeignKeyRowextractsreferencedSchema(and stays nil when the column is absent). 20 pass.Shipping
MSSQL and Oracle are registry-only plugins, so this reaches users after re-releasing both plugins.
Not included: export
The export path (
ExportDataSourceAdapter) also drops schema for non-default-schema tables, but the fix is a separate, larger change:PluginExportTable(a PluginKit transfer type) and thePluginExportDataSourceprotocol methods carry onlydatabaseName, no per-table schema, and the adapter is already inconsistent (it usescurrentSchemafor column/FK fetch butdatabaseNamefor the data query). Threading a real schema through export touches the transfer-type ABI and every export plugin, so it deserves its own scoped change.Relates to #1754
https://claude.ai/code/session_0198faM6VCrViRU4XwRoS1DC