@@ -25,11 +25,35 @@ import (
2525 "github.com/dolthub/dolt/go/libraries/doltcore/doltdb"
2626 "github.com/dolthub/dolt/go/libraries/doltcore/env"
2727 "github.com/dolthub/dolt/go/libraries/doltcore/schema"
28+ "github.com/dolthub/dolt/go/libraries/doltcore/sqle/adapters"
2829 "github.com/dolthub/dolt/go/libraries/doltcore/sqle/index"
2930)
3031
3132const statusDefaultRowCount = 10
3233
34+ func init () {
35+ adapters .TableAdapters [doltdb .StatusTableName ] = DoltStatusTableAdapter {}
36+ }
37+
38+ // DoltStatusTableAdapter implements the adapters.TableAdapter interface. It serves as the default dolt_status table
39+ // implementation, applying zero modifications. This exists in case no adapters are initialized by the integrator, i.e.
40+ // Doltgres.
41+ type DoltStatusTableAdapter struct {}
42+
43+ var _ adapters.TableAdapter = DoltStatusTableAdapter {}
44+
45+ // CreateTable implements the adapters.TableAdapter interface. It returns the default constructor for the dolt_status
46+ // table, applying zero modifications.
47+ func (d DoltStatusTableAdapter ) CreateTable (ctx * sql.Context , tableName string , dDb * doltdb.DoltDB , workingSet * doltdb.WorkingSet , rootsProvider env.RootsProvider [* sql.Context ]) sql.Table {
48+ return NewStatusTable (ctx , tableName , dDb , workingSet , rootsProvider )
49+ }
50+
51+ // TableName implements the adapters.TableAdapter interface. It returns the default name for the dolt_status table,
52+ // applying zero modifications.
53+ func (d DoltStatusTableAdapter ) TableName () string {
54+ return doltdb .StatusTableName
55+ }
56+
3357// StatusTable is a sql.Table implementation that implements a system table which shows the dolt branches
3458type StatusTable struct {
3559 rootsProvider env.RootsProvider [* sql.Context ]
@@ -61,22 +85,14 @@ func (st StatusTable) String() string {
6185 return st .tableName
6286}
6387
64- func getDoltStatusSchema ( tableName string ) sql.Schema {
88+ func ( st StatusTable ) Schema ( ) sql.Schema {
6589 return []* sql.Column {
66- {Name : "table_name" , Type : types .Text , Source : tableName , PrimaryKey : true , Nullable : false },
67- {Name : "staged" , Type : types .Boolean , Source : tableName , PrimaryKey : true , Nullable : false },
68- {Name : "status" , Type : types .Text , Source : tableName , PrimaryKey : true , Nullable : false },
90+ {Name : "table_name" , Type : types .Text , Source : doltdb . StatusTableName , PrimaryKey : true , Nullable : false },
91+ {Name : "staged" , Type : types .Boolean , Source : doltdb . StatusTableName , PrimaryKey : true , Nullable : false },
92+ {Name : "status" , Type : types .Text , Source : doltdb . StatusTableName , PrimaryKey : true , Nullable : false },
6993 }
7094}
7195
72- // GetDoltStatusSchema returns the schema of the dolt_status system table. This is used
73- // by Doltgres to update the dolt_status schema using Doltgres types.
74- var GetDoltStatusSchema = getDoltStatusSchema
75-
76- func (st StatusTable ) Schema () sql.Schema {
77- return GetDoltStatusSchema (st .tableName )
78- }
79-
8096func (st StatusTable ) Collation () sql.CollationID {
8197 return sql .Collation_Default
8298}
0 commit comments