couchbaselabs / gojsonsm

Go implementation of my JSONSM algorithm.
9 stars 7 forks source link

Fixes #116: #117

Closed nelio2k closed 5 years ago

nelio2k commented 5 years ago
nelio2k commented 5 years ago

The example is given the comparison int > equals10000 where equals10000 is missing.

Without the valid comparison, what happens is that equals10000 becomes 0 and the statement becomes true if int is >0. The same statement becomes false if int < 0. So the behavior is a bit odd.

Then there's also addressing the original issue of https://github.com/couchbaselabs/gojsonsm/issues/84 which is pretty much almost the same thing.

brett19 commented 5 years ago

Hey @nelio2k, Based on your description of the issue, it sounds like there is actually a more fundamental failure occurring here, maybe two. It sounds like equals10000 is being parsed as an identifier referring to the document content, then you end up with a query that is SOMETHING >$doc.\equals1000`. So that would mean that for one, this is being incorrectly executed when it should not be, since you would expect a document to contain a field called equals1000. Secondly, it seems like there needs to be some sort of NaN or Nil value handling such that the comparisons make sense when the values cannot be parsed as expected, there are a lot of well-written rules out there on how to handle these cases once they are separated out.

After writing that, I think the problem is the use of variables and the fact that those comparisons get placed into an :AFTER block since they have variables on the left and right side. It's possible that variables need to be checked for values before they are used.

nelio2k commented 5 years ago

@brett19 You were right in your assessment. I've re-addressed this and addressed some other things along the way. Please take a look. Thanks.