Skip to content
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

Only get types and procedures from unqualified schemas #271

Merged
merged 8 commits into from
Jan 31, 2024

Conversation

plcplc
Copy link
Contributor

@plcplc plcplc commented Jan 30, 2024

What

In order to be able to unambiguously refer to types and procedures (i.e to avoid an issue like hasura/graphql-engine#10100) we want to be sure that we track the schema types and procedures are defined in, similar to how we do tables.

This PR implements a minimal first step on the way to this, by simply only tracking types and procedures defined in schemas appearing in a new unqualifiedSchemasForTypesAndProcedures configuration option.

It is then up to a follow-up PR to implement schema name prefixing.

(Small aside: As an auxiliary improvement, thi PR introduces the use of the regclass etc. types to refer to catalog table entries instead of hardcoding oids. Incidentally this fixes fetching of table and column comments on Cockroach.)

How

We add a new configuration option field unqualifiedSchemasForTypesAndProcedures that defaults to ["public","pg_catalog","tiger"]. During introspection we only look in these schemas for types and procedures.

For consistency we also rename unqualifiedSchemas to unqualifiedSchemasForTables. In order to make this change conservative we still recognize unqualifiedSchemas in the API schema and json parsers, but we will only ever output unqualifiedSchemasForTables from the configuration server.

`generate-chinook-configuration.sh` used to use
`new-configuration.sh`, which unconditionally uses the defaults from the
latest version.
As an auxiliary improvement, use the `regclass` etc. types to refer to
catalog table entries instead of hardcoding oids. Incidentally this
fixes fetching of table and column comments on Cockroach.
@plcplc plcplc requested a review from soupi January 31, 2024 14:21
@plcplc plcplc enabled auto-merge January 31, 2024 14:25
// weirdly, we have to use 'skip_serializing_if' rather than 'skip_serializing', since the
// latter causes schemars to consider the field required, in spite of the 'default' attribute.
#[serde(skip_serializing_if = "always_skip_unqualified_schemas")]
pub unqualified_schemas: Vec<String>,
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you please document the relationship between this field and the others? What happens if this field and the others are defined?

@plcplc plcplc disabled auto-merge January 31, 2024 15:33
@plcplc plcplc enabled auto-merge January 31, 2024 15:40
@plcplc plcplc added this pull request to the merge queue Jan 31, 2024
Merged via the queue into main with commit c11ef5c Jan 31, 2024
26 checks passed
@plcplc plcplc deleted the plc/issues/NDAT-1143 branch January 31, 2024 15:49
@plcplc plcplc restored the plc/issues/NDAT-1143 branch February 1, 2024 10:40
@soupi soupi deleted the plc/issues/NDAT-1143 branch July 30, 2024 08:26
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.

2 participants