# 探险者对带“？”的评论感到困惑

**URL:** https://meta.discourse.org/t/explorer-confused-by-comment-with/239693
**Category:** Bug
**Tags:** data-explorer
**Created:** [2022年九月21日 19:30 UTC](https://meta.discourse.org/t/explorer-confused-by-comment-with/239693 "2022-09-21T19:30:52Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![ganncamp](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ganncamp/32/106199_2.png) [@ganncamp](https://meta.discourse.org/u/ganncamp)
#### Post date: [2022年九月21日 19:30 UTC](https://meta.discourse.org/t/explorer-confused-by-comment-with/239693/1 "2022-09-21T19:30:52Z")

</div>

这是我第二次遇到类似的行为。这次，我能够缩小范围。如果你的查询以包含“?”的引导注释开头，你就会收到关于缺少参数的错误：

 ![Selection_470](https://global.discourse-cdn.com/meta/original/4X/7/f/4/7f4a587aebdea6353bef722e8ba1fb2dd6c4b27d.png)

实际添加一个参数，问题就解决了，查询可以运行：

 ![Selection_472](https://global.discourse-cdn.com/meta/original/4X/4/0/a/40a9c216a04f159401a02f897fe469340a5deca8.png)

或者删除问号，它也可以运行。

---

<div class="post-metadata">

### Author: ![ganncamp](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ganncamp/32/106199_2.png) [@ganncamp](https://meta.discourse.org/u/ganncamp)
#### Post date: [2022年九月23日 18:18 UTC](https://meta.discourse.org/t/explorer-confused-by-comment-with/239693/2 "2022-09-23T18:18:34Z")

</div>

不只是引导性评论。看起来任何带有“？”的评论都会出现……？

 ![Selection_477](https://global.discourse-cdn.com/meta/original/4X/e/3/8/e38e061263e4b870a49e538a0646457b8f337691.png)

---

<div class="post-metadata">

### Author: ![fzngagan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fzngagan/32/259349_2.png) [@fzngagan](https://meta.discourse.org/u/fzngagan)
#### Post date: [2022年九月23日 20:59 UTC](https://meta.discourse.org/t/explorer-confused-by-comment-with/239693/3 "2022-09-23T20:59:26Z")

</div>

我已记录此问题，我们正计划着手改进此行为。一旦取得进展，我们会及时与您联系。

---

<div class="post-metadata">

### Author: ![tgxworld](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tgxworld/32/106117_2.png) [@tgxworld](https://meta.discourse.org/u/tgxworld)
#### Post date: [2022年十月7日 08:03 UTC](https://meta.discourse.org/t/explorer-confused-by-comment-with/239693/4 "2022-10-07T08:03:06Z")

</div>

@ganncamp 感谢您提供详细报告，在此留下便条告知您我们已在准备修复。

> <https://github.com/discourse/discourse-data-explorer/pull/189>
>
> Before this fix, the use of PG template patterns containing ":" or the
> use of "?…" in comments in the SQL will result in an error being raised
> because \`DB.param\_encoder.encode\` calls ActiveRecord's \`sanitize\_sql\_array\` which is
> meant for SQL fragments and not an entire SQL string.
> 
> Instead we change data-explorer to use \`MiniSql::InlineParamEncoder\`
> instead which takes into account of template patterns and does not trip
> on \`?\` which is a special param encoding character used by ActiveRecord.

---

<div class="post-metadata">

### Author: ![tgxworld](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tgxworld/32/106117_2.png) [@tgxworld](https://meta.discourse.org/u/tgxworld)
#### Post date: [2022年十一月1日 00:00 UTC](https://meta.discourse.org/t/explorer-confused-by-comment-with/239693/5 "2022-11-01T00:00:41Z")

</div>

此主题已在 21 天后自动关闭。不再允许回复。
