8000 Skip over dropped attributes when enumerating types by TomasHubelbauer · Pull Request #492 · supabase/postgres-meta · GitHub
[go: up one dir, main page]

Skip to content

Skip over dropped attributes when enumerating types #492

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

Merged
merged 2 commits into from
Jan 31, 2023
Merged

Skip over dropped attributes when enumerating types #492

merged 2 commits into from
Jan 31, 2023

Conversation

TomasHubelbauer
Copy link
Contributor
@TomasHubelbauer TomasHubelbauer commented Jan 29, 2023

pg_attribute may contain records for attributes that were dropped but Postgres kept them around and instead of deleting them, renamed them to ........pg.dropped.#........ and set their attisdropped to true.

This ends up generating these dropped attributes as unknown fields in the TypeScript types.

In this commit I updated the types query to not return these.

Maybe it would be preferrable to instead keep these but skip them only when generating the TypeScript types?

What kind of change does this PR introduce?

Feature? Maybe bug fix?

It is arguable whether these dropped attributes should appear in the generated types and be accessible via the Postgres Meta API. I expect folks might lean towards exposing them instead of skipping them. In this case I'd like to contribute a change which adds a new dropped boolean field on types and then skips over dropped types when generating composite types via the TypeScript generator.

What is the current behavior?

Dropped attributes appear in generated TypeScript types.
It used to be that they would appear just as a line saying unknown;.
This seems to have been fixed on master, not they actually display the renamed name:

message_input: {
  "........pg.dropped.11........": unknown
}

See #483 for the PR that fixed this.

Yet these are not useful in the types since they are dropped and I happen to think they shouldn't be in the TypeScript types. It is arguable whether they should be in pgMeta.types.list. I can see an argument for both cases.

What is the new behavior?

pgMeta.types.list skips over attisdropped=true attributes.
As a result, the TypeScript types skip over them as well when generating composite types (among other types?).
I am happy to change the PR to instead skip over these at the TypeScript generator level so they remain accessible in pgMeta.types.list.

@TomasHubelbauer TomasHubelbauer requested a review from a team as a code owner January 29, 2023 22:53
`pg_attribute` may contain records for attributes that were dropped but Postgres kept them around and instead of deleting them, renamed them to `........pg.dropped.#........` and set their `attisdropped` to `true`.

This ends up generating these dropped attributes as `unknown` fields in the TypeScript types.

In this commit I updated the `types` query to not return these.

Maybe it would be preferrable to instead keep these but skip them only when generating the TypeScript types?
@soedirgo
Copy link
Member

Interesting, thanks! Omitting dropped attributes sounds good to me.

@soedirgo soedirgo enabled auto-merge (squash) January 31, 2023 03:36
@soedirgo soedirgo merged commit 9d90f5c into supabase:master Jan 31, 2023
@github-actions
Copy link

🎉 This PR is included in version 0.60.6 🎉

The release is available on:

Your semantic-release bot 📦🚀

@TomasHubelbauer TomasHubelbauer deleted the skip-dropped-attributes branch January 31, 2023 09:36
TomasHubelbauer added a commit to TomasHubelbauer/cli that referenced this pull request Feb 2, 2023
Hi! This is a follow-up to this comment:
supabase/postgres-meta#483 (comment)

I am proposing an update of postgres-meta to version 0.60.6.
I am hoping to make use of supabase/postgres-meta#492 through the Supabase CLI.

As per the above linked comment, I am aware that in general, the postgres-meta version is kept at the same version as what is used on the hosted platform.
This is a minor changes from the current version 0.60.3 so perhaps it will quality for an exception?
I am not sure how I can check what version is live on the hosted platform.

Thanks for considering!
avallete pushed a commit that referenced this pull request May 13, 2025
* Skip over dropped attributes when enumerating types

`pg_attribute` may contain records for attributes that were dropped but Postgres kept them around and instead of deleting them, renamed them to `........pg.dropped.#........` and set their `attisdropped` to `true`.

This ends up generating these dropped attributes as `unknown` fields in the TypeScript types.

In this commit I updated the `types` query to not return these.

Maybe it would be preferrable to instead keep these but skip them only when generating the TypeScript types?

* use `not`

---------

Co-authored-by: Bobbie Soedirgo <bobbie@soedirgo.dev>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0