<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p>I am able to reproduce this behavior in the development version
      of qgis.</p>
    <p>As a consequence, I opened two issues:</p>
    <p>"Python call to --processing.run('qgis:fieldcalculator'-- fails
      to catch divide by zero"<br>
    </p>
    <p>(<a class="moz-txt-link-freetext" href="https://github.com/qgis/QGIS/issues/37737">https://github.com/qgis/QGIS/issues/37737</a>)</p>
    <p>"nonsense code causes infinite regress in error reports"<br>
    </p>
    <p>(<a class="moz-txt-link-freetext" href="https://github.com/qgis/QGIS/issues/37739">https://github.com/qgis/QGIS/issues/37739</a>).  Both have since
      been tagged as "Bug + Processing + Modeller".</p>
    <p>I learned along the way from a comment in the qgis core source
      code that the syntax of the language for the FORMULA argument,
      which I think is called "Processing", is SQL or SQL-ish by design.<br>
    </p>
    <p>- JP</p>
    <div class="moz-cite-prefix">On 6/17/20 4:00 PM, James Powell wrote:<br>
    </div>
    <blockquote type="cite"
      cite="mid:98aaa172-edb8-bb6e-94df-fd6b6a6cfc6a@pdx.edu">
      <meta http-equiv="content-type" content="text/html; charset=UTF-8">
      <p>Hi there everybody,<br>
        <br>
        I want to derive some floating point values using an expression
        in the<br>
        field calculator (see model snapshot below).  I'm using qgis
        3.10.6 on<br>
        Debian 10.<br>
        <br>
        I am finding that the first field calculator call, which
        produces 'dbgfieldcalc',<br>
        gives only NULL answers.<br>
        <br>
        The second field calculator call (at the bottom, which produces
        'dbgfishnetFinal')<br>
        does almost the same thing and it works great.<br>
        <br>
        At no time will running this model produce errors.  In fact,
        even<br>
        changing attribute names to be invalid attribute names doesn't
        produce<br>
        an error at all.<br>
        <br>
        What I expect:<br>
        - That the field calculator is able to consistently run simple
        expressions through.<br>
        - That feeding invalid attribute names causes an error report
        and aborts the model run.<br>
        <br>
        I've read through the docs that show up for a search on
        "qgis-user field calculator".<br>
        <br>
        The python code produced for this model reads<br>
        :  # Field
calculator                                                                                                                                                                                      
        <br>
        :         alg_params =
{                                                                                                                                                                                   
        <br>
        :             'FIELD_LENGTH':
10,                                                                                                                                                                          
        <br>
        :             'FIELD_NAME':
'emissionsAfterFishnetInGramPerHour',                                                                                                                                          
        <br>
        :             'FIELD_PRECISION':
3,                                                                                                                                                                        
        <br>
        :             'FIELD_TYPE':
0,                                                                                                                                                                             
        <br>
        :             'FORMULA': 'attribute($currentfeature,
        \'emissionsingramsperhour\') * attribute($currentfeature,
        \'xlength_2\') / attribute($currentfeature,
        \'length\')',                                    <br>
        :             'INPUT':
outputs['AddGeometryAttributes']['OUTPUT'],                                                                                                                                         
        <br>
        :             'NEW_FIELD':
True,                                                                                                                                                                           
        <br>
        :             'OUTPUT':
parameters['Dbgfieldcalc']                                                                                                                                                         
        <br>
        :        
}                                                                                                                                                                                                
        <br>
        :         outputs['FieldCalculator'] =
        processing.run('qgis:fieldcalculator', alg_params,
        context=context, feedback=feedback,
is_child_algorithm=True)                                                     
        <br>
        :         results['Dbgfieldcalc'] =
outputs['FieldCalculator']['OUTPUT']                                                                                                                                   
        <br>
        where "xlength_2" is a nonexistent attribute (but the script has
        the same behavior when I use<br>
        "length_2", which is an existent attribute).<br>
        <br>
        Is it usual to not detect errors like this?  Is there some
        reason the expression I<br>
        wrote (with the proper attribute name) wouldn't give a floating
        point number, but produces NULL instead?<br>
        <br>
        many thanks,<br>
          James P.</p>
      <p><br>
      </p>
      <p>snapshot:</p>
      <p><img src="cid:part1.90761F48.601D8B95@pdx.edu" alt="" class=""></p>
      <pre class="moz-signature" cols="72">-- 
James E. Powell, MS
Pronouns: he/him/his
Applied Physics PhD Candidate
Department of Physics
Portland State University
Home page: <a class="moz-txt-link-freetext" href="http://web.pdx.edu/~powellj" moz-do-not-send="true">http://web.pdx.edu/~powellj</a>
Office: SRTC 409B Phone: +1-503-725-8515
</pre>
    </blockquote>
    <pre class="moz-signature" cols="72">-- 
James E. Powell, MS
Pronouns: he/him/his
Applied Physics PhD Candidate
Department of Physics
Portland State University
Home page: <a class="moz-txt-link-freetext" href="http://web.pdx.edu/~powellj">http://web.pdx.edu/~powellj</a>
Office: SRTC 409B Phone: +1-503-725-8515
</pre>
  </body>
</html>