tessl install tessl/golang-gorm-io--gorm@1.31.0Full-featured ORM library for Golang with associations, hooks, transactions, migrations, and developer-friendly chainable API
Agent Success
Agent success rate when using this tile
81%
Improvement
Agent success rate improvement when using this tile compared to baseline
1.13x
Baseline
Agent success rate without this tile
72%
Build an order processing function that uses transaction savepoints to handle failures gracefully.
Process an order containing multiple items within a single transaction. For each item, create a savepoint before attempting to add it. If adding an item fails (e.g., insufficient inventory), roll back to that savepoint and skip the item. Successfully added items should be preserved.
The function should:
Use the following models:
type Order struct {
ID uint
CustomerID uint
TotalAmount float64
Status string
CreatedAt time.Time
}
type LineItem struct {
ID uint
OrderID uint
ProductID uint
Quantity int
Price float64
}
type Inventory struct {
ID uint
ProductID uint
Quantity int
}@generates
Implement a function with the following signature:
package main
import (
"gorm.io/gorm"
)
// ProcessOrder processes an order with savepoint-based error recovery.
// Returns the created order ID and any error encountered.
// If no items can be added, returns an error and rolls back everything.
func ProcessOrder(db *gorm.DB, customerID uint, items []OrderItem) (uint, error)
// OrderItem represents a requested order item
type OrderItem struct {
ProductID uint
Quantity int
Price float64
}Provides ORM functionality and transaction management with savepoint support.
@satisfied-by