sqlc.yaml (sqlite, schema migrations/, queries migrations/queries/) generates internal/db with emit_interface. Queries cover dinners (create, get, list by status, update, archive, set favorite), recipes with ingredients and steps (upsert by source_url, get, replace children), photos (insert, get by sha256) and get/upsert for the five settings singletons. Repository tests run every query against a migrated temp database. make sqlc regenerates with the pinned sqlc v1.31.1 (dev tool only, not in go.mod); make sqlc-check regenerates and fails on any drift in internal/db, and CI runs it after make test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
322 lines
7.0 KiB
Go
322 lines
7.0 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.31.1
|
|
// source: dinners.sql
|
|
|
|
package db
|
|
|
|
import (
|
|
"context"
|
|
"database/sql"
|
|
)
|
|
|
|
const archiveDinner = `-- name: ArchiveDinner :one
|
|
UPDATE dinners
|
|
SET status = 'archived',
|
|
updated_by = ?,
|
|
updated_at = ?
|
|
WHERE id = ?
|
|
RETURNING id, name, normalized_name, status, origin, method, minutes_total, difficulty, cuisine, is_favorite, recipe_id, photo_id, grounding_status, updated_by, created_at, updated_at
|
|
`
|
|
|
|
type ArchiveDinnerParams struct {
|
|
UpdatedBy sql.NullString
|
|
UpdatedAt string
|
|
ID string
|
|
}
|
|
|
|
// An unknown id returns sql.ErrNoRows.
|
|
func (q *Queries) ArchiveDinner(ctx context.Context, arg ArchiveDinnerParams) (Dinner, error) {
|
|
row := q.db.QueryRowContext(ctx, archiveDinner, arg.UpdatedBy, arg.UpdatedAt, arg.ID)
|
|
var i Dinner
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.Name,
|
|
&i.NormalizedName,
|
|
&i.Status,
|
|
&i.Origin,
|
|
&i.Method,
|
|
&i.MinutesTotal,
|
|
&i.Difficulty,
|
|
&i.Cuisine,
|
|
&i.IsFavorite,
|
|
&i.RecipeID,
|
|
&i.PhotoID,
|
|
&i.GroundingStatus,
|
|
&i.UpdatedBy,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const createDinner = `-- name: CreateDinner :one
|
|
INSERT INTO dinners (
|
|
id, name, normalized_name, status, origin, method, minutes_total,
|
|
difficulty, cuisine, is_favorite, recipe_id, photo_id, grounding_status,
|
|
updated_by, created_at, updated_at
|
|
) VALUES (
|
|
?, ?, ?, ?, ?, ?, ?,
|
|
?, ?, ?, ?, ?, ?,
|
|
?, ?, ?
|
|
)
|
|
RETURNING id, name, normalized_name, status, origin, method, minutes_total, difficulty, cuisine, is_favorite, recipe_id, photo_id, grounding_status, updated_by, created_at, updated_at
|
|
`
|
|
|
|
type CreateDinnerParams struct {
|
|
ID string
|
|
Name string
|
|
NormalizedName string
|
|
Status string
|
|
Origin string
|
|
Method sql.NullString
|
|
MinutesTotal sql.NullInt64
|
|
Difficulty sql.NullString
|
|
Cuisine sql.NullString
|
|
IsFavorite int64
|
|
RecipeID sql.NullString
|
|
PhotoID sql.NullString
|
|
GroundingStatus string
|
|
UpdatedBy sql.NullString
|
|
CreatedAt string
|
|
UpdatedAt string
|
|
}
|
|
|
|
func (q *Queries) CreateDinner(ctx context.Context, arg CreateDinnerParams) (Dinner, error) {
|
|
row := q.db.QueryRowContext(ctx, createDinner,
|
|
arg.ID,
|
|
arg.Name,
|
|
arg.NormalizedName,
|
|
arg.Status,
|
|
arg.Origin,
|
|
arg.Method,
|
|
arg.MinutesTotal,
|
|
arg.Difficulty,
|
|
arg.Cuisine,
|
|
arg.IsFavorite,
|
|
arg.RecipeID,
|
|
arg.PhotoID,
|
|
arg.GroundingStatus,
|
|
arg.UpdatedBy,
|
|
arg.CreatedAt,
|
|
arg.UpdatedAt,
|
|
)
|
|
var i Dinner
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.Name,
|
|
&i.NormalizedName,
|
|
&i.Status,
|
|
&i.Origin,
|
|
&i.Method,
|
|
&i.MinutesTotal,
|
|
&i.Difficulty,
|
|
&i.Cuisine,
|
|
&i.IsFavorite,
|
|
&i.RecipeID,
|
|
&i.PhotoID,
|
|
&i.GroundingStatus,
|
|
&i.UpdatedBy,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const getDinner = `-- name: GetDinner :one
|
|
SELECT id, name, normalized_name, status, origin, method, minutes_total, difficulty, cuisine, is_favorite, recipe_id, photo_id, grounding_status, updated_by, created_at, updated_at FROM dinners
|
|
WHERE id = ?
|
|
`
|
|
|
|
func (q *Queries) GetDinner(ctx context.Context, id string) (Dinner, error) {
|
|
row := q.db.QueryRowContext(ctx, getDinner, id)
|
|
var i Dinner
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.Name,
|
|
&i.NormalizedName,
|
|
&i.Status,
|
|
&i.Origin,
|
|
&i.Method,
|
|
&i.MinutesTotal,
|
|
&i.Difficulty,
|
|
&i.Cuisine,
|
|
&i.IsFavorite,
|
|
&i.RecipeID,
|
|
&i.PhotoID,
|
|
&i.GroundingStatus,
|
|
&i.UpdatedBy,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const listDinnersByStatus = `-- name: ListDinnersByStatus :many
|
|
SELECT id, name, normalized_name, status, origin, method, minutes_total, difficulty, cuisine, is_favorite, recipe_id, photo_id, grounding_status, updated_by, created_at, updated_at FROM dinners
|
|
WHERE status = ?
|
|
ORDER BY normalized_name, id
|
|
`
|
|
|
|
func (q *Queries) ListDinnersByStatus(ctx context.Context, status string) ([]Dinner, error) {
|
|
rows, err := q.db.QueryContext(ctx, listDinnersByStatus, status)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []Dinner
|
|
for rows.Next() {
|
|
var i Dinner
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.Name,
|
|
&i.NormalizedName,
|
|
&i.Status,
|
|
&i.Origin,
|
|
&i.Method,
|
|
&i.MinutesTotal,
|
|
&i.Difficulty,
|
|
&i.Cuisine,
|
|
&i.IsFavorite,
|
|
&i.RecipeID,
|
|
&i.PhotoID,
|
|
&i.GroundingStatus,
|
|
&i.UpdatedBy,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Close(); err != nil {
|
|
return nil, err
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
const setDinnerFavorite = `-- name: SetDinnerFavorite :one
|
|
UPDATE dinners
|
|
SET is_favorite = ?,
|
|
updated_by = ?,
|
|
updated_at = ?
|
|
WHERE id = ?
|
|
RETURNING id, name, normalized_name, status, origin, method, minutes_total, difficulty, cuisine, is_favorite, recipe_id, photo_id, grounding_status, updated_by, created_at, updated_at
|
|
`
|
|
|
|
type SetDinnerFavoriteParams struct {
|
|
IsFavorite int64
|
|
UpdatedBy sql.NullString
|
|
UpdatedAt string
|
|
ID string
|
|
}
|
|
|
|
// An unknown id returns sql.ErrNoRows.
|
|
func (q *Queries) SetDinnerFavorite(ctx context.Context, arg SetDinnerFavoriteParams) (Dinner, error) {
|
|
row := q.db.QueryRowContext(ctx, setDinnerFavorite,
|
|
arg.IsFavorite,
|
|
arg.UpdatedBy,
|
|
arg.UpdatedAt,
|
|
arg.ID,
|
|
)
|
|
var i Dinner
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.Name,
|
|
&i.NormalizedName,
|
|
&i.Status,
|
|
&i.Origin,
|
|
&i.Method,
|
|
&i.MinutesTotal,
|
|
&i.Difficulty,
|
|
&i.Cuisine,
|
|
&i.IsFavorite,
|
|
&i.RecipeID,
|
|
&i.PhotoID,
|
|
&i.GroundingStatus,
|
|
&i.UpdatedBy,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const updateDinner = `-- name: UpdateDinner :one
|
|
UPDATE dinners
|
|
SET name = ?,
|
|
normalized_name = ?,
|
|
status = ?,
|
|
origin = ?,
|
|
method = ?,
|
|
minutes_total = ?,
|
|
difficulty = ?,
|
|
cuisine = ?,
|
|
recipe_id = ?,
|
|
photo_id = ?,
|
|
grounding_status = ?,
|
|
updated_by = ?,
|
|
updated_at = ?
|
|
WHERE id = ?
|
|
RETURNING id, name, normalized_name, status, origin, method, minutes_total, difficulty, cuisine, is_favorite, recipe_id, photo_id, grounding_status, updated_by, created_at, updated_at
|
|
`
|
|
|
|
type UpdateDinnerParams struct {
|
|
Name string
|
|
NormalizedName string
|
|
Status string
|
|
Origin string
|
|
Method sql.NullString
|
|
MinutesTotal sql.NullInt64
|
|
Difficulty sql.NullString
|
|
Cuisine sql.NullString
|
|
RecipeID sql.NullString
|
|
PhotoID sql.NullString
|
|
GroundingStatus string
|
|
UpdatedBy sql.NullString
|
|
UpdatedAt string
|
|
ID string
|
|
}
|
|
|
|
// An unknown id returns sql.ErrNoRows.
|
|
func (q *Queries) UpdateDinner(ctx context.Context, arg UpdateDinnerParams) (Dinner, error) {
|
|
row := q.db.QueryRowContext(ctx, updateDinner,
|
|
arg.Name,
|
|
arg.NormalizedName,
|
|
arg.Status,
|
|
arg.Origin,
|
|
arg.Method,
|
|
arg.MinutesTotal,
|
|
arg.Difficulty,
|
|
arg.Cuisine,
|
|
arg.RecipeID,
|
|
arg.PhotoID,
|
|
arg.GroundingStatus,
|
|
arg.UpdatedBy,
|
|
arg.UpdatedAt,
|
|
arg.ID,
|
|
)
|
|
var i Dinner
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.Name,
|
|
&i.NormalizedName,
|
|
&i.Status,
|
|
&i.Origin,
|
|
&i.Method,
|
|
&i.MinutesTotal,
|
|
&i.Difficulty,
|
|
&i.Cuisine,
|
|
&i.IsFavorite,
|
|
&i.RecipeID,
|
|
&i.PhotoID,
|
|
&i.GroundingStatus,
|
|
&i.UpdatedBy,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return i, err
|
|
}
|