使用 IN 条件查询 - 列出属性名称/值中包含逗号的属性时出现问题

发布于 2025-01-19 02:57:07 字数 966 浏览 2 评论 0原文

要查询系统中的特定对象,我们可以使用过滤器。当前,我们正在处理过滤器管理器,您可以在文本模式下输入条件以查询系统中的对象。我们可以以rsql查询的形式编写自己的自定义过滤器( https://github.com/ jirutka/rsql-parser )和我们自己的查询语言。过滤器管理器本身的后端逻辑本身以Java编写,JS用于前端。

通常,在过滤器管理器中写的表达式查询正常工作,问题始于“条件”。例如,我们有这样的条件:

Users IN ("value1,value2", "value3", "value4")

不幸的是,“ value1,value2”不会将其视为一个属性,而是分为两个属性:

Users IN (""value1", "value2"", "value3", "value4")

结果,条件变得无效,因为两个引号出现了彼此相邻,一个值分为两个值。

问题在于,某些对象和属性在我们的名字中具有逗号,据我所知,如果在属性名称中有逗号,则无法使用逗号。我想放弃这个想法,在此目的的目的是在操作员或操作员中都不能使用 - 或操作员正常工作。

我想知道可以使用哪种方法(除了使用或操作员使用Bagaround之外)。我想知道JIRO方法,在过滤器中,您可以在其中编写有或没有引号的值。例如:

User IN ("value1,value2", value3, value4)

然后“ value1,value2”被视为一个属性。我还考虑过一些聪明的逃生角色,或者可能是一些言论,但我不确定。

有人对如何解决此问题或任何可能的解决方案有任何建议吗?我迷路了。在此先感谢您的任何答案和评论!

To query specific objects in our system we can use filters. Currently we are working on filter manager in which you can enter your conditions in text mode to query objects in the system. We can write there our own custom filter, in the form of RSQL queries ( https://github.com/jirutka/rsql-parser ) and our own query language. The backend logic of the filter manager itself is written in Java, and JS is used for the front-end.

As a rule, the expression queries written in the Filter Manager work fine, the problem starts with the "IN condition". For example, we have such a condition:

Users IN ("value1,value2", "value3", "value4")

Unfortunately, "value1,value2" will not be treated as one attribute, but broken into two:

Users IN (""value1", "value2"", "value3", "value4")

As a result, the condition becomes invalid, because two quotation marks appear next to each other and a single value is broken into two values.

The problem is that some objects and attributes have a comma in our name, and as far as I can see with the "IN operator" you cannot use commas if there is a comma in the attribute name. I would like to give up the idea, where for such purposes you cannot use IN operator, only OR operator - because OR operator works fine.

I am wondering what approach can be used (besides bagaround using the OR operator). I was wondering about the Jiro approach, where in filters you can write values with and without quotes. For example:

User IN ("value1,value2", value3, value4)

And then "value1,value2" is treated as one attribute. I also thought about some clever escape characters, or maybe some regexp, but I am not sure.

Does anyone have any suggestions on how to approach this problem or any possible solutions? I'm quite lost. Thanks in advance for any answers and comments!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文