Add missing PostgreSQL operators and fix >^ geometric operator#938
Conversation
Adds support for several PostgreSQL operators from core and popular extensions that were previously being split into shorter tokens: - <@> (earthdistance distance) - &&& (PostGIS 3D bounding box overlap) - |=| (PostGIS closest point of approach distance) - ~> (cube coordinate extraction) - #= (hstore replace fields) Also fixes the geometric "is above" operator which was incorrectly defined as ^> instead of >^ per the PostgreSQL docs.
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. |
|
Well, thanks, I appreciate the fixes. I however do not appreciate the LLM-written pull request description. Really, my first reaction was to just reject this whole pull request because it has LLM written all over it and why should I bother reading and understanding all that LLM written text and code if you didn't bother to give any sort of human touch to it. Please don't do this in the future. It's really just not nice towards open source maintainers. |
| ); | ||
| }); | ||
|
|
||
| // Tests for PostgreSQL containment and full-text search operators |
There was a problem hiding this comment.
All these additional "operator tests in context" here are unnecessary. It's just noise, with no real value.
| '&&&', | ||
| '&<', | ||
| '&>', | ||
| '<<|', | ||
| '&<|', | ||
| '|>>', | ||
| '|&>', | ||
| '<^', | ||
| '^>', | ||
| '>^', | ||
| '?#', | ||
| '?-', | ||
| '?|', | ||
| '?-|', | ||
| '?||', | ||
| '@>', | ||
| '<@', | ||
| '<@>', | ||
| '~=', | ||
| // PostGIS | ||
| '|=|', |
There was a problem hiding this comment.
In the PR summary the &&& operator and |=| are listed as PostGIS operators, but in the actual code only the latter is placed to PostGIS group. Some consistency would be nice.
| }); | ||
| }); | ||
|
|
||
| // Tests for extension operators (hstore, cube, ltree) |
There was a problem hiding this comment.
From where does the ltree come into play?
| }); | ||
|
|
||
| // https://www.postgresql.org/docs/current/functions-geometry.html | ||
| // Note: the formatter defines ^> but PostgreSQL docs say the operator is >^ |
There was a problem hiding this comment.
Well, it defined ^> in the past, but now after this PR it's corrected. So the comment doesn't really make sense any more.
Summary
<@>(earthdistance),&&&(PostGIS 3D overlap),|=|(PostGIS trajectory distance),~>(cube),#=(hstore)^>instead of>^per PostgreSQL docsDetail
The formatter's tokenizer was greedily matching shorter known operators instead of the full operator. For example
<@>was being split into<@+>, producingbar <@ > point(1, 2)instead ofbar <@> point(1, 2).The fix is simply adding these operators to the PostgreSQL dialect's operator list. The existing regex builder in
regexFactory.tsalready sorts operators by length descending, so longer operators automatically take priority.Operators added
<@>&&&|=|~>#=>^(fix)Test plan
supportsOperators()for basic spacing and dense mode