From f5ef1da235086747649b9c9d495ac3bc81b192c0 Mon Sep 17 00:00:00 2001 From: "Giau. Tran Minh" <12751435+giautm@users.noreply.github.com> Date: Sun, 5 Jan 2025 15:38:46 +0700 Subject: [PATCH] sql/specutil: pass schema to func/proc convert function (#3292) --- sql/internal/specutil/convert.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/sql/internal/specutil/convert.go b/sql/internal/specutil/convert.go index 5e6f202cf51..1348f58a8dc 100644 --- a/sql/internal/specutil/convert.go +++ b/sql/internal/specutil/convert.go @@ -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) @@ -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. @@ -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) } @@ -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) }