Fix bug with deep-nested queries
This commit is contained in:
parent
482203ba05
commit
343589c3bd
@ -303,10 +303,18 @@ func (s *DBSchema) SetRel(child, parent string, rel *DBRel) error {
|
||||
sp := strings.ToLower(flect.Singularize(parent))
|
||||
pp := strings.ToLower(flect.Pluralize(parent))
|
||||
|
||||
s.rm[sc][sp] = rel
|
||||
s.rm[sc][pp] = rel
|
||||
s.rm[pc][sp] = rel
|
||||
s.rm[pc][pp] = rel
|
||||
if _, ok := s.rm[sc][sp]; !ok {
|
||||
s.rm[sc][sp] = rel
|
||||
}
|
||||
if _, ok := s.rm[sc][pp]; !ok {
|
||||
s.rm[sc][pp] = rel
|
||||
}
|
||||
if _, ok := s.rm[pc][sp]; !ok {
|
||||
s.rm[pc][sp] = rel
|
||||
}
|
||||
if _, ok := s.rm[pc][pp]; !ok {
|
||||
s.rm[pc][pp] = rel
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
@ -151,8 +151,6 @@ func nestedUpdateRelColumnsMap(item kvitem) map[string]struct{} {
|
||||
sk := make(map[string]struct{}, len(item.items))
|
||||
|
||||
for _, v := range item.items {
|
||||
//fmt.Println(">>", v._ctype > 0 && v.relCP.Type == RelOneToMany, v.relCP.Right.Col)
|
||||
|
||||
if v._ctype > 0 && v.relCP.Type == RelOneToMany {
|
||||
sk[v.relCP.Right.Col] = struct{}{}
|
||||
}
|
||||
|
@ -253,7 +253,6 @@ func (com *Compiler) Compile(query []byte, role string) (*QCode, error) {
|
||||
|
||||
func (com *Compiler) compileQuery(qc *QCode, op *Operation, role string) error {
|
||||
id := int32(0)
|
||||
parentID := int32(-1)
|
||||
|
||||
if len(op.Fields) == 0 {
|
||||
return errors.New("invalid graphql no query found")
|
||||
@ -275,7 +274,8 @@ func (com *Compiler) compileQuery(qc *QCode, op *Operation, role string) error {
|
||||
|
||||
for i := range op.Fields {
|
||||
if op.Fields[i].ParentID == -1 {
|
||||
st.Push(op.Fields[i].ID)
|
||||
val := op.Fields[i].ID | (-1 << 16)
|
||||
st.Push(val)
|
||||
}
|
||||
}
|
||||
|
||||
@ -288,7 +288,10 @@ func (com *Compiler) compileQuery(qc *QCode, op *Operation, role string) error {
|
||||
return fmt.Errorf("selector limit reached (%d)", maxSelectors)
|
||||
}
|
||||
|
||||
fid := st.Pop()
|
||||
val := st.Pop()
|
||||
fid := val & 0xFFFF
|
||||
parentID := (val >> 16) & 0xFFFF
|
||||
|
||||
field := &op.Fields[fid]
|
||||
|
||||
if _, ok := com.bl[field.Name]; ok {
|
||||
@ -357,8 +360,8 @@ func (com *Compiler) compileQuery(qc *QCode, op *Operation, role string) error {
|
||||
}
|
||||
|
||||
if len(f.Children) != 0 {
|
||||
parentID = s.ID
|
||||
st.Push(f.ID)
|
||||
val := f.ID | (s.ID << 16)
|
||||
st.Push(val)
|
||||
continue
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user