seomoz / qless-core

Core Lua Scripts for qless
MIT License
85 stars 33 forks source link

Sort 'dependents' and 'dependencies' before comparing them to fix a f… #91

Closed tom93 closed 2 months ago

tom93 commented 2 years ago

…ailing test on Redis 6.2.7

Redis sets are unordered. In Redis 4.0 the Lua API silently sorted sets before returning them, but since Redis 5.0 the sorting is no longer performed.[1]

One of the tests broke on Redis 6.2.7 because the order changed. Sort the lists before comparing them to fix this.

(It's only strictly necessary to sort when there are 2+ elements, but for consistency this commit also sorts when there is just 1 element. Empty sets are special because an empty Lua table is converted to a Python dict rather than a list; this commit does not sort empty sets to avoid masking this idiosyncrasy.)

[1]: https://redis.io/docs/manual/programmability/eval-intro/

tom93 commented 2 months ago

Thanks!