mirror of
https://github.com/supabase/supabase.git
synced 2026-10-15 06:09:08 +03:00
fix: properly detect primary keys regardless of field type
- Changed useQuickstartData to respect isPrimary flag from AI/templates - Always mark 'id' fields as primary key regardless of data type - Fixes issue where text-type id fields weren't marked as primary
This commit is contained in:
1 parent
2372295edf
commit
cce34fd5b5
1 file changed
+8
-5
@@ -53,9 +53,13 @@ export const useQuickstartData = ({
|
||||
|
||||
const columns: TableField['columns'] = fields.map(
|
||||
(field: QuickstartTableField, index: number) => {
|
||||
const looksLikePrimaryKey =
|
||||
// Check if field is marked as primary or if it's an id field
|
||||
const isPrimaryKey = field.isPrimary === true || field.name === 'id'
|
||||
|
||||
const looksLikeIdentity =
|
||||
field.name === 'id' &&
|
||||
(field.type === 'uuid' || field.type.toLowerCase().includes('int'))
|
||||
field.type.toLowerCase().includes('int') &&
|
||||
!field.default
|
||||
|
||||
return {
|
||||
id: `column-${index}`,
|
||||
@@ -64,9 +68,8 @@ export const useQuickstartData = ({
|
||||
defaultValue: field.default ? String(field.default) : null,
|
||||
isNullable: field.nullable !== false,
|
||||
isUnique: field.unique ?? false,
|
||||
isIdentity:
|
||||
looksLikePrimaryKey && field.type.toLowerCase().includes('int') && !field.default,
|
||||
isPrimaryKey: looksLikePrimaryKey,
|
||||
isIdentity: looksLikeIdentity,
|
||||
isPrimaryKey: isPrimaryKey,
|
||||
comment: field.description || '',
|
||||
isNewColumn: true,
|
||||
table: tableName,
|
||||
|
||||
Reference in new issue
Block a user