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

PostgreSQL 参数占位符用法 #6

Closed
panjunjie opened this issue Feb 4, 2018 · 2 comments
Closed

PostgreSQL 参数占位符用法 #6

panjunjie opened this issue Feb 4, 2018 · 2 comments

Comments

@panjunjie
Copy link

PostgreSQL 参数的占位符,一般都是 $1...$6... ,而 go-sqlbuilder 生成的 sql 语句是 ?...?... ,这个是有特别的用法,没有在文档里说明吗?

@huandu
Copy link
Owner

huandu commented Feb 4, 2018

这个是 mysql 的用法。

我看了下 pg 的 driver,确实只支持 $1...$n 这样的 placeholder,看起来或许应该支持一下定制下这样的需求,我来考虑一下。

@huandu huandu closed this as completed in 4414789 Feb 4, 2018
@huandu
Copy link
Owner

huandu commented Feb 4, 2018

已经通过 Flavor 机制支持 PostgreSQL,可以用以下方法使用:

  • DefaultFlavor 设置为 PostgreSQL,这样所有 builder 都使用 PostgreSQL 风格的 marker;
  • 使用 PostgreSQL.NewSelectBuilder() 等函数创建 builder;
  • 使用 SelectBuilderSetFlavor(flavor) 方法,所有的 builder 都支持这个方法;
  • 使用 Builder 接口的 BuildWithFlavor(flavor) 方法,在 build 的时候指定 flavor。

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

No branches or pull requests

2 participants