Skip to content
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

Postgresql 'cube' comparison operators are not recognized #77

Open
ghost opened this issue Oct 11, 2013 · 0 comments
Open

Postgresql 'cube' comparison operators are not recognized #77

ghost opened this issue Oct 11, 2013 · 0 comments
Labels

Comments

@ghost
Copy link

ghost commented Oct 11, 2013

Created by Pushnell, 29th Mar 2012. (originally Lighthouse ticket #35):


SHORT VERSION:
The postgresql 'cube' data type comparison operator '@>' is not recognized by Cake, and it therefore incorrectly inserts '=' into the where clause and breaks it.

Example:

'conditions' => array("earth_box(ll_to_earth(43.0367907637681, -89.4037345224754), 8047) @>" => 'earthloc')

Resulting SQL:

... WHERE earth_box(ll_to_earth(43.0367907637681, -89.4037345224754), 8047) @> = 'earthloc'

Expected SQL:

... WHERE earth_box(ll_to_earth(43.0367907637681, -89.4037345224754), 8047) @> 'earthloc'

Error:

SQLSTATE[42601]: Syntax error: 7 ERROR: syntax error at or near "WHERE" LINE 1

DETAILS:
I'm using the earthdistance module with Postgresql to search by distance from a location. ( http://www.postgresql.org/docs/9.1/static/earthdistance.html ) This uses the 'cube' data type to store earth locations ( http://www.postgresql.org/docs/9.1/static/cube.html ).

One of the cube comparison operators is '@>', which means 'is contained by'. So 'A @> B' means cube B is contained by cube A. This operator is not properly recognized in a Model::find() conditions statement, so cake adds '=' and breaks the query.

In case you were wondering, those are the lat/lng coordinates for the capitol building in Madison, WI, and the query is searching for entries within 5 miles (8047 meters) of that location. Performing this with ::query() works as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant