emit

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 27, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildDelete

func BuildDelete(d dialect.Dialect, table introspect.Table, row map[string]any) string

BuildDelete renders a single DELETE that targets one row by its primary key. Primary-key column order follows table.PrimaryKey, and composite keys are matched with an AND conjunction. Callers must ensure the table has a primary key (extract.Walk rejects tables without one). Row keys must match Column.Name.

func BuildInsert

func BuildInsert(d dialect.Dialect, table introspect.Table, row map[string]any) string

BuildInsert renders a single INSERT statement for the given row. Columns marked IsGenerated are skipped because the database rejects writes that target them. Column order follows table.Columns to keep output stable. Row keys must match Column.Name; missing keys are treated as NULL.

func SummaryComment

func SummaryComment(cmd string, rows, tables int, forward bool) string

SummaryComment returns the leading SQL comment that prefixes normal (non-plan) output, e.g., "-- subset clone: 3 rows from 3 tables, parents-first".

func WritePlan

func WritePlan(
	w io.Writer,
	cmd string,
	forward bool,
	schema introspect.Schema,
	counts map[string]int,
	order []string,
	seed string,
	elapsed time.Duration,
)

WritePlan renders the --plan summary: a header with table/row totals and one line per collected table, each showing its row count and a representative shortest FK path from the seed. cmd is "clone" or "delete"; forward selects the traversal direction (clone walks to FK parents, delete to referencing children). order lists the collected tables in emit order; counts holds each table's row count.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL