/ Make selector json representation for Mongo tables. */ /
| 42 | /* Make selector json representation for Mongo tables. */ |
| 43 | /***********************************************************************/ |
| 44 | bool MakeSelector(PGLOBAL g, PFIL fp, PSTRG s) |
| 45 | { |
| 46 | OPVAL opc = fp->GetOpc(); |
| 47 | |
| 48 | s->Append('{'); |
| 49 | |
| 50 | if (opc == OP_AND || opc == OP_OR) { |
| 51 | if (fp->GetArgType(0) != TYPE_FILTER || fp->GetArgType(1) != TYPE_FILTER) |
| 52 | return true; |
| 53 | |
| 54 | s->Append("\"$"); |
| 55 | s->Append(opc == OP_AND ? "and" : "or"); |
| 56 | s->Append("\":["); |
| 57 | |
| 58 | if (MakeSelector(g, (PFIL)fp->Arg(0), s)) |
| 59 | return true; |
| 60 | |
| 61 | s->Append(','); |
| 62 | |
| 63 | if (MakeSelector(g, (PFIL)fp->Arg(1), s)) |
| 64 | return true; |
| 65 | |
| 66 | s->Append(']'); |
| 67 | } else { |
| 68 | if (fp->GetArgType(0) != TYPE_COLBLK) |
| 69 | return true; |
| 70 | |
| 71 | s->Append('"'); |
| 72 | s->Append(((PCOL)fp->Arg(0))->GetJpath(g, false)); |
| 73 | s->Append("\":{\"$"); |
| 74 | |
| 75 | switch (opc) { |
| 76 | case OP_EQ: |
| 77 | s->Append("eq"); |
| 78 | break; |
| 79 | case OP_NE: |
| 80 | s->Append("ne"); |
| 81 | break; |
| 82 | case OP_GT: |
| 83 | s->Append("gt"); |
| 84 | break; |
| 85 | case OP_GE: |
| 86 | s->Append("gte"); |
| 87 | break; |
| 88 | case OP_LT: |
| 89 | s->Append("lt"); |
| 90 | break; |
| 91 | case OP_LE: |
| 92 | s->Append("lte"); |
| 93 | break; |
| 94 | case OP_NULL: |
| 95 | case OP_LIKE: |
| 96 | case OP_EXIST: |
| 97 | default: |
| 98 | return true; |
| 99 | } // endswitch Opc |
| 100 | |
| 101 | s->Append("\":"); |
no test coverage detected