# PostgreSQL Array field type

**URL:** <https://www.ruby-forum.com/t/postgresql-array-field-type/51166>\
**Category:** Rails\
**Created:** [December 27, 2005, 3:39pm UTC](https://www.ruby-forum.com/t/postgresql-array-field-type/51166 "2005-12-27T15:39:13Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![samer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/dfb087/32.png) [@samer](https://www.ruby-forum.com/u/samer)\
**Post date:** [December 27, 2005, 3:39pm UTC](https://www.ruby-forum.com/t/postgresql-array-field-type/51166/1 "2005-12-27T15:39:13Z")

</div>

It seemed to me that rails extract the special database field type  
(Array … In PostgreSQL) as a string… {‘One’,‘Two’}  
wouldn’t it be great if it got converted to a Ruby array directly?

---

<div class="post-metadata">

**Author:** ![samer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/dfb087/32.png) [@samer](https://www.ruby-forum.com/u/samer)\
**Post date:** [December 27, 2005, 4:06pm UTC](https://www.ruby-forum.com/t/postgresql-array-field-type/51166/2 "2005-12-27T16:06:24Z")

</div>

On 12/27/05, Samer A. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> It seemed to me that rails extract the special database field type  
> (Array … In PostgreSQL) as a string… {‘One’,‘Two’}  
> wouldn’t it be great if it got converted to a Ruby array directly?

I don’t see this making it into rails core because it is a database  
specific feature. I’m just thinking out loud here, but I could see  
there being database-specific plugins. Perhaps you could start a  
postgresql plugin that integrates some of its cooler and unique  
features into AR? It’d be a nice little project to use to learn the  
internals of Active Record.

–  
rick  
[http://techno-weenie.net](http://techno-weenie.net)

---

<div class="post-metadata">

**Author:** ![samer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/dfb087/32.png) [@samer](https://www.ruby-forum.com/u/samer)\
**Post date:** [December 27, 2005, 4:18pm UTC](https://www.ruby-forum.com/t/postgresql-array-field-type/51166/3 "2005-12-27T16:18:30Z")

</div>

Take look at [http://dev.rubyonrails.org/ticket/1480](http://dev.rubyonrails.org/ticket/1480) and  
[http://dev.rubyonrails.org/ticket/3272](http://dev.rubyonrails.org/ticket/3272)

---

<div class="post-metadata">

**Author:** ![samer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/dfb087/32.png) [@samer](https://www.ruby-forum.com/u/samer)\
**Post date:** [December 29, 2005, 2:37am UTC](https://www.ruby-forum.com/t/postgresql-array-field-type/51166/4 "2005-12-29T02:37:46Z")

</div>

> the SQL spec, they’re a reasonably widely recognized standard  
> [http://www.locationintelligence.net/articles/657.html](http://www.locationintelligence.net/articles/657.html)  
> [http://postgis.refractions.net/](http://postgis.refractions.net/)  
> [http://dev.mysql.com/doc/refman/5.0/en/spatial-extensions-in-mysql.html](http://dev.mysql.com/doc/refman/5.0/en/spatial-extensions-in-mysql.html)

I’d suggest submitting a patch, or you’ll have to wait until someone  
else has the need for the feature and implements it. The plugin idea  
is even better because you can get real-world usage out of it, making  
it more likely to making it into rails core.

–  
rick  
[http://techno-weenie.net](http://techno-weenie.net)

---

<div class="post-metadata">

**Author:** ![samer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/dfb087/32.png) [@samer](https://www.ruby-forum.com/u/samer)\
**Post date:** [December 29, 2005, 2:22am UTC](https://www.ruby-forum.com/t/postgresql-array-field-type/51166/5 "2005-12-29T02:22:40Z")

</div>

Rick O. wrote:

> On 12/27/05, Samer A. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > It seemed to me that rails extract the special database field type  
> > (Array … In PostgreSQL) as a string… {‘One’,‘Two’}  
> > wouldn’t it be great if it got converted to a Ruby array directly?
> 
> I don’t see this making it into rails core because it is a database  
> specific feature.

Array datatypes are certainly part of the SQL Standard  
[http://farrago.sourceforge.net/design/CollectionTypes.html](http://farrago.sourceforge.net/design/CollectionTypes.html)  
and even if a database vendor handles them a bit poorly (in  
nonstandard ways), it would be very nice if array functionality  
were still available in ActiveRecord, which could mask the  
nonstandard behavior.

I’d like to see OpenGIS standard spatial datatypes supported  
in ActiveRecord as well – even though they’re not part of  
the SQL spec, they’re a reasonably widely recognized standard  
with support in Oracle, DB2, PostgreSQL and MySQL at least.  
I think with third-party extensions (from ESRI) they can  
work with SQL Server too.

Would that make it standard enough to get ActiveRecord Support.

(refs)

[http://www.oracle.com/technology/products/spatial/htdocs/data\_sheet\_9i/9iR2\_spatial\_ds.html](http://www.oracle.com/technology/products/spatial/htdocs/data_sheet_9i/9iR2_spatial_ds.html)  
[http://www.locationintelligence.net/articles/657.html](http://www.locationintelligence.net/articles/657.html)  
[http://postgis.refractions.net/](http://postgis.refractions.net/)  
[http://dev.mysql.com/doc/refman/5.0/en/spatial-extensions-in-mysql.html](http://dev.mysql.com/doc/refman/5.0/en/spatial-extensions-in-mysql.html)

I’m just thinking out loud here, but I could see
