Skip to content

Commit d28b011

Browse files
committed
fix: fall back to default/public schema if no schema present
1 parent 2d4b83b commit d28b011

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

internal/sql/catalog/table.go

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -268,15 +268,22 @@ func (c *Catalog) createTable(stmt *ast.CreateTableStmt) error {
268268
seen := make(map[string]bool) // used to check for duplicate column names
269269
for _, inheritTable := range stmt.Inherits {
270270

271-
inheritSchema, err := c.getSchema(inheritTable.Schema)
272-
if err != nil {
273-
return err
271+
var inheritTableSchema *Schema
272+
if inheritTable.Schema == "" {
273+
inheritTableSchema = schema
274+
} else {
275+
inheritSchema, err := c.getSchema(inheritTable.Schema)
276+
if err != nil {
277+
return err
278+
}
279+
inheritTableSchema = inheritSchema
274280
}
275281

276-
t, _, err := inheritSchema.getTable(inheritTable)
282+
t, _, err := inheritTableSchema.getTable(inheritTable)
277283
if err != nil {
278284
return err
279285
}
286+
280287
// check and ignore duplicate columns
281288
for _, col := range t.Columns {
282289
if notNull, ok := seen[col.Name]; ok {

0 commit comments

Comments
 (0)