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

make op() accept a hash #4

wants to merge 9 commits into
base: master


None yet
1 participant

spechenin commented Feb 18, 2015

$sql = sql_obj('SQL', { a => b});
$sql->and('SQL', {c => d}); # it does not work
So I added some code to make it work.

I moved all sql_obj() code to _parse_args
sql_obj() and op() now use it.
SQL::Object::Interp can be simplified a lot just by overloading just one function _parse_args().

bind() now dereferences scalars.
sql_obj("SQL", $a, $b);
bind() returns actual values ($$a, $$b)

spechenin and others added some commits Feb 15, 2015

fix overloaded operators modify operands
Let us consider the statement
$C = $A op $B
op is one of '&', '|', '+'

The existing code results in
$A op $B; $C = $A
So "$A op $B" modifies $A and then assigns it to $C, $C==$A
Usually people do not expect such a behaviour

After this change
$C is a new object, $A and $B are not modified by "op".

@spechenin spechenin closed this Apr 5, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment