英文:
How can I run the CQL query "(col1, col2) IN ((1,2), (3,4))" with GoCQLX?
问题
好的,以下是翻译好的内容:
嗯,标题可能不太具有信息性,抱歉。
如果我使用以下代码:
qb.Select(...)
.Where(
qb.Eq("part_key_col1"),
qb.Eq("part_key_col1"),
qb.In("clust_key_col1"),
qb.In("clust_key_col2")
)
查询构建器将生成以下SQL语句:
SELECT ...
WHERE part_key_col1 = ?
AND part_key_col1 = ?
AND clust_key_col1 IN ?
AND clust_key_col2 in ?
现在,如果我传递2个clust_key_col1
值(例如"hello"和"world")和2个clust_key_col2
值("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", "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.
答案1
得分: 1
在快速调查中,似乎GoCQLX查询构建器在使用IN()
运算符时不支持复杂嵌套。
你可以尝试向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!
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论