File tree Expand file tree Collapse file tree 1 file changed +4
-29
lines changed Expand file tree Collapse file tree 1 file changed +4
-29
lines changed Original file line number Diff line number Diff line change @@ -48,36 +48,11 @@ func (b *Builder) resolveDb(name string) sql.Database {
4848}
4949
5050func (b * Builder ) resolveDbForTable (table ast.TableName ) sql.Database {
51- dbName := table .DbQualifier .String ()
52- if dbName == "" {
53- dbName = b .ctx .GetCurrentDatabase ()
54- }
55-
56- if dbName == "" {
57- b .handleErr (sql .ErrNoDatabaseSelected .New ())
58- }
59-
60- database , err := b .cat .Database (b .ctx , dbName )
61- if err != nil {
62- b .handleErr (err )
63- }
64-
65- schema := table .SchemaQualifier .String ()
66- if schema != "" {
67- scd , ok := database .(sql.SchemaDatabase )
68- if ! ok {
69- b .handleErr (fmt .Errorf ("database %T does not support schemas" , database ))
70- }
71- database , ok , err = scd .GetSchema (b .ctx , schema )
72- if err != nil {
73- b .handleErr (err )
74- }
75- if ! ok {
76- b .handleErr (sql .ErrDatabaseSchemaNotFound .New (schema ))
77- }
51+ db , ok := b .maybeResolveDbForTable (table )
52+ if ! ok {
53+ b .handleErr (sql .ErrDatabaseSchemaNotFound .New (table .SchemaQualifier .String ()))
7854 }
79-
80- return database
55+ return db
8156}
8257
8358func (b * Builder ) maybeResolveDbForTable (table ast.TableName ) (sql.Database , bool ) {
You can’t perform that action at this time.
0 commit comments