我如何在((1,2),(3,4)中运行CQL查询“(Col1,col2));与gocqlx?

发布于 2025-02-11 11:59:28 字数 1015 浏览 1 评论 0原文

好吧,标题可能不太有用,对不起。

如果我使用

qb.Select(...)
  .Where(
    qb.Eq("part_key_col1"),
    qb.Eq("part_key_col1"), 
    qb.In("clust_key_col1"),
    qb.In("clust_key_col2")
  )

,请查询构建器构造:

SELECT ...
  WHERE part_key_col1 = ?
  AND part_key_col1 = ?
  AND clust_key_col1 IN ?
  AND clust_key_col2 in ?

现在,如果我通过2 clust_key_col1(例如,“ hello”和“ hello”和“ hello”)和2 clust_key_col2 values(“ foo”和“ foo”和“ bar”),它构建:

SELECT ...
  WHERE part_key_col1 = ?
  AND part_key_col1 = ?
  AND clust_key_col1 IN ("hello", "world")
  AND clust_key_col2 in ("foo", "bar")

这导致4个可能的匹配:

hello foo
hello bar
world foo
world bar

我应该如何使用gocqlx qb构造此查询:where(part_key_col1,part_key_col2)in((“ hello”,“ hello”,“ foo”),(“ world” “,” bar“”))?我想通过任意数量的元素。

Well, the title may be not quite informative, sorry.

If I use

qb.Select(...)
  .Where(
    qb.Eq("part_key_col1"),
    qb.Eq("part_key_col1"), 
    qb.In("clust_key_col1"),
    qb.In("clust_key_col2")
  )

, query builder constructs:

SELECT ...
  WHERE part_key_col1 = ?
  AND part_key_col1 = ?
  AND clust_key_col1 IN ?
  AND clust_key_col2 in ?

Now if I pass, say, 2 clust_key_col1 (e.g. "hello" and "world") and 2 clust_key_col2 values ("foo" and "bar"), it builds:

SELECT ...
  WHERE part_key_col1 = ?
  AND part_key_col1 = ?
  AND clust_key_col1 IN ("hello", "world")
  AND clust_key_col2 in ("foo", "bar")

This leads to 4 possible matches:

hello foo
hello bar
world foo
world bar

How should I use gocqlx qb to construct this query: WHERE (part_key_col1, part_key_col2) IN (("hello", "foo"), ("world", "bar")) ? I want to pass arbitrary number of elements.

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

许久 2025-02-18 11:59:28

在快速研究中,在使用() operator中使用时,GoCQLX查询构建器似乎都支持复杂的嵌套。

您最好与Scylla的团队一起记录门票。我已经标记了您的问题,希望有人会看到它。您还可以创建针对gocqlx存储库的问题。干杯!

On a quick research, it doesn't appear as though the GoCQLX query builder supports complex nesting when using the IN() operator.

You have better luck logging a ticket with the team at Scylla. I've tagged your question so hopefully someone will see it. You can also create an issue against the GoCQLX repository. Cheers!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文