哪个 Ruby ORM 支持 PostgreSQL 的数组数据类型?
我需要找到一个支持 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
正如您在之前的评论中提到的,Sequel 的 sql_subscript 仅用于在查询时访问值。
除此之外,Sequel 没有对数据库数组的特殊支持。您可以在 create_table 块中创建数组:
但这并不是特殊支持,因为 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:
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.
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#|
andSymbol#/
, 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.