-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Added 'withinPolygon' to query #3866
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
Changes from 6 commits
0d7d2bb
03b0d5b
f9e935f
4681892
7aaeedc
7a5703f
7f50180
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ const PostgresDuplicateObjectError = '42710'; | |
const PostgresUniqueIndexViolationError = '23505'; | ||
const PostgresTransactionAbortedError = '25P02'; | ||
const logger = require('../../../logger'); | ||
const _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
|
||
const debug = function(){ | ||
let args = [...arguments]; | ||
|
@@ -344,6 +345,25 @@ const buildWhereClause = ({ schema, query, index }) => { | |
index += 2; | ||
} | ||
|
||
if (fieldValue.$geoWithin && fieldValue.$geoWithin.$polygon) { | ||
const polygon = fieldValue.$geoWithin.$polygon; | ||
if (!(polygon instanceof Array)) { | ||
throw new Parse.Error(Parse.Error.INVALID_JSON, 'bad $geoWithin value'); | ||
} | ||
const points = polygon.map((point) => { | ||
if (!((typeof point === 'undefined' ? 'undefined' : _typeof(point)) === 'object' && point !== null && point.__type === 'GeoPoint')) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. doesn't seem to be something a human would write :)
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good thing I'm not human There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry if I offended you, it looked like generated code |
||
throw new Parse.Error(Parse.Error.INVALID_JSON, 'bad $geoWithin value'); | ||
} else { | ||
Parse.GeoPoint._validate(point.latitude, point.longitude); | ||
} | ||
return `(${point.longitude}, ${point.latitude})`; | ||
}).join(', '); | ||
|
||
patterns.push(`$${index}:name::point <@ $${index + 1}::polygon`); | ||
values.push(fieldName, `(${points})`); | ||
index += 2; | ||
} | ||
|
||
if (fieldValue.$regex) { | ||
let regex = fieldValue.$regex; | ||
let operator = '~'; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does that come from transpired babel source? please remove :)