哪个 Ruby ORM 支持 PostgreSQL 的数组数据类型?

发布于 2024-11-05 05:26:36 字数 243 浏览 0 评论 0原文

我需要找到一个支持 PostgreSQL 数组列数据类型的 Ruby ORM(Active Record、Sequel 等)。

http://www.postgresql.org/docs/8.2/interactive/arrays.html 有什么

建议吗?

I'm need to find a Ruby ORM (Active Record, Sequel, etc) that supports PostgreSQL's Array column datatype.

http://www.postgresql.org/docs/8.2/interactive/arrays.html

Any tips?

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

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

发布评论

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

评论(2

_畞蕅 2024-11-12 05:26:36

正如您在之前的评论中提到的,Sequel 的 sql_subscript 仅用于在查询时访问值。

除此之外,Sequel 没有对数据库数组的特殊支持。您可以在 create_table 块中创建数组:

DB.create_table do
  column :numbers, 'integer[]'
end

但这并不是特殊支持,因为 Sequel 只是传递类型。在构建查询时,没有内置支持获取 ruby​​ 数组并将其转换为 PostgreSQL 数组,也不支持在检索时将 PostgreSQL 数组转换为 ruby​​ 数组(它将作为字符串返回)。

话虽如此,Sequel 的设置是为了可以相对轻松地实现提供完全集成的 PostgreSQL 数组和 hstore 类型的扩展。有人一直在致力于对 hstore 的支持(我认为它已经完成或接近完成,但我还没有审查它),对数组的支持应该与此类似。 Sequel 的未来版本很可能会默认提供此类支持,或者作为官方扩展提供。

Sequel's sql_subscript is just for accessing values when querying, as you mentioned in an earlier comment.

Sequel doesn't have special support for database arrays other than that. You can create arrays in create_table blocks:

DB.create_table do
  column :numbers, 'integer[]'
end

But that's not special support as Sequel is just passing the type through. There's no built-in support for taking a ruby array and turning it into an PostgreSQL array when building a query, and there's also no support for turning the PostgreSQL array into a ruby array when retrieving (it'll be returned as a string).

That being said, Sequel is set up so that extensions for PostgreSQL's array and hstore types that offer full integration could be implemented with relative ease. Someone has been working on support for hstore (I think it's finished or close to it, but I haven't reviewed it yet), and support for arrays should be similar to that. It's likely that a future version of Sequel will ship with such support either by default or available as an official extension.

小红帽 2024-11-12 05:26:36

Sequel 通过 sql_subscript

最初在版本 0.4.3(2007 年 12 月)中通过 Symbol#|Symbol#/ 添加了支持,但在版本 2.12.0(2009 年 - 4 月)。搜索CHANGELOG,了解随着时间推移发生的改进的更多提及。

Sequel supports this through the sql_subscript method on Symbols (and others).

Support was originally added in release 0.4.3 (2007-Dec) via Symbol#| and Symbol#/, but was changed to use the new method in release 2.12.0 (2009-Apr). Search the CHANGELOG for more mentions of improvements that have occurred over time.

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