From 286b3a7237fa6fce412cd75528263cde6357b7e7 Mon Sep 17 00:00:00 2001 From: Taylor Bantle Date: Tue, 3 Dec 2024 13:27:51 -0800 Subject: [PATCH] Add pointer for dolt_diff schema for doltgres --- .../sqle/dtables/unscoped_diff_table.go | 28 ++++++++++++------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/go/libraries/doltcore/sqle/dtables/unscoped_diff_table.go b/go/libraries/doltcore/sqle/dtables/unscoped_diff_table.go index 0e5999eb56..20223f4b7d 100644 --- a/go/libraries/doltcore/sqle/dtables/unscoped_diff_table.go +++ b/go/libraries/doltcore/sqle/dtables/unscoped_diff_table.go @@ -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