另一种方法是构建一个到 postgres C 接口的非常简单的绑定,然后使用它。在这种情况下,抽象不是很有帮助,但绝对不会泄漏。这可能就足够了。
这就是 Russ Cox(来自核心 Go (golang) 团队)最终为 sqlite 所做的事情。 。
I don't have specific experience with go-psql, but since there's no answer I'll write my thoughts.
There are issues with the current implementation, which might bite you (e.g. time resolution lower than seconds is ignored. What happens if you update a single field, but your ORM decides to include a time field within the query?).
Other problem that I see is, there's no promise this project will be maintained as long as you wish.
Another approach is to build a very simple binding to the postgres C interface, and just use it. In that case, the abstraction is not very helpful, but definitely not leaky. And it might be enough.
That's what Russ Cox (from the core Go (golang) team) ended up doing for sqlite.
发布评论
评论(1)
我对 go-psql 没有具体的经验,但由于没有答案,我会写下我的想法。
当前实现存在一些问题,这可能会困扰您(例如,低于秒的时间分辨率会被忽略。如果您更新单个字段,但您的
ORM
决定包含time<查询中的 /code> 字段?)。
我看到的另一个问题是,不能保证这个项目会按照您的意愿维持下去。
另一种方法是构建一个到
postgres
C 接口的非常简单的绑定,然后使用它。在这种情况下,抽象不是很有帮助,但绝对不会泄漏。这可能就足够了。这就是 Russ Cox(来自核心 Go (golang) 团队)最终为 sqlite 所做的事情。 。
I don't have specific experience with
go-psql
, but since there's no answer I'll write my thoughts.There are issues with the current implementation, which might bite you (e.g. time resolution lower than seconds is ignored. What happens if you update a single field, but your
ORM
decides to include atime
field within the query?).Other problem that I see is, there's no promise this project will be maintained as long as you wish.
Another approach is to build a very simple binding to the
postgres
C interface, and just use it. In that case, the abstraction is not very helpful, but definitely not leaky. And it might be enough.That's what Russ Cox (from the core Go (golang) team) ended up doing for sqlite.