File tree Expand file tree Collapse file tree 1 file changed +23
-16
lines changed Expand file tree Collapse file tree 1 file changed +23
-16
lines changed Original file line number Diff line number Diff line change @@ -131,23 +131,8 @@ func (b *Builder) buildScalar(inScope *scope, e ast.Expr) (ex sql.Expression) {
131131 }
132132 b .handleErr (err )
133133 }
134- // Look past table aliases
135- var origTbl string
136- if inScope .node != nil {
137- transform .Inspect (inScope .node , func (node sql.Node ) bool {
138- switch n := node .(type ) {
139- case * plan.TableAlias :
140- if n .Name () == c .table {
141- if child , ok := n .Child .(sql.Nameable ); ok {
142- origTbl = child .Name ()
143- }
144- }
145- return false
146- }
147- return true
148- })
149- }
150134
135+ origTbl := b .getOrigTblName (inScope .node , c .table )
151136 c = c .withOriginal (origTbl , v .Name .String ())
152137 return c .scalarGf ()
153138 case * ast.FuncExpr :
@@ -418,6 +403,28 @@ func (b *Builder) buildScalar(inScope *scope, e ast.Expr) (ex sql.Expression) {
418403 return nil
419404}
420405
406+ func (b * Builder ) getOrigTblName (node sql.Node , alias string ) string {
407+ if node == nil {
408+ return ""
409+ }
410+ // Look past table aliases
411+ var origTbl string
412+ transform .Inspect (node , func (n sql.Node ) bool {
413+ switch n := node .(type ) {
414+ case * plan.TableAlias :
415+ if n .Name () == alias {
416+ if child , ok := n .Child .(sql.Nameable ); ok {
417+ origTbl = child .Name ()
418+ }
419+ }
420+ return false
421+ default :
422+ return true
423+ }
424+ })
425+ return origTbl
426+ }
427+
421428// getJsonValueTypeLiteral converts a type coercion string into a literal
422429// expression with the zero type of the coercion (see json_value function).
423430func (b * Builder ) getJsonValueTypeLiteral (e sql.Expression ) sql.Expression {
You can’t perform that action at this time.
0 commit comments