-
Notifications
You must be signed in to change notification settings - Fork 245
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
feat: geospatial types support #4208
base: main
Are you sure you want to change the base?
Conversation
2f8c856
to
dd4410c
Compare
Absolutely boss 🚀 |
CodSpeed Performance ReportMerging #4208 will not alter performanceComparing Summary
|
Amazing. So that the tests are automatically run going forward: |
adf09c6
to
a588e12
Compare
So there was quite a lot of things I had overlooked when testing on my machine..! I squashed all the fixes and we now have a mostly green test suite 👍 |
🚀 Two test failures left for now:
PS: No need from our side to combine your PRs and force push, we only merge via "Squash and merge" which combines all the commits, and with the individual commits of the fixes it might be easier to understand what test failures where fixed where - or introduced. |
a588e12
to
3522419
Compare
So the two additional queries breaking the tests are due to:
and
Both are needed to run the tests, I updated the counter to 9 to make the test succeed. No clue about the Vitess issue though...
EDIT: it's now all fixed 🙌 |
How can I help to merge it? |
Test it, figure out how it would fit into Prisma, let the author and us know what else is needed to make this a complete feature. |
@janpio @Oreilles thanks for all you do guys. I am at the point in my project to start introducing PostGIS and trying to figure out how to test this PR. I cloned @Oreilles feature branch and compiled debug targets of |
@okonon Have a look at the documentation: https://www.prisma.io/docs/concepts/components/prisma-engines#using-custom-engine-libraries-or-binaries |
@RafaelKr thanks a lot for that sorry i missed that section. |
Adding a comment to voice support for this to be added to Prisma! Looking forward to seeing this merged; keep up the good work. |
Definitely would love that to be merged as well 👍 |
Sorry, but this will definitely not be merged as it is only part of the full feature that needs to be implemented. But we are interested in bringing it there, so let's see what we can do here. |
For now I created a branch based on the commit this was forked from, so that there are no conflicts and @Oreilles can keep committing if they want. I also created a local branch of the code that runs all our CI (Buildkite is not run on external contributions), with the goal of publishing the engines to our infrastructure, so we can build a Prisma CLI and Client with them for further testing. But unfortunately some tests are failing (results only internally visible): #4427 Random example of a SQLite failure, our of many (
MySQL 5.6 only fails 2:
5.7 only 1 even:
MariaDB the same as 5.6:
Trying to get these tests to run on GitHub Actions now. But maybe you have speculative fixes @Oreilles? |
Interesting, as far as I can remember (almost) all tests were succeeding the last time we discussed the PR, and we did have tests for all MySQL versions... though I might remember wrong. Did you resolve merge conflicts when you merged Anyway, I'll have a look as soon as possible. Edit: nevermind, I had not seen that they were already mentioned in your message! |
@Oreilles just wanted to say i appreciate your work and loving these commits |
…is required which only ships with Ubuntu 22.04
Got back at it, now up to date with main! Made many changes to make it easier to digest (and maintain), specifically:
I had to disable the schema engine tests CI for Spatialite, since libspatialite >= 5.0.0 is required and that only ships starting with Ubuntu 22.04. (the CI fail with an SSL error if we try to update the runner). |
… so let's try it with latest instead.
I will be so happy when this feature will be merged! Thank you for your work and effort ❤️ |
Fixes prisma/prisma#1798
Fixes prisma/prisma#2789
This PR implements support for database geometry types. I'll start this message by saying that, although I'd be very proud of making such a contribution to Prisma, I understand that the likeliness of such a massive PR to be accepted is pretty low due to the time I'd take to fully review. How did I end up there ? In the end of last year, I tried to get in touch with the team as I had some experience in the field, and also had the time to work on the feature - but by the time we managed to exchange emails I no longer had enough time to invest in working on this. Last month, I had time and remembered about this project, so I started browing the prisma repo - and realised the ORM core was not actually Typescript, but full Rust, which I had no previous experience with. I questioned my ability to be up to the task, but though: why not have a go at it ? Not having sufficient rust experience, I decided against getting back in touch with the Prisma team and just leverage this project as a learning experience. A month later, although it is very far from being production ready, I believe this branch might deserve some attention which is why I decide to release it. Again, apologies about the size. I worked on this as a learning experience and ended up getting quite ahead of myself.. heh.
Now for the meat of the PR, here's what it includes:
In the
psl
/query-engine
:ScalarType
s:Geometry
andGeoJSON
. Both types refer to the same underlying database types, they only differ in the geometry serialization format the user wants to use:GeoJSON
forGeoJSON
,EWKT
forGeometry
. Why do we need both ?GeoJSON
is the format most people wants to use, as they most likely use TypeScript andGeoJSON
is the de-facto standard for manipulating geometries on the web. ButEwkt
allows for richer information about the raw geometry: it can be used to serialize geometry in any CRS (when GeoJSON is limited by specification to WGS84), and can also represent more geometry types than geojson (CIRCULARSTRING
,CURVEPOLYGON
etc). As such, onlyEWKT
can be used to safely & exhaustively read database geometries.Geometry(Not)Within
mapping tost_within
Geometry(Not)Intersects
mapping tost_intersects
In
quaint
:Value
s:Geometry
andGeography
, which both holds the same type (GeometryValue
, a struct with a WKT string and an SRIDi32
). We might have needed only one, but MSSQL required making the two explicitly different.geom_from_text
, that maps to the SQL/MMst_geomfromtext
.geom_as_text
, that maps tost_astext.
geometry_is_valid
that maps tost_isvalid
geometry_is_empty
that maps tost_isempty
geometry(_not)_within
that maps tost_within
geometry(_not)_intersects
that maps tost_intersects
geometry_type(_not)_equals
that maps tost_geometrytype(x) = ...
All in all, what works:
SPATIALITE_PATH
)Within
andIntersects
operators for all vendors except MongoDB (Mongo has the$geoWithin
and$geoIntersects
query operators, however they cannot be used with the current connector implementation, since those are Query operators wherehas Prisma uses Aggregation operators. Unfortunately, they're not compatible, and no geospatial filtering operators are available for aggregate queries in MongoDB.What hasn't been fully implemented / properly tested:
There is still a lot of work to do here, but I was quite happy to get the core features (introspection, IO and filtering) going and though it was worth sharing.
My intent with this PR is to show a possible implementation, start a discussion with the team and community about its viability, potential drawbacks and help making these features reach Prisma in a production ready state. Questions about the implementation details are welcome and encouraged. Please get in touch at aurele.nitoref at icloud if you'd like to discuss this more thoroughly!