<p>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.</p>

<p>For starters the proposed fix is a no-go: the codebase in general <a href="https://github.com/dbsrgits/dbix-class/search?q=%22length+ref+%22&amp;type=Code">goes to great lengths</a> to not treat <code>bless into false</code> in a special way. In fact any <strong>naked</strong> ref in boolean context is a mistake, not the other way around. But there is another reason this can not be applied:</p>

<p>The more fundamental problem is that <code>SQL::Abstract</code> fundamentally does not support your desired use-case (which you already ran into here <code>...I also tried to re-bless it into different package, not "0", but it only fails in different place...</code>):</p>

<pre><code>~$ perl -MSQL::Abstract -MScalar::Defer -MData::Dumper -e '
  my $x = my $y = 0;
  print Dumper [ map { "$_" }
    SQL::Abstract-&gt;new-&gt;where([
      defer { ++$x }, defer { ++$y }
    ]) ]
'

$VAR1 = [
          ' WHERE ( 2 = ? )',
          '2'
        ];
</code></pre>

<p>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.</p>

<p>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) <code>Scalar::Defer</code> at all.</p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">&mdash;<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly or <a href="https://github.com/dbsrgits/dbix-class/pull/98#issuecomment-204347775">view it on GitHub</a><img alt="" height="1" src="https://github.com/notifications/beacon/AASeAkv_ZpQA2TfgkaT9QWbiqId4cNntks5pzPlpgaJpZM4H7fjh.gif" width="1" /></p>
<div itemscope itemtype="http://schema.org/EmailMessage">
<div itemprop="action" itemscope itemtype="http://schema.org/ViewAction">
  <link itemprop="url" href="https://github.com/dbsrgits/dbix-class/pull/98#issuecomment-204347775"></link>
  <meta itemprop="name" content="View Pull Request"></meta>
</div>
<meta itemprop="description" content="View this Pull Request on GitHub"></meta>
</div>