Repository navigation
Conversation
There was a problem hiding this comment.
There is no reason to have any special code in postgres - having all the code in abstract datatypes is fine
There was a problem hiding this comment.
Dialect specific datatypes are only used if a data type is only supported by a single dialect, or if a dialect uses a different type (for example postgres blobs = bytea)
The geometry type is supported by mysql and mssql as well
|
Looking good so far! :) To be able to test this you need to enable postgis in the travis config. http://docs.travis-ci.com/user/using-postgresql/#Using-PostGIS It seems like geojson is also supported in mysql 5.7 (http://dev.mysql.com/doc/refman/5.7/en/spatial-geojson-functions.html#function_st-geomfromgeojson) - but its still in development, so... When fetching data again, the data is returned in the well-known text format, but it should be as simple as pluging in https://www.npmjs.com/package/wellknown or similar to return geojson Still needs unit tests for escaping geo types, and integration tests, but you probably already know that :) It could be super-duper awesome if you can get this to work for mysql and mssql as well using WKT - it shouldn't be a lot of added work. |
|
@mibrito , @mikeringrose, @Ghirro Which of you are still working on this feature, and whats the best way to move forward with it? Are any of you tempted by the posibiltiy of implenting this using wkt in mysql / mssql and geojson in PG. If we can only get the postgres support in for now that'd also be fine, but I'd love to support this cross-dialect |
|
@janmeier since i'll be using it in production shortly. i plan on writing more test and add mysql support this weekend. |
|
@mikeringrose Looking forward to it :) |
|
Hi, very cool stuff mibrito, I was about to start hacking my own support into the escape functions before I saw this pull request. I've found one issue while testing this on legacy tables, if the column name is not equal to the attribute name, i.e. Then the abstract query generator fails because in "mainModel._isGeometryAttribute(attr)" , the value of attr is actually "the_geom,geometry" (The pull request appears to be for 2.1 instead of 3.0?) |
There was a problem hiding this comment.
attr may be composed of both the column name and the alias, comma separated. Then the lookup doesn't work.
|
Any updates on this? This seems to be a valid feature that is not there. yet (?) |
|
Closed in favor of #3828 |
As discussed on #2839, it would be nice to have this feature on sequelize. Particulary I'm working in a project using sequelize that needs to be able to insert and retrieve geographic data from PostgreSQL with PostGIS. So I made a fork of the sequelize and tried to insert some initial steps to achive this functionality.
Basicaly was created a new datatype GEOMETRY and some of the functions were adapted to store geometries using GeoJSON objects (ST_GeomFromGeoJSON) and retrieve them as GeoJSON (ST_AsGeoJSON).
The new datatype created is based on Geometry Type Definition syntax added on PostGIS version 2.0.0:
Sequelize.GEOMETRY(geometry_type::asString)Allows the method .sync() to create a new column of the type Geometry(geometry_type), which by default on PostGIS has srid equals -1.
Sequelize.GEOMETRY(geometry_type::asString, srid::asNumber)Allows the method .sync() to create a column of type Geometry(geometry_type, srid).
postgres.QueryGenerator.escape()Was modified to "escape" geometry data using PostGIS function ST_GeomFromGeoJSON.
abstract.QueryGenerator.selectQuery()Was modified to retrieve data as GeoJSON using PostGIS function ST_AsGeoJSON.
Instance.prototype.set()Was modified to parse GeoJSON object as JSON.
Model now has a vector called
_geometryAttributes, a function called_hasGeometryAttributesand a function called_isGeometryAttribute.As a first attempt it still needs some tests and adjustments, so i'm sharing it now to have some feedback and ideas on the changes that are needed.