APIJSON icon indicating copy to clipboard operation
APIJSON copied to clipboard

连接查询时,报错“服务器内部错误,解析子查询 []/0/Tda_datasource_header/@from@:{ } 为 Subquery 对象失败!”

Open Lsq-class opened this issue 3 years ago • 3 comments

{"@Explain":true, "[]": { Tda_datasource_header: { "@from@":{ "from":"Tda_datasource_header", "join":"&/Tda_datasource_tableset/set_key@", Tda_datasource_tableset:{ "@column": "set_name_cn", "set_key@":"/Tda_datasource_header/set_key" }, Tda_datasource_header:{ } }, "@order": "row_id", }, "count": 10000, "page": 0 }, } image

这是我的查询语句,需要用主表Tda_datasource_header连接副表 Tda_datasource_tableset,通过set_key连接。

Lsq-class avatar May 17 '22 09:05 Lsq-class

顺序错了,引用赋值只能下面对象依赖上面对象 https://github.com/Tencent/APIJSON/issues/381

TommyLemon avatar May 17 '22 14:05 TommyLemon

好的,谢谢上面问题调换顺序后已经解决,但是我又遇到一个问题, 我的Tda_datasource_header表中的set_key数据大部分为空,我想使用左连接 Tda_datasource_tableset表,将为空的也查出来,这样的查询语句哪里有错误?

"[]": {

    Tda_datasource_header: {
      "@from@":{
        "from":"Tda_datasource_header",
        "join":"</Tda_datasource_tableset/set_key@",
        Tda_datasource_header:{
        },
        Tda_datasource_tableset:{
          "@column": "set_name_cn",
          "set_key@":"/Tda_datasource_header/set_key"
        },

      },
      "@order": "row_id",

      // "@column": "row_id,category1,category2,category3,source_desc"
    },
    "count": 10000,
    "page": 0
  }

image

顺序错了,引用赋值只能下面对象依赖上面对象 #381

Lsq-class avatar May 18 '22 01:05 Lsq-class

引用赋值键值对解析出来 null 值会导致所在对象中断查询,直接返回空。 目前能解决的方法是把 set_key 改为 NOT NULL,用空字符串 '' 表示没有值

TommyLemon avatar May 21 '22 16:05 TommyLemon