Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return a Point object from the PG Point type #20448

Merged
merged 1 commit into from Jun 7, 2015

Conversation

sgrif
Copy link
Contributor

@sgrif sgrif commented Jun 5, 2015

This introduces a deprecation cycle to change the behavior of the
default point type in the PostgreSQL adapter. The old behavior will
continue to be available for the immediate future as :legacy_point.

The current behavior of returning an Array causes several problems,
the most significant of which is that we cannot differentiate between an
array of points, and a point itself in the case of a column with the
point[] type.

The attributes API gives us a reasonable way to have a proper
deprecation cycle for this change, so let's take advantage of it. If we
like this change, we can also add proper support for the other geometric
types (line, lseg, box, path, polygon, and circle), all of which are
just aliases for string today.

Fixes #20441

This introduces a deprecation cycle to change the behavior of the
default point type in the PostgreSQL adapter. The old behavior will
continue to be available for the immediate future as `:legacy_point`.

The current behavior of returning an `Array` causes several problems,
the most significant of which is that we cannot differentiate between an
array of points, and a point itself in the case of a column with the
`point[]` type.

The attributes API gives us a reasonable way to have a proper
deprecation cycle for this change, so let's take advantage of it. If we
like this change, we can also add proper support for the other geometric
types (line, lseg, box, path, polygon, and circle), all of which are
just aliases for string today.

Fixes rails#20441
@sgrif
Copy link
Contributor Author

sgrif commented Jun 5, 2015

@rafaelfranca
Copy link
Member

:shipit:

sgrif added a commit that referenced this pull request Jun 7, 2015
Return a `Point` object from the PG Point type
@sgrif sgrif merged commit ee372bd into rails:master Jun 7, 2015
@sgrif sgrif deleted the sg-postgresql-point-type branch Jun 7, 2015
@meinac
Copy link
Contributor

meinac commented Jun 7, 2015

Ups, I was looking at the pr and it has been merged before my comment 😄


def cast(value)
case value
when ::String
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When an empty string is passed-in, this fails with "can't convert nil into Float". This ends-up happening when a user doesn't enter a value on a form for example. Should this method be converting empty string to nil and storing it as such?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants