-
Notifications
You must be signed in to change notification settings - Fork 443
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
Azure MS SQL gets completely different decimals #1012
Comments
So if you check the value via a different tool in the database, the value that was written is incorrect? I'll try to write a test case for this. |
Well I use my nodeJs sequelize server to write the value and I also see the query, where the value is correct. Then, using DBeaver, I see the incorrect value in the DB. |
@arthurschreiber fyi I updated to tedious v6.6.1 after fixing the problem described in #1008 . Didn't make a difference for this issue though |
Does anyone have an indication why this might happen and/or what a workaround could look like? |
@obermobber I'll take a look as soon as I can. |
Okay, thanks @arthurschreiber ! It's just really driving me crazy haha |
@obermobber I tried reproducing this, but I'm failing to do so. I added new test cases to the decimal tests in Can you distill the issue you're seeing into a simple test case? 🙇 |
@arthurschreiber shame on me, but I've never written a single test in my short developer life (it's bad, i know..). But I'd be more than happy to provide all the information necessary :( |
It doesn't have to be a test case written in the framework we use for for testing tedious. I just need the minimum amount of code that would allow me to reproduce this issue. 😄 |
So, I hope I got that right. All I'm executing is this:
I am sending this body:
this is what's logged:
and this is what's written in the DB:
so 465324.75 turns into 4156.148157261 I use routing controllers 0.7.7 for the requests, if that's important to know. +++EDIT+++Thought you might need the table definition:
|
It looks like you're using sequelize on top of tedious. This often makes issues harder to track down, because there's more moving parts where things could be going wrong. 😞 How is |
Ah, you just posted the definition. I'll see what I can do. |
Here is an example I just whipped up: const { Connection, Request, TYPES: { Decimal } } = require('tedious');
const connection = new Connection({
// ...
});
connection.on('connect', () => {
const request = new Request('CREATE TABLE #decimals (value decimal(18, 9))', (err) => {
if (err) {
throw err;
}
const request = new Request('INSERT INTO #decimals (value) VALUES (@value)', (err) => {
if (err) {
throw err;
}
const request = new Request('SELECT * FROM #decimals', (err) => {
if (err) {
throw err;
}
connection.close();
});
request.on('row', (columns) => {
console.log(columns);
});
connection.execSql(request);
});
request.addParameter('value', Decimal, 18728.4, { precision: 18, scale: 9 });
connection.execSql(request);
});
connection.execSqlBatch(request);
}); and this is the output I get back:
I really don't think this is an issue with Which version of |
hmm... I'll try that, thanks! Currently stuck on But while I try to fix that, here is a snapshot of my package-lock (tedious is not listed in the dependencies of sequelize, this is the only occurrence of tedious in my package-lock):
|
Oh, if you change the code to this: const { Connection, Request, TYPES: { Decimal } } = require('tedious');
const connection = new Connection({
// ...
});
connection.on('connect', (err) => {
if (err) {
throw err;
}
const request = new Request('CREATE TABLE #decimals (value decimal(18, 9))', (err) => {
if (err) {
throw err;
}
const request = new Request('INSERT INTO #decimals (value) VALUES (@value)', (err) => {
if (err) {
throw err;
}
const request = new Request('SELECT * FROM #decimals', (err) => {
if (err) {
throw err;
}
connection.close();
});
request.on('row', (columns) => {
console.log(columns);
});
connection.execSql(request);
});
request.addParameter('value', Decimal, 18728.4, { precision: 18, scale: 9 });
connection.execSql(request);
});
connection.execSqlBatch(request);
}); You should see a better error message if connecting fails. |
That actually helped a lot, I didn't have the The following should be correct right?
I used the same credentials with DBeaver and din't have any problems, but I always get Sorry for all the trouble! |
That should be right! Is the user you're connecting with a SQLServer user or a Azure Active Directory account user? (There can be both/either on Azure databases). Try using |
This brought me a step closer. Now I get Regarding this issue, everything seems pointing towards an error somewhere else than tedious, so we could close this on my part and I'd probably raise an issue with sequelize. I really really appreciate the time you took @arthurschreiber !! |
Hm. I'm still wondering why you can connect using sequelize, but not using Feel free to close this issue and reopen it once you can confirm the problem is coming from |
I wouldn't say no to solving this mystery with you haha! But I didn't want to take any more of your time 😃 |
Hello together,
I had a Range Error Issue which forced me to update tedious to version 6.5.0 (I tried to update to 6.6.1 but that didn't work out, please see issue #1008 )
Now, when I try to save a high decimal value, it turns into a different, much smaller number.
It's suspicious how often they end with
5926290
.When the execution is posted to the console, I actually see the correct value. So it changes on the way after the query and into the db.
POSTing 12304.53 actually works and will be written into the DB just like that.
I use it in combination with
sequelize 5.15.1
typescript: 3.3.4000
Node: 10.15.3
an Azure MS SQL database
and the field is defined as
This is also what the ms sql database says itself about that field.
Let me know if you need additional information
The text was updated successfully, but these errors were encountered: