Closed tbranyen closed 12 years ago
I'm also super confused about the test
functions for each type. I see the following (specifically string here):
test: function(v) {
return (v === null || typeof v === "undefined" || typeof v === 'string');
}
When you test v === null || ...
if the value is null
it's going to return true
for that type. Is this expected behavior?
Interesting problem guys. So a few thoughts:
Promoted ticket #105.
I'm wondering if there is another way of determining null checks without doing it inside the actual type check. Basically doing the null check outside of the test function where its necessary (for maintaining null column values).
I think the issue is more than "why would you want to", versus what could easily happen based off input coming from a third-party location. What happens if you get a tweet text where the only value is "true" or "555555" this shouldn't break the column type String.
There is a lot of confusion surrounding Miso.Types. For instance:
"1"
is a Number and not a String. If the intention here is to allow Numbers and Booleans also be Strings, that's not going to work as expected. For instance the following code was brought up by pmjs1 in #misoproject:The error message that is reported:
is triggered, because
"1"
is recognized as a number in yourMiso.typeOf
check, which resides inside theupdate
function.My patch to him was to change the
test
function for number to:I humbly suggest changing both
boolean
andnumber
types to respect their native JavaScript types. This will prevent the above kind of issues where it's impossible to insert a String value if it can be regex tested to a Number.