How do I define multidimensional arrays? #49

Closed
coffeebite opened this Issue Jan 15, 2013 · 3 comments

Comments

Projects
None yet
2 participants

How do I define multidimensional arrays with this gem?

Contributor

danmcclain commented Jan 15, 2013

All PostgreSQL arrays are multidimensional arrays. As of 9.2, there is no way to specify that you want an array or a multidimensional array. One thing to note is that your multidimensional array must be rectangular, ie each sub-array must have the same number of elements.

danmcclain closed this Jan 15, 2013

Oh .. did not know that. Thank you.

Contributor

danmcclain commented Jan 15, 2013

However, the current implementation ignores any supplied array size limits, i.e., the behavior is the same as for arrays of unspecified length.

The current implementation does not enforce the declared number of dimensions either. Arrays of a particular element type are all considered to be of the same type, regardless of size or number of dimensions. So, declaring the array size or number of dimensions in CREATE TABLE is simply documentation; it does not affect run-time behavior.

http://www.postgresql.org/docs/9.2/static/arrays.html#ARRAYS-DECLARATION for future reference, I should probably add this to the README

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