Real numbers get rounded.
See original GitHub issueWhen I try to insert a field with a real number, it gets rounded down in the table.
F.e.
let v = 8.5
sql.query`INSERT INTO Table (columnName) VALUES (${v})`
Then the new record gets a value of 8 instead of 8.5, while the type of columnName is set to real.
I think this is related to the decimal separator in MS SQL, as I’m currently working in a Dutch environment, and the decimal separator of the database is set to a comma instead of a period. So I guess the driver tries to do a conversion and ends up trunkating the result to the first period.
I also tried converting it to a string, and replacing the default JS period with a comma character, but then the query would not accept the value due to mismatch in types (nvarchar vs real).
Edit: it doesn’t happen when I include the value literally in the query. So it’s probably related to the escaping of the query instead.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:10

Top Related StackOverflow Question
You can override default type for each input parameter.
My issue was not specifying the precision and scale in the data type, without it, the library rounds the decimal apparently:
.input("pH", TYPES.Decimal(12, 2), spData.pH)