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

Function sqlSelectToPbDepth

rel/sql.go:950–1001  ·  view source on GitHub ↗
(m *SqlSelect, depth int)

Source from the content-addressed store, hash-verified

948 return sqlSelectToPbDepth(m, 0)
949}
950func sqlSelectToPbDepth(m *SqlSelect, depth int) *SqlSelectPb {
951 //u.Debugf("SqlSelectToPb %d? %p", depth, m)
952 s := SqlSelectPb{}
953 s.Db = m.Db
954 s.Raw = m.Raw
955 s.Star = m.Star
956 s.Distinct = m.Distinct
957 s.Limit = int32(m.Limit)
958 s.Offset = int32(m.Offset)
959 s.IsAgg = m.isAgg
960 s.Finalized = m.finalized
961 s.Schemaqry = m.schemaqry
962 if len(m.Alias) > 0 {
963 s.Alias = &m.Alias
964 }
965 if m.Where != nil {
966 s.Where = SqlWhereToPb(m.Where)
967 }
968 if m.proj != nil {
969 s.Projection = projectionToPb(m.proj)
970 }
971 if m.Having != nil {
972 s.Having = m.Having.NodePb()
973 }
974 if len(m.Columns) > 0 {
975 s.Columns = ColumnsToPb(m.Columns)
976 }
977 if len(m.GroupBy) > 0 {
978 s.GroupBy = ColumnsToPb(m.GroupBy)
979 }
980 if len(m.OrderBy) > 0 {
981 s.OrderBy = ColumnsToPb(m.OrderBy)
982 }
983 if len(m.From) > 0 && depth == 0 {
984 s.From = make([]*SqlSourcePb, len(m.From))
985 for i, from := range m.From {
986 s.From[i] = from.ToPB()
987 }
988 }
989 if len(m.With) > 0 {
990 by, err := json.Marshal(m.With)
991 if err != nil {
992 u.Errorf("unhandled error json with? %v", err)
993 } else {
994 s.With = by
995 }
996 }
997 if m.Into != nil {
998 s.Into = &m.Into.Table
999 }
1000 return &s
1001}
1002func (m *SqlSelect) Equal(ss SqlStatement) bool {
1003 s, ok := ss.(*SqlSelect)
1004 if !ok {

Callers 2

SqlSelectToPbFunction · 0.85
sqlSourceToPbFunction · 0.85

Calls 7

SqlWhereToPbFunction · 0.85
projectionToPbFunction · 0.85
ColumnsToPbFunction · 0.85
ErrorfMethod · 0.80
NodePbMethod · 0.65
ToPBMethod · 0.45
MarshalMethod · 0.45

Tested by

no test coverage detected