diff --git a/core/rootvalue.go b/core/rootvalue.go index 041bb0d150..b6ddf2306c 100644 --- a/core/rootvalue.go +++ b/core/rootvalue.go @@ -322,7 +322,7 @@ func (root *RootValue) GetTableHash(ctx context.Context, tName doltdb.TableName) } // GetTableNames implements the interface doltdb.RootValue. -func (root *RootValue) GetTableNames(ctx context.Context, schemaName string) ([]string, error) { +func (root *RootValue) GetTableNames(ctx context.Context, schemaName string, includeRootObjects bool) ([]string, error) { tableMap, err := root.getTableMap(ctx, schemaName) if err != nil { return nil, err @@ -336,22 +336,23 @@ func (root *RootValue) GetTableNames(ctx context.Context, schemaName string) ([] if err != nil { return nil, err } - // Iterate collections - colls, err := rootobject.LoadAllCollections(ctx, root) - if err != nil { - return nil, err - } - for _, coll := range colls { - err = coll.IterIDs(ctx, func(identifier id.Id) (stop bool, err error) { - tName := coll.IDToTableName(identifier) - if tName.Schema == schemaName { - names = append(names, tName.Name) - } - return false, nil - }) + if includeRootObjects { + colls, err := rootobject.LoadAllCollections(ctx, root) if err != nil { return nil, err } + for _, coll := range colls { + err = coll.IterIDs(ctx, func(identifier id.Id) (stop bool, err error) { + tName := coll.IDToTableName(identifier) + if tName.Schema == schemaName { + names = append(names, tName.Name) + } + return false, nil + }) + if err != nil { + return nil, err + } + } } return names, nil } diff --git a/go.mod b/go.mod index 1709be421b..aa8ed4bb06 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( github.com/PuerkitoBio/goquery v1.8.1 github.com/cockroachdb/apd/v2 v2.0.3-0.20200518165714-d020e156310a github.com/cockroachdb/errors v1.7.5 - github.com/dolthub/dolt/go v0.40.5-0.20250808163615-dfb2b4e5b652 + github.com/dolthub/dolt/go v0.40.5-0.20250808223748-f010490a4a9d github.com/dolthub/eventsapi_schema v0.0.0-20250725194025-a087efa1ee55 github.com/dolthub/flatbuffers/v23 v23.3.3-dh.2 github.com/dolthub/go-icu-regex v0.0.0-20250327004329-6799764f2dad diff --git a/go.sum b/go.sum index b718734093..82c9a3a37b 100644 --- a/go.sum +++ b/go.sum @@ -273,8 +273,8 @@ github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5Xh github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= github.com/dolthub/aws-sdk-go-ini-parser v0.0.0-20250305001723-2821c37f6c12 h1:IdqX7J8vi/Kn3T3Ee0VzqnLqwFmgA2hr8WZETPcQjfM= github.com/dolthub/aws-sdk-go-ini-parser v0.0.0-20250305001723-2821c37f6c12/go.mod h1:rN7X8BHwkjPcfMQQ2QTAq/xM3leUSGLfb+1Js7Y6TVo= -github.com/dolthub/dolt/go v0.40.5-0.20250808163615-dfb2b4e5b652 h1:xRqbUQCeZ+QVN9wDzkWGw8bugMX6AbND7J2QWvVWeDk= -github.com/dolthub/dolt/go v0.40.5-0.20250808163615-dfb2b4e5b652/go.mod h1:pP/jZVfosnKfvpsxx2YZODFkfhtMdGtRHXWmT3rtIW8= +github.com/dolthub/dolt/go v0.40.5-0.20250808223748-f010490a4a9d h1:M/VGXJTV9A4QreZzBPwTK8gSivF6xJstkwbr62/Wrmw= +github.com/dolthub/dolt/go v0.40.5-0.20250808223748-f010490a4a9d/go.mod h1:pP/jZVfosnKfvpsxx2YZODFkfhtMdGtRHXWmT3rtIW8= github.com/dolthub/eventsapi_schema v0.0.0-20250725194025-a087efa1ee55 h1:LdtiPD8IJ+M2XckvfQ/aLG34lET1shz+WMccGBhZRLM= github.com/dolthub/eventsapi_schema v0.0.0-20250725194025-a087efa1ee55/go.mod h1:CoDLfgPqHyBtth0Cp+fi/CmC4R81zJNX4wPjShdZ+Bw= github.com/dolthub/flatbuffers/v23 v23.3.3-dh.2 h1:u3PMzfF8RkKd3lB9pZ2bfn0qEG+1Gms9599cr0REMww= diff --git a/testing/bats/root-objects.bats b/testing/bats/root-objects.bats index 797236047f..115562f59e 100644 --- a/testing/bats/root-objects.bats +++ b/testing/bats/root-objects.bats @@ -83,3 +83,18 @@ SQL [ "$status" -eq 0 ] [[ "$output" =~ "12" ]] || false } + +@test 'root-objects: \d does not break' { + query_server < 'pg_catalog' + AND n.nspname !~ '^pg_toast' + AND n.nspname <> 'information_schema' + AND pg_catalog.pg_table_is_visible(c.oid) +ORDER BY 1,2;`, + Expected: []sql.Row{ + {"public", "call", "table", "postgres"}, + {"public", "call_id_seq", "sequence", "postgres"}, + {"public", "dolt_branches", "table", "postgres"}, + {"public", "dolt_column_diff", "table", "postgres"}, + {"public", "dolt_commit_ancestors", "table", "postgres"}, + {"public", "dolt_commit_diff_call", "table", "postgres"}, + {"public", "dolt_commit_diff_user", "table", "postgres"}, + {"public", "dolt_commits", "table", "postgres"}, + {"public", "dolt_conflicts", "table", "postgres"}, + {"public", "dolt_conflicts_call", "table", "postgres"}, + {"public", "dolt_conflicts_user", "table", "postgres"}, + {"public", "dolt_constraint_violations", "table", "postgres"}, + {"public", "dolt_constraint_violations_call", "table", "postgres"}, + {"public", "dolt_constraint_violations_user", "table", "postgres"}, + {"public", "dolt_diff", "table", "postgres"}, + {"public", "dolt_diff_call", "table", "postgres"}, + {"public", "dolt_diff_user", "table", "postgres"}, + {"public", "dolt_history_call", "table", "postgres"}, + {"public", "dolt_history_user", "table", "postgres"}, + {"public", "dolt_log", "table", "postgres"}, + {"public", "dolt_merge_status", "table", "postgres"}, + {"public", "dolt_remote_branches", "table", "postgres"}, + {"public", "dolt_remotes", "table", "postgres"}, + {"public", "dolt_schema_conflicts", "table", "postgres"}, + {"public", "dolt_status", "table", "postgres"}, + {"public", "dolt_tags", "table", "postgres"}, + {"public", "dolt_workspace_call", "table", "postgres"}, + {"public", "dolt_workspace_user", "table", "postgres"}, + {"public", "user", "table", "postgres"}, + {"public", "user_id_seq", "sequence", "postgres"}, + }, + }, + }, + }, }) }