mirror of
https://github.com/dolthub/dolt.git
synced 2026-03-14 19:20:44 -05:00
Bug fixes, new schema diff interface
This commit is contained in:
@@ -57,7 +57,7 @@ type RowDiffer interface {
|
||||
Close() error
|
||||
}
|
||||
|
||||
// SqlRowDiffWriter knows how to write diff rows to an arbitrary format and destination.
|
||||
// SqlRowDiffWriter knows how to write diff rows for a table to an arbitrary format and destination.
|
||||
type SqlRowDiffWriter interface {
|
||||
// WriteRow writes the diff row given, of the diff type provided. colDiffTypes is guaranteed to be the same length as
|
||||
// the input row.
|
||||
@@ -67,5 +67,16 @@ type SqlRowDiffWriter interface {
|
||||
Close(ctx context.Context) error
|
||||
}
|
||||
|
||||
// SchemaDiffWriter knows how to write SQL DDL statements for a schema diff for a table to an arbitrary format and
|
||||
// destination.
|
||||
type SchemaDiffWriter interface {
|
||||
// WriteSchemaDiff writes the schema diff given (a SQL statement) and returns any error. A single table may have
|
||||
// many SQL statements for a single diff.
|
||||
WriteSchemaDiff(ctx context.Context, schemaDiffStatement string) error
|
||||
|
||||
// Close finalizes the work of this writer.
|
||||
Close(ctx context.Context) error
|
||||
}
|
||||
|
||||
// ColorFunc is a function that can color a format string
|
||||
type ColorFunc func(a ...interface{}) string
|
||||
|
||||
@@ -35,10 +35,15 @@ func NewJsonDiffWriter(wr io.WriteCloser, outSch schema.Schema) (*JsonDiffWriter
|
||||
// leading diff type column with empty name
|
||||
cols := outSch.GetAllCols()
|
||||
newCols := schema.NewColCollection()
|
||||
newCols.Append(schema.NewColumn("diff_type", 0, types.StringKind, false))
|
||||
newCols.Append(cols.GetColumns()...)
|
||||
newCols = newCols.Append(schema.NewColumn("diff_type", 0, types.StringKind, false))
|
||||
newCols = newCols.AppendColl(cols)
|
||||
|
||||
writer, err := NewJSONWriter(wr, outSch)
|
||||
newSchema, err := schema.SchemaFromCols(newCols)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
writer, err := NewJSONWriter(wr, newSchema)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -77,3 +82,16 @@ func (j *JsonDiffWriter) WriteRow(
|
||||
func (j *JsonDiffWriter) Close(ctx context.Context) error {
|
||||
return j.wr.Close(ctx)
|
||||
}
|
||||
type JsonSchemaDiffWriter struct {
|
||||
wr io.WriteCloser
|
||||
}
|
||||
|
||||
var _ diff.SchemaDiffWriter = (*JsonSchemaDiffWriter)(nil)
|
||||
|
||||
func (j JsonSchemaDiffWriter) WriteSchemaDiff(ctx context.Context, schemaDiffStatement string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (j JsonSchemaDiffWriter) Close(ctx context.Context) error {
|
||||
return j.wr.Close()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user