Skip to content

Conversation

MSch
Copy link
Contributor

@MSch MSch commented Aug 10, 2012

@tenderlove https://twitter.com/tenderlove/statuses/231807764907819008

Today I looked into adding support for the postgresql geo types. Everything went well but I didn't manage to get AR to type cast pg's string representation into an array. (See the failing base_test.rb)

Got a pointer for me?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this fails

@ghost ghost assigned tenderlove Aug 10, 2012
@steveklabnik
Copy link
Member

This no longer merges cleanly.

@steveklabnik
Copy link
Member

@MSch ping! Any interest in keeping this pull request up to date?

@MSch
Copy link
Contributor Author

MSch commented Nov 17, 2012

Would love to but I'm stuck with the data type / oid conversions. I'd need some input by someone knowledable (e.g. @tenderlove) on how to best make those conversions actually work in both directions.

@guilleiguaran
Copy link
Member

@MSch try pinging him on twitter.

/cc @tenderlove

@schneems
Copy link
Member

schneems commented Jan 2, 2013

@MSch can you please explain the problem you're having starting from the beginning and pretending I have no prior knowldge of the issue? @tenderlove and the other AR maintainers are notoriously overwhelmed with help requests, the more info you can give me and them the better.

@MSch
Copy link
Contributor Author

MSch commented Jan 9, 2013

@schneems Thanks I'll do that. And thanks for offering! Had a busy last week, so sorry for the late answer:

Postgres has a type point which is a tuple of two floats. I want to add native support to ActiveRecord for this type.

When ActiveRecord queries Postgres about the type of such a point column it doesn't return "point" but rather "this is a composite type made up of two floats" (OIDs of data types).

I looked through the then current AR code to figure out how to hook into only that and then convert PG point <--> Ruby Array but for some reason I couldn't get it to work.

I've seen that my pull request doesn't merge cleanly any more, so maybe something has changed. I'll try again to make this work (since in principle it should be easy IMO) and will come back with some concrete question once I've hit a roadblock.

@rafaelfranca
Copy link
Member

@MSch great! Let me know when you are done

@MSch
Copy link
Contributor Author

MSch commented Jan 9, 2013

@rafaelfranca This time round I didn't get stuck with the vector conversion like last time.

This actually works, but I'm not happy with some of the code. I'm not sure if it wouldn't be better to generally convert all vectors into ruby arrays (like described here

# FIXME: this should probably split on +delim+ and use +subtype+
) or not. OTOH I'd actually love to convert points, uuids, etc. into specialized ruby types that closer mirror Postgres semantics. But that's another PR.

Comments anyone?

@MSch
Copy link
Contributor Author

MSch commented Jan 16, 2013

@rafaelfranca ping! it's been a week, i'm anxious :) got any input for me?

@bai
Copy link
Contributor

bai commented Jan 16, 2013

Very interested in this one.

Copy link
Member

Choose a reason for hiding this comment

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

Why it is instantiate latter?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

see below.

@bai
Copy link
Contributor

bai commented Jan 26, 2013

I've seen postgres range support PR has been merged, any decisions on this one? /cc @tenderlove

@esad
Copy link
Contributor

esad commented Jan 30, 2013

+1

@MSch
Copy link
Contributor Author

MSch commented Mar 7, 2013

@rafaelfranca @tenderlove I've fixed the issue with instantiating OID:Point later.

Anything else that needs to be done so that this can be merged?

@MSch
Copy link
Contributor Author

MSch commented Mar 25, 2013

@rafaelfranca ping :)

@rafaelfranca
Copy link
Member

Seems good. Could you add a CHANGELOG entry?

Copy link
Member

Choose a reason for hiding this comment

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

We have to change it to sql_type since this method was removed from Column. See 4b4c8bd

@rafaelfranca
Copy link
Member

Please rebase against master to get the last code changes on the schema methods and see if the tests are passing

@MSch
Copy link
Contributor Author

MSch commented Mar 25, 2013

@rafaelfranca Added CHANGELOG entry. Changed to sql_type, but only in quote, not in type_cast since we're still using column.sql_type there and the tests pass.

rafaelfranca added a commit that referenced this pull request Mar 25, 2013
Add support for pg geometric datatypes point and box
@rafaelfranca rafaelfranca merged commit fc8411a into rails:master Mar 25, 2013
@rafaelfranca
Copy link
Member

Thank you. ❤️ 💚 💙 💛 💜

@MSch MSch deleted the pg-geometric branch March 25, 2013 18:47
@ghost
Copy link

ghost commented Mar 27, 2013

I am in favor of liking this.

@schneems
Copy link
Member

Thanks for this code!!!

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