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
Fix table editor unable to update PK after renaming table #21285
Fix table editor unable to update PK after renaming table #21285
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
6 Ignored Deployments
|
Updates to Preview Branch (chore/fix-table-editor-unable-to-update-PK-after-renaming-table) ↗︎
Tasks are run on every commit but only new migration files are pushed.
Connecting to this Preview Branch
Branching Preview Branches by Supabase. |
}: { | ||
projectRef: string | ||
connectionString: string | undefined | ||
payload: CreateColumnPayload | ||
selectedTable: PostgresTable | ||
primaryKey?: Constraint |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why pass in the primary key when it's available on selectedTable.primary_keys
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
{ | ||
enabled: typeof schema !== 'undefined' && typeof table !== 'undefined', | ||
select(data) { | ||
return ((data as any)?.result ?? []).map((constraint: Constraint) => constraint) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this do the same thing? The map isn't doing anything apart from adding types
return ((data as any)?.result ?? []).map((constraint: Constraint) => constraint) | |
return ((data as any)?.result ?? []) as Constraint[] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm maybe the whole map can just be removed entirely then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unless we rewrite it like this?
export const useTableConstraintsQuery = (
{ projectRef, connectionString, schema, table }: TableConstraintsVariables,
options: UseQueryOptions<ExecuteSqlData, TableConstraintsError, Constraint[]> = {}
) => {
return useExecuteSqlQuery(
{
projectRef,
connectionString,
sql: getTableConstraints({ schema, table }),
queryKey: ['table-constraints'],
},
{
enabled: typeof schema !== 'undefined' && typeof table !== 'undefined',
select(data) {
return ((data as any)?.result ?? []) as Constraint[]
},
...options,
}
)
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm maybe the whole map can just be removed entirely then?
oh 🤦 that worked hahaha sorry not sure why i was overcomplicating things haha
Resolves #19341