Bug report
Describe the bug
There appears to be a regression in the TypeScript definitions for the Postgrest filter methods, specifically .eq(). Previously, the first argument (the column name) was strictly typed based on the schema of the table selected in .from().
Currently, .eq() is accepting arbitrary string values for the column name without throwing a TypeScript error, even when the column does not exist on the table.
To Reproduce
Schema Context:
Assume a table profiles exists with columns id, avatar_url and username.
import { createBrowserClient } from "@supabase/ssr"
const supabaseUrl = process.env.NEXT_PUBLIC_SUPABASE_URL as string
const supabasePubKey = process.env.NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY as string
type Database = {
public: {
Tables: {
profiles: {
Row: {
id: string
avatar_url: string | null
username: string | null
}
Insert: {
id: string
avatar_url?: string | null
username?: string | null
}
Update: {
id?: string
avatar_url?: string | null
username?: string | null
}
Relationships: []
}
}
Views: {}
Functions: {
authorize: {
Args: {
requested_permission: Database["public"]["Enums"]["app_permission"]
}
Returns: boolean
}
}
CompositeTypes: {
[_ in never]: never
}
}
}
export const supabase = createBrowserClient<Database>(supabaseUrl, supabasePubKey)
supabase.from("profiles").select("*").eq("INVALID", "test")
Observed Behavior:
The code above compiles successfully. The compiler allows "non_existent_column" (or any string) as the first argument to .eq().
Expected Behavior:
TypeScript should raise an error indicating that "non_existent_column" does not exist on the profiles table, similar to how it behaves for .select() or .update().
Additional notes:
.from() and .gt(),.gte(),.lt(),.lte() behave as expected and are typesafe
System information
Bug report
(https://github.com/supabase/supabase/discussions), and Discord.
I found a relevant post in discord however it was never resolved.
Describe the bug
There appears to be a regression in the TypeScript definitions for the Postgrest filter methods, specifically .eq(). Previously, the first argument (the column name) was strictly typed based on the schema of the table selected in .from().
Currently, .eq() is accepting arbitrary string values for the column name without throwing a TypeScript error, even when the column does not exist on the table.
To Reproduce
Schema Context:
Assume a table profiles exists with columns id, avatar_url and username.
Observed Behavior:
The code above compiles successfully. The compiler allows "non_existent_column" (or any string) as the first argument to .eq().
Expected Behavior:
TypeScript should raise an error indicating that "non_existent_column" does not exist on the profiles table, similar to how it behaves for .select() or .update().
Additional notes:
.from() and .gt(),.gte(),.lt(),.lte() behave as expected and are typesafe
System information
OS: [macOS, but tried on Ubuntu 22.04 as welll]
Version of supabase:
But tried also with the latest ssr 0.9.0 and supabase-js 2.98.0, issue remains
Version of Node.js: v20.17.0