mirror of
https://github.com/bitechdev/ResolveSpec.git
synced 2025-12-06 14:26:22 +00:00
Fixes on Table Name on insert
This commit is contained in:
parent
640582d508
commit
3d5334002d
@ -319,6 +319,10 @@ func (b *BunInsertQuery) Model(model interface{}) common.InsertQuery {
|
||||
}
|
||||
|
||||
func (b *BunInsertQuery) Table(table string) common.InsertQuery {
|
||||
if b.hasModel {
|
||||
// If model is set, do not override table name
|
||||
return b
|
||||
}
|
||||
b.query = b.query.Table(table)
|
||||
return b
|
||||
}
|
||||
|
||||
@ -663,7 +663,14 @@ func (h *Handler) handleCreate(ctx context.Context, w common.ResponseWriter, dat
|
||||
}
|
||||
|
||||
// Create insert query
|
||||
query := tx.NewInsert().Model(modelValue).Table(tableName).Returning("*")
|
||||
query := tx.NewInsert().Model(modelValue)
|
||||
|
||||
// Only set Table() if the model doesn't provide a table name via TableNameProvider
|
||||
if provider, ok := modelValue.(common.TableNameProvider); !ok || provider.TableName() == "" {
|
||||
query = query.Table(tableName)
|
||||
}
|
||||
|
||||
query = query.Returning("*")
|
||||
|
||||
// Execute BeforeScan hooks - pass query chain so hooks can modify it
|
||||
itemHookCtx := &HookContext{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user