@@ -260,7 +260,7 @@ func (h *Handler) handleRead(ctx context.Context, w common.ResponseWriter, id st
260260 query = query .ColumnExpr ("(?) AS " + colName , colExpr )
261261 for colIndex := range options .Columns {
262262 if options .Columns [colIndex ] == colName {
263- //Remove the computed column from the selected columns to avoid duplication
263+ // Remove the computed column from the selected columns to avoid duplication
264264 options .Columns = append (options .Columns [:colIndex ], options .Columns [colIndex + 1 :]... )
265265 break
266266 }
@@ -274,7 +274,7 @@ func (h *Handler) handleRead(ctx context.Context, w common.ResponseWriter, id st
274274 query = query .ColumnExpr ("(?) AS " + cu .Name , cu .Expression )
275275 for colIndex := range options .Columns {
276276 if options .Columns [colIndex ] == cu .Name {
277- //Remove the computed column from the selected columns to avoid duplication
277+ // Remove the computed column from the selected columns to avoid duplication
278278 options .Columns = append (options .Columns [:colIndex ], options .Columns [colIndex + 1 :]... )
279279 break
280280 }
@@ -305,13 +305,13 @@ func (h *Handler) handleRead(ctx context.Context, w common.ResponseWriter, id st
305305 }
306306 // Note: Expand would require JOIN implementation
307307 // For now, we'll use Preload as a fallback
308- //query = query.Preload(expand.Relation)
308+ // query = query.Preload(expand.Relation)
309309 if options .Preload == nil {
310310 options .Preload = make ([]common.PreloadOption , 0 )
311311 }
312312 skip := false
313- for _ , existing := range options .Preload {
314- if existing .Relation == expand .Relation {
313+ for idx := range options .Preload {
314+ if options . Preload [ idx ] .Relation == expand .Relation {
315315 skip = true
316316 continue
317317 }
@@ -327,7 +327,8 @@ func (h *Handler) handleRead(ctx context.Context, w common.ResponseWriter, id st
327327 }
328328
329329 // Apply preloading
330- for _ , preload := range options .Preload {
330+ for idx := range options .Preload {
331+ preload := options .Preload [idx ]
331332 logger .Debug ("Applying preload: %s" , preload .Relation )
332333 query = query .PreloadRelation (preload .Relation , func (sq common.SelectQuery ) common.SelectQuery {
333334 if len (preload .OmitColumns ) > 0 {
@@ -972,7 +973,7 @@ func (h *Handler) handleDelete(ctx context.Context, w common.ResponseWriter, id
972973 continue
973974 }
974975
975- query := tx .NewDelete ().Table (tableName ).Where (fmt .Sprintf ("%s = ?" , common .QuoteIdent (reflection .GetPrimaryKeyName (tableName ))), itemID )
976+ query := tx .NewDelete ().Table (tableName ).Where (fmt .Sprintf ("%s = ?" , common .QuoteIdent (reflection .GetPrimaryKeyName (model ))), itemID )
976977
977978 result , err := query .Exec (ctx )
978979 if err != nil {
@@ -1039,7 +1040,7 @@ func (h *Handler) handleDelete(ctx context.Context, w common.ResponseWriter, id
10391040 continue
10401041 }
10411042
1042- query := tx .NewDelete ().Table (tableName ).Where (fmt .Sprintf ("%s = ?" , common .QuoteIdent (reflection .GetPrimaryKeyName (tableName ))), itemID )
1043+ query := tx .NewDelete ().Table (tableName ).Where (fmt .Sprintf ("%s = ?" , common .QuoteIdent (reflection .GetPrimaryKeyName (model ))), itemID )
10431044 result , err := query .Exec (ctx )
10441045 if err != nil {
10451046 return fmt .Errorf ("failed to delete record %v: %w" , itemID , err )
@@ -1090,7 +1091,7 @@ func (h *Handler) handleDelete(ctx context.Context, w common.ResponseWriter, id
10901091 continue
10911092 }
10921093
1093- query := tx .NewDelete ().Table (tableName ).Where (fmt .Sprintf ("%s = ?" , common .QuoteIdent (reflection .GetPrimaryKeyName (tableName ))), itemID )
1094+ query := tx .NewDelete ().Table (tableName ).Where (fmt .Sprintf ("%s = ?" , common .QuoteIdent (reflection .GetPrimaryKeyName (model ))), itemID )
10941095 result , err := query .Exec (ctx )
10951096 if err != nil {
10961097 return fmt .Errorf ("failed to delete record %v: %w" , itemID , err )
@@ -1150,7 +1151,7 @@ func (h *Handler) handleDelete(ctx context.Context, w common.ResponseWriter, id
11501151 return
11511152 }
11521153
1153- query = query .Where (fmt .Sprintf ("%s = ?" , common .QuoteIdent (reflection .GetPrimaryKeyName (tableName ))), id )
1154+ query = query .Where (fmt .Sprintf ("%s = ?" , common .QuoteIdent (reflection .GetPrimaryKeyName (model ))), id )
11541155
11551156 // Execute BeforeScan hooks - pass query chain so hooks can modify it
11561157 hookCtx .Query = query
0 commit comments