Skip to content

Geometry Support - #3828

Closed
mikeringrose wants to merge 15 commits into
sequelize:masterfrom
mikeringrose:master
Closed

mikeringrose wants to merge 15 commits into
sequelize:masterfrom
mikeringrose:master

Conversation

@mikeringrose

Copy link
Copy Markdown

This was originally based on #3641, however, I fixed some bugs and hopefully made the code more extensible. If you're happy with the path that I am on, I'll add support for MySQL (and more tests).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This should use WKT righT?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Not sure parsing belongs in the QG. Perhaps in dialects/X/geojson.js? With a parse and stringify function similar to how PG range works https://github.com/sequelize/sequelize/blob/master/lib/dialects/postgres/range.js

@janmeier

Copy link
Copy Markdown
Member

Looking good so far! Give me shout when you have something more, or if you have issues with WKT support :)

@janmeier

Copy link
Copy Markdown
Member

Any news @mikeringrose

@mikeringrose

Copy link
Copy Markdown
Author

jan,

here's the issue that i'm currently running into. when sequelize performs
an insert the following is execute:

INSERT INTO "tablename" ("id","geom") VALUES
(DEFAULT,ST_GeomFromGeoJSON('{"type":"Point","coordinates":[34,-72]}'))
RETURNING *;

this causes an issue since we're not generating the select clause here, the
value being returned from the postgres is hex encoded wkb. there are two
solutions, 1) decode the value using hex encoded wkb and then transform to
geojson or 2) generate a proper select statement. i think the latter would
be better moving forward and the former should be now to add this feature.
Any opinions?

Mike Ringrose

On Sun, Jun 14, 2015 at 8:36 AM, Jan Aagaard Meier <[email protected]

wrote:

Any news @mikeringrose https://github.com/mikeringrose

—
Reply to this email directly or view it on GitHub
#3828 (comment).

@janmeier

Copy link
Copy Markdown
Member

@mikeringrose Agreed, the right solution would definitely be to generate the correct select statement.

However, I can fully understand that you don't want to undertake that now - and since this is the only case where this has been a problem up to now it would be a lot of work just for this feature :). We would be fine with merging 1 for now.

@mikeringrose

Copy link
Copy Markdown
Author

Awesome. Thanks Jan. I update my PR in the morning and then I wouldn't mind
helping out on some other features. Sorry for the delay, lots of projects,
little time. :)

Mike Ringrose

On Wed, Jun 17, 2015 at 11:41 AM, Jan Aagaard Meier <
[email protected]> wrote:

@mikeringrose https://github.com/mikeringrose Agreed, the right
solution would definitely be to generate the correct select statement.

However, I can fully understand that you don't want to undertake that now

  • and since this is the only case where this has been a problem up to now
    it would be a lot of work just for this feature :). We would be fine with
    merging 1 for now.

—
Reply to this email directly or view it on GitHub
#3828 (comment).

@mikeringrose

Copy link
Copy Markdown
Author

I added a few tests, moved the parsing out of query-generator, and i'm now using the raw value returned from postgresql instead of converting it to GeoJSON. The new way I read the value in as binary, then as WKB, and finally to GeoJSON.

Comment thread logfile

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

🔥

@janmeier

Copy link
Copy Markdown
Member

@mikeringrose Sounds very good! If everything is passing locally for you you should rebase so we can run the tests on travis :)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I believe this should be just POINT in the general case (for mysql at least)

@mikeringrose

Copy link
Copy Markdown
Author

Cool. I'll make that change. I was thinking that since this PR has been going on for a while, I'd add the postgis implementation first followed by the msyql implementation. I have a lot more experience with postgis but a mysql implemenation should follow fairly fast.

Comment thread lib/instance.js

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We don't need the && value !== null && value !== undefined && !value._isSequelizeMethod part, when we check isString right after :)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Good catch. Will change.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This function is never overridden by dialects, so it could just be inlined, right?

@janmeier

Copy link
Copy Markdown
Member

Very clean and readable code @mikeringrose - good work so far!

@mikeringrose

Copy link
Copy Markdown
Author

Are you cool if I just re-branch off of the latest code and apply my changes? I'm running into some painful merge conflicts.

@janmeier

Copy link
Copy Markdown
Member

Yep, thats fine

@mikeringrose

Copy link
Copy Markdown
Author

All code has been moved to the following PR: #4013.

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.

3 participants