Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix(compiler): support identifiers with schema
close #1858
  • Loading branch information
orisano committed Aug 5, 2023
commit b88a0350e5f9d9f52418f7f4d2e08bcdc291ea3b
9 changes: 8 additions & 1 deletion internal/compiler/output_columns.go
Original file line number Diff line number Diff line change
Expand Up @@ -595,19 +595,26 @@ func (c *Compiler) sourceTables(qc *QueryCatalog, node ast.Node) ([]*Table, erro

func outputColumnRefs(res *ast.ResTarget, tables []*Table, node *ast.ColumnRef) ([]*Column, error) {
parts := stringSlice(node.Fields)
var name, alias string
var schema, name, alias string
switch {
case len(parts) == 1:
name = parts[0]
case len(parts) == 2:
alias = parts[0]
name = parts[1]
case len(parts) == 3:
schema = parts[0]
alias = parts[1]
name = parts[2]
default:
return nil, fmt.Errorf("unknown number of fields: %d", len(parts))
}
var cols []*Column
var found int
for _, t := range tables {
if schema != "" && t.Rel.Schema != schema {
continue
}
if alias != "" && t.Rel.Name != alias {
continue
}
Expand Down