AQL requires that all subqueries or withQuery orderBy clauses are same
(s2aCtx *SQL2AqlContext, mapKey int)
| 1863 | |
| 1864 | // AQL requires that all subqueries or withQuery orderBy clauses are same |
| 1865 | func (v *ASTBuilder) isSameOrderBy(s2aCtx *SQL2AqlContext, mapKey int) (bool, error) { |
| 1866 | qLevel, _, index := v.getInfoByKey(mapKey) |
| 1867 | // generte group by clause json bytes based on the first subquery/withQuery |
| 1868 | if s2aCtx.orderByJSON == nil { |
| 1869 | withKeyMin := v.generateKey(qLevel, typeWithQuery, 0) |
| 1870 | subQKeyMin := v.generateKey(qLevel, typeSubQuery, 0) |
| 1871 | var err error |
| 1872 | if s2aCtx.MapOrderBy[withKeyMin] != nil { |
| 1873 | s2aCtx.orderByJSON, err = json.Marshal(s2aCtx.MapOrderBy[withKeyMin]) |
| 1874 | } else { |
| 1875 | s2aCtx.orderByJSON, err = json.Marshal(s2aCtx.MapOrderBy[subQKeyMin]) |
| 1876 | } |
| 1877 | if err != nil { |
| 1878 | return false, errors.New("unable to encode order by clause of the first subquery/withQuery") |
| 1879 | } |
| 1880 | |
| 1881 | if index == 0 { |
| 1882 | return true, nil |
| 1883 | } |
| 1884 | } |
| 1885 | |
| 1886 | // compare current groupBy clause with ctx.groupByJSON |
| 1887 | orderBy, err := json.Marshal(s2aCtx.MapOrderBy[mapKey]) |
| 1888 | if err != nil { |
| 1889 | return false, errors.New("unable to encode order by clause of this subquery/withQuery") |
| 1890 | } |
| 1891 | |
| 1892 | return bytes.EqualFold(s2aCtx.orderByJSON, orderBy), nil |
| 1893 | } |
| 1894 | |
| 1895 | // addQIdentifier adds subquery/withQuery identifier and its mapKey into queryIdentifierSet |
| 1896 | func (v *ASTBuilder) addQIdentifier(s2aCtx *SQL2AqlContext, indentifier string, key int) error { |
no test coverage detected