Skip to content

Commit

Permalink
Add pointer for dolt_diff schema for doltgres
Browse files Browse the repository at this point in the history
  • Loading branch information
tbantle22 committed Dec 3, 2024
1 parent 116f9b3 commit 286b3a7
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions go/libraries/doltcore/sqle/dtables/unscoped_diff_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,20 +86,28 @@ func (dt *UnscopedDiffTable) String() string {
return dt.tableName
}

// Schema is a sql.Table interface function that returns the sql.Schema for this system table.
func (dt *UnscopedDiffTable) Schema() sql.Schema {
func getUnscopedDoltDiffSchema(dbName, tableName string) sql.Schema {
return []*sql.Column{
{Name: "commit_hash", Type: types.Text, Source: dt.tableName, PrimaryKey: true, DatabaseSource: dt.dbName},
{Name: "table_name", Type: types.Text, Source: dt.tableName, PrimaryKey: true, DatabaseSource: dt.dbName},
{Name: "committer", Type: types.Text, Source: dt.tableName, PrimaryKey: false, DatabaseSource: dt.dbName},
{Name: "email", Type: types.Text, Source: dt.tableName, PrimaryKey: false, DatabaseSource: dt.dbName},
{Name: "date", Type: types.Datetime, Source: dt.tableName, PrimaryKey: false, DatabaseSource: dt.dbName},
{Name: "message", Type: types.Text, Source: dt.tableName, PrimaryKey: false, DatabaseSource: dt.dbName},
{Name: "data_change", Type: types.Boolean, Source: dt.tableName, PrimaryKey: false, DatabaseSource: dt.dbName},
{Name: "schema_change", Type: types.Boolean, Source: dt.tableName, PrimaryKey: false, DatabaseSource: dt.dbName},
{Name: "commit_hash", Type: types.Text, Source: tableName, PrimaryKey: true, DatabaseSource: dbName},
{Name: "table_name", Type: types.Text, Source: tableName, PrimaryKey: true, DatabaseSource: dbName},
{Name: "committer", Type: types.Text, Source: tableName, PrimaryKey: false, DatabaseSource: dbName},
{Name: "email", Type: types.Text, Source: tableName, PrimaryKey: false, DatabaseSource: dbName},
{Name: "date", Type: types.Datetime, Source: tableName, PrimaryKey: false, DatabaseSource: dbName},
{Name: "message", Type: types.Text, Source: tableName, PrimaryKey: false, DatabaseSource: dbName},
{Name: "data_change", Type: types.Boolean, Source: tableName, PrimaryKey: false, DatabaseSource: dbName},
{Name: "schema_change", Type: types.Boolean, Source: tableName, PrimaryKey: false, DatabaseSource: dbName},
}
}

// GetUnscopedDoltDiffSchema returns the schema of the dolt_diff system table. This is used
// by Doltgres to update the dolt_diff schema using Doltgres types.
var GetUnscopedDoltDiffSchema = getUnscopedDoltDiffSchema

// Schema is a sql.Table interface function that returns the sql.Schema for this system table.
func (dt *UnscopedDiffTable) Schema() sql.Schema {
return GetUnscopedDoltDiffSchema(dt.dbName, dt.tableName)
}

// Collation implements the sql.Table interface.
func (dt *UnscopedDiffTable) Collation() sql.CollationID {
return sql.Collation_Default
Expand Down

0 comments on commit 286b3a7

Please sign in to comment.