Documentation ¶
Overview ¶
Package diff contains sq's diff implementation. There are two package entrypoints: ExecSourceDiff and ExecTableDiff.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExecSourceDiff ¶
func ExecSourceDiff(ctx context.Context, cfg *Config, src1, src2 *source.Source) (hasDiffs bool, err error)
ExecSourceDiff is the entrypoint to diff two sources, handle1 and handle2. If differences are found, hasDiffs returns true.
Contrast with ExecTableDiff, which diffs two tables.
func ExecTableDiff ¶
func ExecTableDiff(ctx context.Context, cfg *Config, src1 *source.Source, table1 string, src2 *source.Source, table2 string, ) (hasDiffs bool, err error)
ExecTableDiff is the entrypoint to diff two tables, src1.table1 and src2.table2.
If differences are found, hasDiffs returns true.
Contrast with ExecSourceDiff, which diffs two sources.
Types ¶
type Config ¶
type Config struct { // Run is the main program run.Run instance. Run *run.Run // Modes specifies what diff modes to use. Modes *Modes // RecordHunkWriter generates a diff hunk for pairs of records. RecordHunkWriter RecordHunkWriter // Printing is the output.Printing instance to use when generating diff text. Printing *output.Printing // Colors is the diff colors to use when generating diff text. It may be // modified by the diff package; pass a clone if the original should not be // modified. Colors *diffdoc.Colors // Lines specifies the number of lines of context surrounding a diff. Lines int // HunkMaxSize specifies the maximum number of items in a diff hunk. HunkMaxSize int // Concurrency specifies the maximum number of concurrent diff executions. // Zero indicates sequential execution; a negative values indicates unbounded // concurrency. Concurrency int // StopAfter specifies the number of diffs to execute before stopping. StopAfter int }
Config contains parameters to control diff behavior.
type Modes ¶ added in v0.48.0
type Modes struct { // Overview compares a summary of the sources. Overview bool // DBProperties compares DB properties. DBProperties bool // Schema compares table/schema structure. Schema bool // RowCount compares table row count when comparing schemata. RowCount bool // Data compares each row in a table. Caution: this can be slow. Data bool }
Modes determines what diff modes to execute.
type RecordHunkWriter ¶ added in v0.48.0
type RecordHunkWriter interface { // WriteHunk writes a diff hunk to dest for the given record pairs. WriteHunk(ctx context.Context, dest *diffdoc.Hunk, rm1, rm2 record.Meta, pairs []record.Pair) }
RecordHunkWriter generates a diff hunk for pairs of records in a particular diff output format.
func NewRecordHunkWriterAdapter ¶ added in v0.48.0
func NewRecordHunkWriterAdapter(pr *output.Printing, rw output.NewRecordWriterFunc, lines int) RecordHunkWriter
NewRecordHunkWriterAdapter bridges RecordHunkWriter and output.RecordWriter for diff output formats that don't implement a native RecordHunkWriter.