Repository: dolthub/dolt
File: go/libraries/doltcore/doltdb/root_object.go (Go)

Code before:
	Name() TableName
}

// ConflictRootObject is a RootObject that contains conflict information.
type ConflictRootObject interface {
	RootObject
	// DiffCount returns the number of diffs that this conflict will return.
	DiffCount(ctx *sql.Context) (int, error)
	// RemoveDiffs removes the conflicts indicated by the given diffs. Returns an updated root object that will be
	// written to the root.
	RemoveDiffs(ctx *sql.Context, diffs []RootObjectDiff) (ConflictRootObject, error)
	// Rows returns the rows that represent conflicting portions of a root object. These should be able to be converted
	// to a RootObjectDiff via FromRow.
	Rows(ctx *sql.Context) (sql.RowIter, error)
	// Schema returns the schema that should be displayed.
	Schema(originatingTableName string) sql.Schema
	// UpdateField updates the root object by applying the change between the two diffs. Returns an updated root object
	// that will be written to the root.
	UpdateField(ctx *sql.Context, oldDiff RootObjectDiff, newDiff RootObjectDiff) (ConflictRootObject, error)
}

// RootObjectDiff is a diff for the RootObject.
type RootObjectDiff interface {
	// Compare returns an integer from -1 to 1, with 0 meaning the diffs are equal to each other. This only compares the
	// unique identifier for the diff, so different diffs may return that they are equal.
	Compare(ctx context.Context, other RootObjectDiff) (int, error)
	// ToRow returns the diff as a row.
	ToRow(ctx *sql.Context) (sql.Row, error)
}

// RootObjectDiffFromRow returns a diff from the given row.
var RootObjectDiffFromRow = func(ctx *sql.Context, conflict ConflictRootObject, row sql.Row) (RootObjectDiff, error) {
	panic("Dolt impl used")
}


Review comment (suggestion):
It seems a little confusing for Compare to return 0 when the diffs aren't really equal. That'll probably surprise people reading this code in the future. It could help to rename this to something more specific, like `CompareIds()` or something. Otherwise the name seems to imply a different behavior. 

Code after:
	Name() TableName
}

// ConflictRootObject is a RootObject that contains conflict information.
type ConflictRootObject interface {
	RootObject
	// DiffCount returns the number of diffs that this conflict will return.
	DiffCount(ctx *sql.Context) (int, error)
	// RemoveDiffs removes the conflicts indicated by the given diffs. Returns an updated root object that will be
	// written to the root.
	RemoveDiffs(ctx *sql.Context, diffs []RootObjectDiff) (ConflictRootObject, error)
	// Rows returns the rows that represent conflicting portions of a root object. These should be able to be converted
	// to a RootObjectDiff via FromRow.
	Rows(ctx *sql.Context) (sql.RowIter, error)
	// Schema returns the schema that should be displayed.
	Schema(originatingTableName string) sql.Schema
	// UpdateField updates the root object by applying the change between the two diffs. Returns an updated root object
	// that will be written to the root.
	UpdateField(ctx *sql.Context, oldDiff RootObjectDiff, newDiff RootObjectDiff) (ConflictRootObject, error)
}

// RootObjectDiff is a diff for the RootObject.
type RootObjectDiff interface {
	// CompareIds returns an integer from -1 to 1, with 0 meaning the diffs are equal to each other. This only compares the
	// unique identifier for the diff, so different diffs may return that they are equal.
	CompareIds(ctx context.Context, other RootObjectDiff) (int, error)
	// ToRow returns the diff as a row.
	ToRow(ctx *sql.Context) (sql.Row, error)
}

// RootObjectDiffFromRow returns a diff from the given row.
var RootObjectDiffFromRow = func(ctx *sql.Context, conflict ConflictRootObject, row sql.Row) (RootObjectDiff, error) {
	panic("Dolt impl used")
}