dmfay / massive-js

A data mapper for Node.js and PostgreSQL.
2.49k stars 158 forks source link

Decompose should preserve ordering of query results #531

Closed nireno closed 6 years ago

nireno commented 6 years ago

Fixes issue #530

dmfay commented 6 years ago

And here I was trying to think of how to preserve ordering and coming up blank. That's creative!

I think the build failure is a fluke -- one setup hook had issues. I've seen it happen once or twice before but haven't figured out exactly what's going on. I'll rerun it just to make sure.

dmfay commented 6 years ago

I'm a little perplexed by the shifting of tests (looks like that caught you by surprise too), but I suppose the ordering of internal arrays was never guaranteed in the first place. Merged, thanks for contributing!

nireno commented 6 years ago

Looks like postgres lists rows with null columns last when it left joins so the actual query produces:

user_id username test_id name id description
3 "carol" 2 "carol's first test" 2 "carol's issue"
3 "carol" 3 "carol's second test"

but the decompose was reordering it.