Skip to content
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

Remove signature to allow any table name for from #514

Open
olee opened this issue Jan 20, 2024 · 0 comments
Open

Remove signature to allow any table name for from #514

olee opened this issue Jan 20, 2024 · 0 comments

Comments

@olee
Copy link

olee commented Jan 20, 2024

I think the 3rd signature for the from method should be removed which currently allows using any table name inside the postgrest client:

from<
TableName extends string & keyof Schema['Tables'],
Table extends Schema['Tables'][TableName]
>(relation: TableName): PostgrestQueryBuilder<Schema, Table, TableName>
from<ViewName extends string & keyof Schema['Views'], View extends Schema['Views'][ViewName]>(
relation: ViewName
): PostgrestQueryBuilder<Schema, View, ViewName>
from(relation: string): PostgrestQueryBuilder<Schema, any, any>

Currently this makes it quite hard to catch errors when for example removing or renaming tables.


If anyone would like to allow calling from on unknown tables, they could still do it imho by adding an index signature to the schema eg.

type Database = {
    public: {
        Tables: {
            /* standard signatures go here */

            // Allow any table name in from etc
            [key: string]: any;
        }
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant