You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We are working with an order table and see unexpected behavior when generating types. This behavior may be due to the unfortunate use of a reserved word as a table name. We are already planning to update the table name in the future which resolves this issue, but wanted to at least surface the behavior.
To Reproduce
Steps to reproduce the behavior, please provide code snippets or a repository:
Create two tables with an id column, one called hotel, another called order.
Run the below SQL to create functions
CREATE OR REPLACE FUNCTION public.test_func1(hotel)
RETURNS text
LANGUAGE sql
AS $function$
SELECT $1.id::text;
$function$;
CREATE OR REPLACE FUNCTION public.test_func2("order")
RETURNS text
LANGUAGE sql
AS $function$
SELECT $1.id::text;
$function$;
Generate DB types using the supabase CLI (we use supabase gen types typescript --local --schema public > src/generated/supabase.ts)
Expected behavior
We expect to see the created functions added as properties in the generated DB types for the order and profile tables, but this is missing from the order table.
Screenshots
Code snipping below showing the generated types not including test_func2 on the order table.
export type Json =
| string
| number
| boolean
| null
| { [key: string]: Json | undefined }
| Json[]
export type Database = {
public: {
Tables: {
hotel: {
Row: {
id: number
test_func1: string | null
}
Insert: {
id?: number
}
Update: {
id?: number
}
Relationships: []
}
order: {
Row: {
id: number
}
Insert: {
id?: number
}
Update: {
id?: number
}
Relationships: []
}
}
Views: {
[_ in never]: never
}
Functions: {
test_func1: {
Args: {
"": unknown
}
Returns: string
}
test_func2: {
Args: {
"": unknown
}
Returns: string
}
}
Enums: {
[_ in never]: never
}
CompositeTypes: {
[_ in never]: never
}
}
}
type PublicSchema = Database[Extract<keyof Database, "public">]
export type Tables<
PublicTableNameOrOptions extends
| keyof (PublicSchema["Tables"] & PublicSchema["Views"])
| { schema: keyof Database },
TableName extends PublicTableNameOrOptions extends { schema: keyof Database }
? keyof (Database[PublicTableNameOrOptions["schema"]]["Tables"] &
Database[PublicTableNameOrOptions["schema"]]["Views"])
: never = never,
> = PublicTableNameOrOptions extends { schema: keyof Database }
? (Database[PublicTableNameOrOptions["schema"]]["Tables"] &
Database[PublicTableNameOrOptions["schema"]]["Views"])[TableName] extends {
Row: infer R
}
? R
: never
: PublicTableNameOrOptions extends keyof (PublicSchema["Tables"] &
PublicSchema["Views"])
? (PublicSchema["Tables"] &
PublicSchema["Views"])[PublicTableNameOrOptions] extends {
Row: infer R
}
? R
: never
: never
export type TablesInsert<
PublicTableNameOrOptions extends
| keyof PublicSchema["Tables"]
| { schema: keyof Database },
TableName extends PublicTableNameOrOptions extends { schema: keyof Database }
? keyof Database[PublicTableNameOrOptions["schema"]]["Tables"]
: never = never,
> = PublicTableNameOrOptions extends { schema: keyof Database }
? Database[PublicTableNameOrOptions["schema"]]["Tables"][TableName] extends {
Insert: infer I
}
? I
: never
: PublicTableNameOrOptions extends keyof PublicSchema["Tables"]
? PublicSchema["Tables"][PublicTableNameOrOptions] extends {
Insert: infer I
}
? I
: never
: never
export type TablesUpdate<
PublicTableNameOrOptions extends
| keyof PublicSchema["Tables"]
| { schema: keyof Database },
TableName extends PublicTableNameOrOptions extends { schema: keyof Database }
? keyof Database[PublicTableNameOrOptions["schema"]]["Tables"]
: never = never,
> = PublicTableNameOrOptions extends { schema: keyof Database }
? Database[PublicTableNameOrOptions["schema"]]["Tables"][TableName] extends {
Update: infer U
}
? U
: never
: PublicTableNameOrOptions extends keyof PublicSchema["Tables"]
? PublicSchema["Tables"][PublicTableNameOrOptions] extends {
Update: infer U
}
? U
: never
: never
export type Enums<
PublicEnumNameOrOptions extends
| keyof PublicSchema["Enums"]
| { schema: keyof Database },
EnumName extends PublicEnumNameOrOptions extends { schema: keyof Database }
? keyof Database[PublicEnumNameOrOptions["schema"]]["Enums"]
: never = never,
> = PublicEnumNameOrOptions extends { schema: keyof Database }
? Database[PublicEnumNameOrOptions["schema"]]["Enums"][EnumName]
: PublicEnumNameOrOptions extends keyof PublicSchema["Enums"]
? PublicSchema["Enums"][PublicEnumNameOrOptions]
: never
System information
OS: [e.g. macOS]
Version of supabase-js: [e.g. 2.39.7]
Version of Node.js: [e.g. 20.11.0]
Additional context
Appreciate anyone taking the time to check this one out!
The text was updated successfully, but these errors were encountered:
I assume this is because the function argument "order" is quoted, and the quotes result in an inability to match with the table name. Some of the code in this repo for pulling the schema is using pg_get_function_arguments() which does return "order" for this function.
Bug report
Describe the bug
We are working with an
order
table and see unexpected behavior when generating types. This behavior may be due to the unfortunate use of a reserved word as a table name. We are already planning to update the table name in the future which resolves this issue, but wanted to at least surface the behavior.To Reproduce
Steps to reproduce the behavior, please provide code snippets or a repository:
id
column, one calledhotel
, another calledorder
.supabase gen types typescript --local --schema public > src/generated/supabase.ts
)Expected behavior
We expect to see the created functions added as properties in the generated DB types for the
order
andprofile
tables, but this is missing from theorder
table.Screenshots
Code snipping below showing the generated types not including
test_func2
on the order table.System information
Additional context
Appreciate anyone taking the time to check this one out!
The text was updated successfully, but these errors were encountered: