Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

远程函数执行结果如何作为数组条件进行传递 #746

Open
zxcwindy opened this issue Jul 30, 2024 · 2 comments
Open

远程函数执行结果如何作为数组条件进行传递 #746

zxcwindy opened this issue Jul 30, 2024 · 2 comments

Comments

@zxcwindy
Copy link
Contributor

zxcwindy commented Jul 30, 2024

Description

postgresql数据库有一列id的类型为uuid,通过以下方式过滤数据库会提示两边类型不匹配的异常:operator does not exist: uuid = character varying

{
...
"id":"e94f8127-1dee-4f12-aefe-34f7fc601231"
....
}

编写了一个函数进行远程函数调用

.....
public Object uuidStr(@NotNull JSONObject current, String uuid) {
		try {
			return UUID.fromString(uuid);
		} catch (Exception e) {
			e.printStackTrace();
			return uuid;
		}
	}
......

可以通过以下方式返回正常结果

{
....
"id()":"uuidStr(e94f8127-1dee-4f12-aefe-34f7fc601231)"
}

现在的问题是,我想实现id in ('e94f8127-1dee-4f12-aefe-34f7fc601231','ebc48f09-47da-4941-88f4-adfdc28db0d0',....)的效果,但是好像没法同时用
"id(){}":[uuidStr(e94f8127-1dee-4f12-aefe-34f7fc601231),uuidStr(ebc48f09-47da-4941-88f4-adfdc28db0d0)..]

请问以上场景该如何实现

@TommyLemon
Copy link
Collaborator

分步骤,两个键值对先后执行,远程函数需要 key-() 提高优先级

@TommyLemon
Copy link
Collaborator

另外 PostgreSQL 可以加参数配置字符串传参,适配各种数据库类型,网上查下,可以不用 APIJSON 远程函数

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants