I've spend the last couple of days getting to know the SQLite node and attempting to apply it to a use case I'm trying to solve. Sadly, it seems a possible bug is thwarting my efforts, please see:
Is there a way I can workaround this issue, I'm really keen to use the functionality of the prepared node (it's clean and allows me oversight of my query), perhaps it's even user error and not a bug!
I guess that the node is using toString() to convert it. What other tool are you using that does something different? Note that if you use a command line client for example then you are passing it a string, not a number.
I tried command line and some Mac SQLite applications to run the same query, never had the same issue, regardless, that's not proof there's an issue, merely an observation.
Further, it only happens with 'long' numbers, like the one in my example I posted to GitHub, I've not quite tracked down at what point it starts to add the '.0'
Note that storing it with a trailing .0 is not incorrect. It is a perfectly valid representation of the number. If you read it back out again and convert it to a number you will end up with the number you started with. Javascript does not have the concept of integers and floats, they are all just numbers.
Are you seeing that with .toString(). I don't. This in a function node displays the numbers as they are entered.
x = 11111;
node.warn(x.toString())
x = 11111111;
node.warn(x.toString())
x = 11111111111;
node.warn(x.toString())
x = 111111111111;
node.warn(x.toString())
x = 11111111111111;
node.warn(x.toString())
x = 1111111111111111;
node.warn(x.toString())
return msg;
Argh, only when used with the node, i.e. to build the msg.params...
To be clear, debug terminal never shows an issue, only the final value at the table is wrong.
I assume the issue occurs between the 'prepared' node receiving the msg.parms, and converting them, before it applies the query. Hence my assumption that it's an issue with the SQLite node somewhere (a pretty uneducated assumption, but it's all I have!).
So if you put a function node to convert it with toString() and then feed that into the node it doesn't put in the db the string generated by toString()?
To save me getting the whole flow can you just post the function please? I presume you have put a debug on the output of that to see what it is showing.
What is the reason, you are using a number for _id?
It will be much more safe if you generate unique string. Yes that may fail as random is random but this is rare and can be predicted.
Something like var id = "chat_"+Math.random().toString(36).substr(2, 6)+"."+Math.random().toString(36).substr(3, 7);