EWA

新增对mysql json字段的支持

2017-02-17

DTTable自动解析json字段,并映射到DTCell

Frame 新增和更新json字段

INSERT INTO xx_main( ESL_UNID, ESL_JSON ) VALUES (
      @sys_UNID , EWA_JSON(
            @ESL_NAME_CN, @ESl_NAME_EN, @ESL_MEMO
          , @ESL_P_TYPE, @ESL_P_AIR
          , @ESL_P_YEAR, @ESL_P_NET, @ESL_P_CERT, @ESL_P_FEELVL, @ESL_P_SCH_NUM
          , @ESL_P_ACT, @ESL_P_CLA_NUM, @ESL_P_AREA, @ESL_P_ASS, @ESL_P_CAR
          , @ESL_ADDR, @ESL_TELE, @ESL_EMAIL, @ESL_FAX, @ESL_WEB
          , @ESL_INFO_STU, @ESL_INFO_CERT, @ESL_INFO_SLEEP
          , @ESL_INFO_AREA, @ESL_INFO_SCHOOL, @ESL_INFO_REQ
          , @esl_p_own
    )
 )
-- 更新,主要第一个参数(ESL_JSON)
UPDATE bas_esl_main SET
   ESL_MDATE = @sys_DATE,
   ESL_JSON =  EWA_JSON ( 
        ESL_JSON
          , @ESL_NAME_CN, @ESl_NAME_EN, @ESL_MEMO
          , @ESL_P_TYPE, @ESL_P_AIR
          , @ESL_P_YEAR, @ESL_P_NET, @ESL_P_CERT, @ESL_P_FEELVL, @ESL_P_SCH_NUM
          , @ESL_P_ACT, @ESL_P_CLA_NUM, @ESL_P_AREA, @ESL_P_ASS, @ESL_P_CAR
          , @ESL_ADDR, @ESL_TELE, @ESL_EMAIL, @ESL_FAX, @ESL_WEB
          , @ESL_INFO_STU, @ESL_INFO_CERT, @ESL_INFO_SLEEP
          , @ESL_INFO_AREA, @ESL_INFO_SCHOOL, @ESL_INFO_REQ
          , @esl_p_own
    )
WHERE ESL_UNID=@ESL_UNID;

注意创建虚拟列的时候,varchar字段需要添加JSON_UNQUOTE,否则字段会出现双引号

ALTER TABLE xx_main ADD ESL_NAME_CN VARCHAR(200) 
    GENERATED ALWAYS AS (JSON_UNQUOTE(ESL_JSON->'$.esl_name_cn')) virtual