MCPcopy Create free account
hub / github.com/araddon/qlbridge / CopyRewrite

Method CopyRewrite

rel/sql.go:812–827  ·  view source on GitHub ↗

CopyRewrite Create a new copy of this column for rewrite purposes removing alias

(alias string)

Source from the content-addressed store, hash-verified

810
811// CopyRewrite Create a new copy of this column for rewrite purposes removing alias
812func (m *Column) CopyRewrite(alias string) *Column {
813 left, right, _ := m.LeftRight()
814 newCol := m.Copy()
815 //u.Warnf("in rewrite: Alias:'%s' '%s'.'%s' sourcefield:'%v'", alias, left, right, m.SourceField)
816 if left == alias {
817 newCol.SourceField = right
818 newCol.right = right
819 }
820 if newCol.Expr != nil {
821 _, right, _ := expr.LeftRight(newCol.Expr.String())
822 if right == m.SourceField {
823 newCol.Expr = &expr.IdentityNode{Text: right}
824 }
825 }
826 return newCol
827}
828
829// Copy - deep copy, shared nothing
830func (m *Column) Copy() *Column {

Callers 1

RewriteSqlSourceFunction · 0.80

Calls 4

LeftRightMethod · 0.95
CopyMethod · 0.95
LeftRightFunction · 0.92
StringMethod · 0.65

Tested by

no test coverage detected