-
-
Notifications
You must be signed in to change notification settings - Fork 126
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
Support for range types #840
Comments
While this issue is specifically around range types, I'd love to see a way to be able to handle columns that come from any extension in a generic way. In my case, I have a username column using the I've personally been working around this by hand-editing my type definition files, but as I move to a more automated type generation, and specifically type checks as suggested by the environments document, I can't hand-edit the types the CI generates to check for uncommitted changes. This leaves me with choosing between scripting the changes with a tool like |
I've got a workaround that allows me to type my Say you use If you currently generate your types into import { Database as GeneratedDatabase, Json } from "./_generated_database";
export type { Json };
type Override<
Table extends keyof GeneratedDatabase["public"]["Tables"],
Column extends keyof GeneratedDatabase["public"]["Tables"][Table]["Row"],
RowType,
InsertType = RowType
> = {
public: {
Tables: {
[T in Table]: {
Insert: { [C in Column]: InsertType };
Update: { [C in Column]?: RowType };
Row: { [C in Column]: RowType };
};
};
};
};
export type Database = GeneratedDatabase &
Override<"user", "name" | "email", string> &
Override<"company", "name", string>; The purpose of the 4th generic parameter ( |
FYI - for ranges, I found this advice from Postgrest - https://postgrest.org/en/stable/how-tos/working-with-postgresql-data-types.html?highlight=range#casting-a-range-to-a-json-object |
This might also work for GeoJSON objects using postgis. I'm not sure if casting with a function will change the type generation, but combining this with @BernieSumption's solution might help us find a good fix. I'll test this in a few weeks and let you know how it goes. I also think it's a big problem that the CLI can't change type generation. This forces TypeScript developers to either use |
Feature request
Is your feature request related to a problem? Please describe.
When generating types columns that use a range are being generated with
unknown
.For example:
Will generate:
As there are already several range types in Postgres these should be supported.
The text was updated successfully, but these errors were encountered: