mirror of
https://github.com/dolthub/dolt.git
synced 2026-05-01 11:49:54 -05:00
Merge pull request #9620 from dolthub/nathan/fixAsOf
Fix for 'as of' with dolt_query_catalog
This commit is contained in:
@@ -30,6 +30,8 @@ var _ sql.UpdatableTable = (*QueryCatalogTable)(nil)
|
||||
var _ sql.DeletableTable = (*QueryCatalogTable)(nil)
|
||||
var _ sql.InsertableTable = (*QueryCatalogTable)(nil)
|
||||
var _ sql.ReplaceableTable = (*QueryCatalogTable)(nil)
|
||||
var _ VersionableTable = (*QueryCatalogTable)(nil)
|
||||
var _ sql.IndexAddressableTable = (*QueryCatalogTable)(nil)
|
||||
|
||||
// QueryCatalogTable is the system table that stores saved queries.
|
||||
type QueryCatalogTable struct {
|
||||
@@ -112,6 +114,28 @@ func (qt *QueryCatalogTable) Deleter(*sql.Context) sql.RowDeleter {
|
||||
return newQueryCatalogWriter(qt)
|
||||
}
|
||||
|
||||
func (qt *QueryCatalogTable) LockedToRoot(ctx *sql.Context, root doltdb.RootValue) (sql.IndexAddressableTable, error) {
|
||||
if qt.backingTable == nil {
|
||||
return qt, nil
|
||||
}
|
||||
return qt.backingTable.LockedToRoot(ctx, root)
|
||||
}
|
||||
|
||||
// IndexedAccess implements IndexAddressableTable, but QueryCatalogTable has no indexes.
|
||||
// Thus, this should never be called.
|
||||
func (qt *QueryCatalogTable) IndexedAccess(ctx *sql.Context, lookup sql.IndexLookup) sql.IndexedTable {
|
||||
panic("Unreachable")
|
||||
}
|
||||
|
||||
// GetIndexes implements IndexAddressableTable, but QueryCatalogTable has no indexes.
|
||||
func (qt *QueryCatalogTable) GetIndexes(ctx *sql.Context) ([]sql.Index, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (qt *QueryCatalogTable) PreciseMatch() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
var _ sql.RowReplacer = (*queryCatalogWriter)(nil)
|
||||
var _ sql.RowUpdater = (*queryCatalogWriter)(nil)
|
||||
var _ sql.RowInserter = (*queryCatalogWriter)(nil)
|
||||
|
||||
@@ -115,4 +115,32 @@ var DoltQueryCatalogScripts = []queries.ScriptTest{
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "can use 'as of' on dolt_query_catalog",
|
||||
SetUpScript: []string{
|
||||
"INSERT INTO dolt_query_catalog VALUES ('show', 1, 'show', 'show tables;', '')",
|
||||
"CALL DOLT_COMMIT('-A','-m', 'first commit')",
|
||||
"INSERT INTO dolt_query_catalog VALUES ('select', 2, 'select', 'select * from dolt_query_catalog;', '')",
|
||||
"CALL DOLT_COMMIT('-A', '-m', 'second commit')",
|
||||
},
|
||||
Assertions: []queries.ScriptTestAssertion{
|
||||
{
|
||||
Query: "SELECT * FROM dolt_query_catalog as of 'HEAD~2'",
|
||||
Expected: []sql.Row{},
|
||||
},
|
||||
{
|
||||
Query: "SELECT * FROM dolt_query_catalog as of 'HEAD~1'",
|
||||
Expected: []sql.Row{
|
||||
{"show", 1, "show", "show tables;", ""},
|
||||
},
|
||||
},
|
||||
{
|
||||
Query: "SELECT * FROM dolt_query_catalog as of 'HEAD'",
|
||||
Expected: []sql.Row{
|
||||
{"show", 1, "show", "show tables;", ""},
|
||||
{"select", 2, "select", "select * from dolt_query_catalog;", ""},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user