Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

sql/specutil: pass schema to func/proc convert function #3292

Merged
merged 1 commit into from
Jan 5, 2025
Merged
Changes from all commits
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
10 changes: 6 additions & 4 deletions sql/internal/specutil/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ type (
ConvertIndexFunc func(*sqlspec.Index, *schema.Table) (*schema.Index, error)
ConvertViewIndexFunc func(*sqlspec.Index, *schema.View) (*schema.Index, error)
ConvertCheckFunc func(*sqlspec.Check) (*schema.Check, error)
ConvertFuncFunc func(*sqlspec.Func, *schema.Schema) (*schema.Func, error)
ConvertProcFunc func(*sqlspec.Func, *schema.Schema) (*schema.Proc, error)
ColumnTypeSpecFunc func(schema.Type) (*sqlspec.Column, error)
TableSpecFunc func(*schema.Table) (*sqlspec.Table, error)
TableColumnSpecFunc func(*schema.Column, *schema.Table) (*sqlspec.Column, error)
Expand Down Expand Up @@ -58,8 +60,8 @@ type (
ScanFuncs struct {
Table ConvertTableFunc
View ConvertViewFunc
Func func(*sqlspec.Func) (*schema.Func, error)
Proc func(*sqlspec.Func) (*schema.Proc, error)
Func ConvertFuncFunc
Proc ConvertProcFunc
// Triggers add themselves to the relevant tables/views.
Triggers func(*schema.Realm, []*sqlspec.Trigger) error
// Objects add themselves to the realm.
Expand Down Expand Up @@ -220,7 +222,7 @@ func Scan(r *schema.Realm, doc *ScanDoc, funcs *ScanFuncs) error {
if !ok {
return fmt.Errorf("schema %q not found for function %q", name, sf.Name)
}
f, err := funcs.Func(sf)
f, err := funcs.Func(sf, s)
if err != nil {
return fmt.Errorf("cannot convert function %q: %w", sf.Name, err)
}
Expand All @@ -244,7 +246,7 @@ func Scan(r *schema.Realm, doc *ScanDoc, funcs *ScanFuncs) error {
if !ok {
return fmt.Errorf("schema %q not found for procedure %q", name, sf.Name)
}
f, err := funcs.Proc(sf)
f, err := funcs.Proc(sf, s)
if err != nil {
return fmt.Errorf("cannot convert procedure %q: %w", sf.Name, err)
}
Expand Down
Loading