-
Notifications
You must be signed in to change notification settings - Fork 109
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
record.set() fails to set some keys #327
Comments
I guess it's meant to do parseInt() for things that are base-10-numbers. Unfortunately javascript accepts things as !isNaN than decimal numbers.
I guess the solution could either be to remove the "10" part from parseInt, or to just remove this whole thing altogether. I can't find any indication in the tests or the code why this tokenization exists. |
So maybe we could replace |
What is the reason behind this parseInt-conversion in the first place? I suspect some kind of optimization of key sizes. Would it be a terrible solution to remove it altogether? :) Alternatively, a way to opt-out of the optimization and store the keys as-is. |
I tried how the code works when changing parseInt(part, 10) to parseInt(part):
I would say that's rather counter-intuitive, and causes a change between how .get()/.set() and .get(path)/.set(path) works. I suggest removing the parseInt thing altogether for now |
To clarify, are you taking about:
Not sure if there is a specific reason we turn it into a number, other than because its an array index. This seems like a legit fix, can't see when anyone would use something that isn't a number to point to an element in an array. |
Just saw PR, thanks! |
Ping! Can we get this merged? :) |
Closing since this has been merged on Feb 16 |
Hello!
We ran into an issue recently when building a record. We wanted to have a record containing a bunch of mac addresses. We wanted to use the mac addresses as keys. But we ran into this problem:
The expected result is that both methods produce the same output (like the latter method). I.e. it shouldn't turn a valid key string into a string containing just a zero.
The problem seems to be in the "tokenize" method in json-path.js:
For some reason it's running "parseInt(part, 10)" on the key, which will turn it into 0.
We're running "deepstream.io-client-js": "^2.1.1"
The text was updated successfully, but these errors were encountered: