Open eashaw opened 3 years ago
@eashaw Thanks for posting! We'll take a look as soon as possible.
In the mean time, there are a few ways you can help speed things along:
Please remember: never post in a public forum if you believe you've found a genuine security vulnerability. Instead, disclose it responsibly.
For help with questions about Sails, click here.
I also noted some repeated records being returned when using stream
and fixed that with the sort
clause workaround.
Now I just realised that when checking for null
values in the query criteria some records are skipped, and the sort
clause does not seem to have any effect.
For example:
const criteria = { someField: null };
const userCount = await User.count(criteria);
let userStreamCount = 0;
await User.stream(criteria).sort('id').eachRecord( async (record)=>{
userStreamCount += 1;
});
In the above example, userCount
is greater than userStreamCount
. I've tested with a dataset of 159, the stream just returns 90 records. Also tested with and without a transaction in usingConnection
.
Hi @ochicf, I wasn't able to reproduce the results you were seeing. If you want to reproduce it in a github repo, I'd be happy to take a look.
Node version: 14.17.0 Sails version (sails): 1.4.4 ORM hook version (sails-hook-orm): ^3.0.2 Sockets hook version (sails-hook-sockets): ^2.0.0 Organics hook version (sails-hook-organics): ^2.0.0 Grunt hook version (sails-hook-grunt): 1.0.4 Uploads hook version (sails-hook-uploads): DB adapter & version (e.g. sails-mysql@5.55.5): sails-postgresql 2.0.0
When using
.stream()
with a model usingsails-postgresql
the second batch was not iterating through the models correctly.We are looking into this behavior. To ensure that
.stream()
is working correctly, you can specify an attribute to sort by in the.stream()
and the models will iterate in the correct order.