Skip to content

Commit

Permalink
simplified
Browse files Browse the repository at this point in the history
  • Loading branch information
adranwit committed Aug 3, 2023
1 parent 3a0f163 commit 16137d8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
6 changes: 5 additions & 1 deletion view/column/discover.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,11 @@ func readSinkColumns(ctx context.Context, db *sql.DB, table string) ([]sink.Colu
if err != nil {
return nil, err
}
return config.Columns(ctx, session, db, table)
columns, err := config.Columns(ctx, session, db, table)
if len(columns) == 0 {
return inferColumnWithSQL(ctx, db, "SELECT * FROM "+table+" WHERE 1 = 0", []interface{}{}, map[string]sink.Column{})
}
return columns, err
}

func parseQuery(SQL string) (string, string, sqlparser.Columns) {
Expand Down
1 change: 1 addition & 0 deletions view/view.go
Original file line number Diff line number Diff line change
Expand Up @@ -1297,6 +1297,7 @@ func (v *View) BuildParametrizedSQL(state Parameters, types *xreflect.Types, SQL
return nil, fmt.Errorf("failed to evaluate %v: %w", v.Name, err)
}
bindingArgs = append(bindingArgs, result.Context.DataUnit.ParamsGroup...)
result.Expanded = shared.TrimPair(result.Expanded, '(', ')')
return &sqlx.SQL{Query: result.Expanded, Args: bindingArgs}, nil
}

Expand Down

0 comments on commit 16137d8

Please sign in to comment.