mojolicious / mojo-pg

Mojolicious :heart: PostgreSQL
https://metacpan.org/release/Mojo-Pg
Artistic License 2.0
101 stars 46 forks source link

Stop SQL::Abstract::Pg mutating inputs #56

Closed mohawk2 closed 5 years ago

mohawk2 commented 5 years ago

Summary

Stop SQL::Abstract::Pg->select mutating its inputs on non-inner joins, by copying the input and shifting that. The current code shifts its inputs for non-inner join, removing the join-type modifier, which creates a fiendishly hard to track bug. Basically, this doesn't work:

my $sources = ['foo', [-left => 'bar', foo_id => 'id']];
is_deeply [ $sqlapg->select($sources) ], [ $sqlapg->select($sources) ];

Motivation

Subtly mutating function inputs leads to hard-to-track bugs

References

Sorry, none. Hopefully this summary plus the test modification (which now fails without the module change) makes clear the problem.

kraih commented 5 years ago

Thanks, resolved more efficiently.

mohawk2 commented 5 years ago

And with no test to avoid regressions?