[DBIx-Class-Devel] [dbsrgits/dbix-class] Scalar::Defer support as column name (#98)

Peter Rabbitson notifications at github.com
Fri Apr 1 10:54:33 GMT 2016


I now understand what your problem is. It's not that the thing doesn't work, but that you get defer() called too many times.

For starters the proposed fix is a no-go: the codebase in general [goes to great lengths](https://github.com/dbsrgits/dbix-class/search?q="length+ref+"&type=Code) to not treat `bless into false` in a special way. In fact any **naked** ref in boolean context is a mistake, not the other way around. But there is another reason this can not be applied:

The more fundamental problem is that `SQL::Abstract` fundamentally does not support your desired use-case (which you already ran into here `...I also tried to re-bless it into different package, not "0", but it only fails in different place...`):
```
~$ perl -MSQL::Abstract -MScalar::Defer -MData::Dumper -e '
  my $x = my $y = 0;
  print Dumper [ map { "$_" }
    SQL::Abstract->new->where([
      defer { ++$x }, defer { ++$y }
    ]) ]
'

$VAR1 = [
          ' WHERE ( 2 = ? )',
          '2'
        ];
```

While it is possible to get things to work in the long run (with a ton of work), a small one-off patch like what is proposed in this PR is certainly off the table.

Could you describe the actual problem you are trying to solve? Perhaps there is a better way forward without using (the clearly not working OOB) `Scalar::Defer` at all.

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/dbsrgits/dbix-class/pull/98#issuecomment-204347775
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.scsys.co.uk/pipermail/dbix-class-devel/attachments/20160401/447cb0c2/attachment-0001.htm>


More information about the DBIx-Class-Devel mailing list