Open ecchochan opened 1 year ago
In the actual version is even worse
const temp: PostgrestSingleResponse<SelectQueryError<"Referencing missing column 'full_name '">[]>
The full_name
property don't appear inside the table type, just on the generated types as funcion
Actually, I found the problem in my case... still a bug, I'm trying to do some workaround on my project.
The problem is here: https://github.com/supabase/postgres-meta/blob/HEAD/src/server/templates/typescript.ts#L101
.filter((fn) => fn.argument_types === table.name)
The parameter of my function is from another schema. Then the fn.argument_types
property has the value like customschema.people
, while the table.name
is just people
In case someone also faces this problem, the way that I solve it was:
import { Database, Json } from "./supabase.ts";
export interface CustomDatabase extends Database {
gestaolocador: {
Tables: {
rentals: {
Row: {
last_due_date: string | null;
next_due_date: string | null;
} & Database["gestaolocador"]["Tables"]["rentals"]["Row"];
} & Database["gestaolocador"]["Tables"]["rentals"];
};
Functions: {
get_rental_by_user: {
Args: {
_user_id: string
}
Returns: {
last_due_date: string | null;
next_due_date: string | null;
}[]
}
}
} & Database["gestaolocador"];
}
export type { CustomDatabase as Database, Json };
I created a custom Database interface that complements the missing fields. This way I can still regenerate the types without redoing my manual changes every time
Bug report
Describe the bug
The below line introduced the bug in v0.61.1 https://github.com/supabase/postgres-meta/blob/e4dc2177cded3e06d07301570b2395099d860d24/src/lib/sql/functions.sql#L44
The above results in computed column typehint always equal to
unknown
To Reproduce
Setup Supabase with the following schema:
Run
Or the following if docker-compose is setup with meta using
v0.61.1
:Expected behavior
The typescript generated should be
Screenshots
The typescript generated is however
System information
Additional context
Reverting the changes of the below resolve the issue https://github.com/supabase/postgres-meta/blob/e4dc2177cded3e06d07301570b2395099d860d24/src/lib/sql/functions.sql#L44