APIJSON icon indicating copy to clipboard operation
APIJSON copied to clipboard

连接表操作时,引用赋值不起效果

Open GITWEIZ opened this issue 3 years ago • 2 comments

环境信息

  • 系统: Windows 10
  • JDK: 1.8.0_17
  • 数据库: MySQL 8.0.28
  • APIJSON: 4.9.1

问题描述

(由于github不容易上传图片,只好只放代码了,请见谅) 数据库结构如下:

CREATE TABLE lrx_score (
  sid VARCHAR (10),
  cid VARCHAR (10),
  grade DECIMAL (18, 1)
);
INSERT INTO lrx_score VALUES('01' , '01' , 80);
INSERT INTO lrx_score VALUES('01' , '02' , 90);
INSERT INTO lrx_score VALUES('01' , '03' , 99);
INSERT INTO lrx_score VALUES('02' , '01' , 70);
INSERT INTO lrx_score VALUES('02' , '02' , 60);
INSERT INTO lrx_score VALUES('02' , '03' , 80);
INSERT INTO lrx_score VALUES('03' , '01' , 80);
INSERT INTO lrx_score VALUES('03' , '02' , 80);
INSERT INTO lrx_score VALUES('03' , '03' , 80);
INSERT INTO lrx_score VALUES('04' , '01' , 50);
INSERT INTO lrx_score VALUES('04' , '02' , 30);
INSERT INTO lrx_score VALUES('04' , '03' , 20);
INSERT INTO lrx_score VALUES('05' , '01' , 76);
INSERT INTO lrx_score VALUES('05' , '02' , 87);
INSERT INTO lrx_score VALUES('06' , '01' , 31);
INSERT INTO lrx_score VALUES('06' , '03' , 34);
INSERT INTO lrx_score VALUES('07' , '02' , 89);
INSERT INTO lrx_score VALUES('07' , '03' , 98);

当进行连接表操作时,引用赋值不起效果。虽然没有报错,但是原本该出现结果却没有出现。 执行的apijson如下:

{
  "[]": {
    "join": "&/Lrx_score:t2/sid@",
    "Lrx_score": {
      "@column": "sid,cid,grade",
      "cid": "01",
      "grade>@": "/Lrx_score:t2/grade"  //引用赋值不起效果
    },
    "Lrx_score:t2": {
      "@column": "sid,cid,grade",
      "sid@": "/Lrx_score/sid",
      "cid": "02"
    }
  },
  "@schema": "lrx"
}

执行结果: image

错误信息

GITWEIZ avatar Apr 06 '22 13:04 GITWEIZ

只允许引用上方的值,不允许反过来,类比 Java 定义两个变量: int a = b; int b = 0; 这样是会编译报错的,因为 b 在声明前就被使用了。

应该把所有引用赋值(外键关联)键值对都写在下方副表里

https://github.com/Tencent/APIJSON/issues/383#issuecomment-1091653670

TommyLemon avatar Apr 07 '22 12:04 TommyLemon

请问解决了吗?

cqs1234567s avatar May 25 '23 15:05 cqs1234567s