注册

GolangMySQL迁移JSONfield报错

SCQQQQ 2023/10/16 503 0

为提高效率,提问时请提供以下信息,问题描述清晰可优先响应。
【DM版本】:v8
【操作系统】:linux golang - windows-DM
【CPU】: AMD
【问题描述】*:
golang 项目MySQL迁移到DMDB,使用到Gorm。报错:非法的基类名[JSON]
相关golang代码:

type test struct{ config configjson.RawMessage `gorm:"column:config; type:json" json:"config" form:"config"` }

报错原因,golang-gorm tag中类型问题。

通过查询,相关SQL类似下面这样,其中关于predicates 的那一行。参考链接和SQL如下
https://www.modb.pro/db/34708

CREATE TABLE "sys_route_conf" ( "id" INT IDENTITY(34,1) NOT NULL, "route_name" VARCHAR(200) NULL, "route_id" VARCHAR(200) DEFAULT '' NOT NULL, "predicates" VARCHAR(1000) CONSTRAINT ensure_json CHECK ("predicates" IS JSON), --JSON NULL, --"filters" JSON NULL, "uri" VARCHAR(200) NULL, "order" INT DEFAULT 0 NULL, "create_time" TIMESTAMP(0) DEFAULT CURRENT_TIMESTAMP() NULL, "update_time" TIMESTAMP(0) NULL, "del_flag" CHAR(4) DEFAULT '0' NULL ) po_document VARCHAR(1000) CONSTRAINT ensure_json CHECK (po_document IS JSON) );

问题:这种涉及到达梦JSON的Tag怎么写?

回答 0
暂无回答
扫一扫
联系客服