英文:
JOOQ throws DataTypeException when fetching table meta
问题
在尝试获取表元数据时出现错误。
使用的组件:
JOOQ 3.14.0,
PostgeSQL 12,
PostgreSQL 驱动程序 42.2.10
示例:
@RestController
@ApiVersion("v2")
public class TypeResource {
private final DSLContext ctx;
@GetMapping(value = "/test")
public void test(@RequestParam String table) {
ctx.meta().getTables(table);
}
}
错误(这不是完整的错误信息,但剩余部分类似):
17:16:44.808 [http-nio-8181-exec-5] [WARN ] org.jooq.impl.MetaImpl - 默认值:无法加载默认值:'{}'::character varying[],类型为:varchar ([Ljava.lang.String;)
org.jooq.exception.DataTypeException: 无法从 '{}'::character varying[] (class java.lang.String) 转换为类 [Ljava.lang.String;
...
...
...
...
表创建脚本示例:
CREATE TABLE public.user_role
(
id bigint NOT NULL DEFAULT nextval('user_role_id_seq'::regclass),
user_id bigint NOT NULL,
role_id bigint NOT NULL,
ts_created timestamp without time zone NOT NULL DEFAULT CURRENT_TIMESTAMP,
ts_updated timestamp without time zone NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_by_user character varying(256) COLLATE pg_catalog."default" NOT NULL DEFAULT 'n/a'::character varying,
updated_by_process character varying(64) COLLATE pg_catalog."default" NOT NULL DEFAULT 'n/a'::character varying,
CONSTRAINT user_role_pkey PRIMARY KEY (id),
CONSTRAINT x_role_id_fk FOREIGN KEY (role_id)
REFERENCES public.role (id) MATCH FULL
ON UPDATE NO ACTION
ON DELETE NO ACTION,
CONSTRAINT x_user_id_fk FOREIGN KEY (user_id)
REFERENCES public."user" (id) MATCH FULL
ON UPDATE NO ACTION
ON DELETE NO ACTION
)
...
...
...
起初,我的目标是获取表索引,这部分运行良好。我尝试将 JOOQ 从 3.13.1 升级到 3.14.0,并在数据库中尝试不同的表,但没有任何成功的结果。
英文:
Getting an error when trying to fetch table meta data.
Using:
JOOQ 3.14.0,
PostgeSQL 12,
PostgreSQL driver 42.2.10
Example:
@RestController
@ApiVersion("v2")
public class TypeResource {
private final DSLContext ctx;
@GetMapping(value = "/test")
public void test(@RequestParam String table) {
ctx.meta().getTables(table);
}
}
Error (This is not the whole error but the rest is similar):
17:16:44.808 [http-nio-8181-exec-5] [WARN ] org.jooq.impl.MetaImpl - Default value : Could not load default value: '{}'::character varying[] for type: varchar ([Ljava.lang.String;)
org.jooq.exception.DataTypeException: Cannot convert from '{}'::character varying[] (class java.lang.String) to class [Ljava.lang.String;
at org.jooq.tools.Convert$ConvertAll.fail(Convert.java:1303)
at org.jooq.tools.Convert$ConvertAll.from(Convert.java:1192)
at org.jooq.tools.Convert.convert0(Convert.java:392)
at org.jooq.tools.Convert.convert(Convert.java:384)
at org.jooq.tools.Convert.convert(Convert.java:458)
at org.jooq.impl.AbstractDataType.convert(AbstractDataType.java:534)
at org.jooq.impl.DefaultDataType.convert(DefaultDataType.java:86)
at org.jooq.impl.DSL.val(DSL.java:24373)
at org.jooq.impl.DSL.inline(DSL.java:23891)
at org.jooq.impl.MetaImpl$MetaTable.init(MetaImpl.java:910)
at org.jooq.impl.MetaImpl$MetaTable.<init>(MetaImpl.java:560)
at org.jooq.impl.MetaImpl$MetaSchema.getTables(MetaImpl.java:421)
at org.jooq.impl.MetaImpl.getTables0(MetaImpl.java:217)
at org.jooq.impl.AbstractMeta$4.iterator(AbstractMeta.java:194)
at org.jooq.impl.AbstractMeta.get(AbstractMeta.java:340)
at org.jooq.impl.AbstractMeta.initTables(AbstractMeta.java:191)
at org.jooq.impl.AbstractMeta.getTables(AbstractMeta.java:172)
at org.jooq.impl.AbstractMeta.getTables(AbstractMeta.java:167)
17:16:44.843 [http-nio-8181-exec-5] [WARN ] org.jooq.impl.MetaImpl - Default value : Could not load default value: '{{0,0}}'::numeric[] for type: numeric ([Ljava.math.BigDecimal;)
org.jooq.exception.DataTypeException: Cannot convert from '{{0,0}}'::numeric[] (class java.lang.String) to class [Ljava.math.BigDecimal;
at org.jooq.tools.Convert$ConvertAll.fail(Convert.java:1303)
at org.jooq.tools.Convert$ConvertAll.from(Convert.java:1192)
at org.jooq.tools.Convert.convert0(Convert.java:392)
at org.jooq.tools.Convert.convert(Convert.java:384)
at org.jooq.tools.Convert.convert(Convert.java:458)
at org.jooq.impl.AbstractDataType.convert(AbstractDataType.java:534)
at org.jooq.impl.DefaultDataType.convert(DefaultDataType.java:86)
at org.jooq.impl.DSL.val(DSL.java:24373)
at org.jooq.impl.DSL.inline(DSL.java:23891)
at org.jooq.impl.MetaImpl$MetaTable.init(MetaImpl.java:910)
at org.jooq.impl.MetaImpl$MetaTable.<init>(MetaImpl.java:560)
at org.jooq.impl.MetaImpl$MetaSchema.getTables(MetaImpl.java:421)
at org.jooq.impl.MetaImpl.getTables0(MetaImpl.java:217)
at org.jooq.impl.AbstractMeta$4.iterator(AbstractMeta.java:194)
at org.jooq.impl.AbstractMeta.get(AbstractMeta.java:340)
at org.jooq.impl.AbstractMeta.initTables(AbstractMeta.java:191)
at org.jooq.impl.AbstractMeta.getTables(AbstractMeta.java:172)
at org.jooq.impl.AbstractMeta.getTables(AbstractMeta.java:167)
Example table create script :
CREATE TABLE public.user_role
(
id bigint NOT NULL DEFAULT nextval('user_role_id_seq'::regclass),
user_id bigint NOT NULL,
role_id bigint NOT NULL,
ts_created timestamp without time zone NOT NULL DEFAULT CURRENT_TIMESTAMP,
ts_updated timestamp without time zone NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_by_user character varying(256) COLLATE pg_catalog."default" NOT NULL DEFAULT 'n/a'::character varying,
updated_by_process character varying(64) COLLATE pg_catalog."default" NOT NULL DEFAULT 'n/a'::character varying,
CONSTRAINT user_role_pkey PRIMARY KEY (id),
CONSTRAINT x_role_id_fk FOREIGN KEY (role_id)
REFERENCES public.role (id) MATCH FULL
ON UPDATE NO ACTION
ON DELETE NO ACTION,
CONSTRAINT x_user_id_fk FOREIGN KEY (user_id)
REFERENCES public."user" (id) MATCH FULL
ON UPDATE NO ACTION
ON DELETE NO ACTION
)
TABLESPACE pg_default;
ALTER TABLE public.user_role
OWNER to postgres;
CREATE UNIQUE INDEX x_role_user_id_role_id_uq
ON public.user_role USING btree
(user_id ASC NULLS LAST, role_id ASC NULLS LAST)
TABLESPACE pg_default;
Initially my goal was to get the table indexes and this is working fine.
I tried to update JOOQ from 3.13.1 to 3.14.0 and tested with different tables in the database but without any luck.
答案1
得分: 2
这是一个错误,将在 jOOQ 3.15 通过 https://github.com/jOOQ/jOOQ/issues/8469 进行修复。jOOQ 目前假定 DatabaseMetaData
列描述生成 DEFAULT
表达式的值,而不是表达式。
这个错误是“表面上的”,只影响日志记录。该字段仍然被正确生成(没有任何 DEFAULT
表达式)。您可以在日志记录配置中静音该消息,直到上述错误得到修复。
英文:
This is a bug which will be fixed in jOOQ 3.15 via https://github.com/jOOQ/jOOQ/issues/8469. jOOQ currently assumes that DatabaseMetaData
column descriptions produce values for DEFAULT
expressions, instead of expressions.
The bug is "cosmetic", as it only affects your logs. The field is still produced correctly (without any DEFAULT
expression). You can mute the message in your logger configuration until the above bug is fixed.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论