Skip to content

Adding GEOMETRY Support - #4013

Merged
janmeier merged 5 commits into
sequelize:masterfrom
mikeringrose:master
Jun 28, 2015
Merged

janmeier merged 5 commits into
sequelize:masterfrom
mikeringrose:master

Conversation

@mikeringrose

Copy link
Copy Markdown

This is to replace PR #3828. Same code added to the latest in master.

@mikeringrose

Copy link
Copy Markdown
Author

Locally make postgres passes just fine.

1568 passing (2m)
2 pending

@mikeringrose

Copy link
Copy Markdown
Author

@janmeier if there's anything else that'd you'd like me to change, let me know. Otherwise I'll begin adding MySQL support in another PR.

@mikeringrose mikeringrose mentioned this pull request Jun 27, 2015
@janmeier

Copy link
Copy Markdown
Member

@mikeringrose Nope, everything looks good! Looking forward to the next PR :)

janmeier added a commit that referenced this pull request Jun 28, 2015
@janmeier
janmeier merged commit 56dbddd into sequelize:master Jun 28, 2015
@gordlea gordlea mentioned this pull request Jun 29, 2015

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

hey @mikeringrose, I think you are either missing another term in this statement, or need to remove the leading "+". I tried creating geometry with DataTypes.GEOMETRY("Point", 4326) and ended up having bad queries generated due to this line.

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.

Thanks for the heads up. I'll be submitting a fix for this issue tomorrow
to address the following bug -
#4054. If you need things to
work for now, you can leave off the SRID. Thanks again.

Mike Ringrose

On Tue, Jul 7, 2015 at 9:22 PM, Kris Rasmussen [email protected]
wrote:

In lib/dialects/postgres/query-generator.js
#4013 (comment):

@@ -897,6 +897,13 @@ var QueryGenerator = {
return 'ARRAY[' + value.map(function (v) {
return SqlString.escape(JSON.stringify(v), false, this.options.timezone, this.dialect, field);
}, this).join(',') + ']::' + jsonType.key + '[]';

  • } else if (value && field && field.type instanceof DataTypes.GEOMETRY) {
  •  var s = "ST_GeomFromGeoJSON('" + JSON.stringify(value) + "'";
    
  •  if (field.type.srid) {
    
  •    s += + ", " + field.type.srid;
    

hey @mikeringrose https://github.com/mikeringrose, I think you are
either missing another term in this statement, or need to remove the
leading "+". I tried creating geometry with DataTypes.GEOMETRY("Point",
4326) and ended up having bad queries generated due to this line.

—
Reply to this email directly or view it on GitHub
https://github.com/sequelize/sequelize/pull/4013/files#r34108922.

@mshahriarinia

Copy link
Copy Markdown

What is the syntax for sequelize postgres geometry? Is there a HelloWorld example?

@janmeier

Copy link
Copy Markdown
Member

@mshahriarinia We will add documentation for this once all dialects are supported.

Until then Id recommend you to look at the tests in this PR to see the syntax

@mshahriarinia

Copy link
Copy Markdown

I am using the latest version on github f38d0ca, and I have postgres+postgis. Quick note for folks: on you DB make sure you run CREATE EXTENSION postgis; otherwise you get Error: "geometry" does not exist from postgres.

Here is where I picked the example from

@mshahriarinia

Copy link
Copy Markdown

Can I do distance calculation between a lat/lon and a point column in potgres in current state or top k closest points to a given point? I went through all sorts of code, looks like somebody introduced the concept of $geoWithin, $geoIn, but got deleted from pull request?

@janmeier

Copy link
Copy Markdown
Member

@mshahriarinia Unfortunately those operators were not integrated into the final pull request.

They would definitely be nice to have, so a PR to re-add them would be very wellcome! The code should be pretty similar to whats in this PR, just needs to be migrated

@mikeringrose

Copy link
Copy Markdown
Author

That'd be awesome if we could get those in. 👍

On Mon, Jul 13, 2015 at 3:17 AM, Jan Aagaard Meier <[email protected]

wrote:

@mshahriarinia https://github.com/mshahriarinia Unfortunately those
operators were not integrated into the final pull request.

They would definitely be nice to have, so a PR to re-add them would be
very wellcome! The code should be pretty similar to whats in this PR, just
needs to be migrated

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

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.

4 participants