Answers.Body: <p>This is a bug.  It only happens when you have modified the name of the pledge status "Completed" or "Cancelled".  In your case, "Completed" has been modified.</p>
  
  <p>While you could change that label back, the report shouldn't crash regardless.  It was easy to fix, so I <a href="https://github.com/civicrm/civicrm-core/pull/15543" rel="nofollow noreferrer">reported the issue</a> then <a href="https://lab.civicrm.org/dev/report/issues/22" rel="nofollow noreferrer">made the fix</a>.</p>
  
  <p>You literally need to change one word in one file, so if you feel comfortable changing the contents of a file in your CiviCRM directory, you can look at the fix I made and make the change on your site.  If you do, please report back on Github that it works - that will speed up the process of getting this fixed merged into CiviCRM for everyone.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-10-19T07:17:26.300Z
Answers.Text: We do not feel confident about changing the code. Meanwhile we restored "Completed" instead of "Completato" (translate by I10n)  in "pledge_status" options and everything works. Thank you and we hope that the bug resolution request will be implemented.
Answers.UserDisplayName: Alessandro Letizia
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-10-19T17:51:53.237Z
Answers.Text: @AlessandroLetizia The fix has been accepted, it will be in CiviCRM 5.20 and above.
Answers.UserDisplayName: Jon G - Megaphone Tech
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-10-18T19:40:51.573Z
Answers.LastActivityDate: 2019-10-18T19:40:51.573Z
Answers.UserDisplayName: Jon G - Megaphone Tech
Body: <p>CiviCRM ver. 5.18.2 (or 5.14.2) on Wordpress.</p>
  
  <p>Hi all.</p>
  
  <p>When <strong>Balance Due</strong> is selected in <strong>Pledge Report > Details</strong> we get a <strong>syntax error</strong>. Here is the error log:</p>
  
  <pre><code> [error] $Fatal Error Details = Array
  (
  [callback] =&gt; Array
      (
          [0] =&gt; CRM_Core_Error
          [1] =&gt; handle
      )
  [code] =&gt; -2
  [message] =&gt; DB Error: syntax error
  [mode] =&gt; 16
  [debug_info] =&gt; SELECT SQL_CALC_FOUND_ROWS contact_civireport.sort_name as civicrm_contact_sort_name, pledge_civireport.id as civicrm_pledge_id, pledge_civireport.contact_id as civicrm_pledge_contact_id, pledge_civireport.amount as civicrm_pledge_amount, pledge_civireport.currency as civicrm_pledge_currency, pledge_civireport.status_id as civicrm_pledge_status_id, COALESCE(sum(pledge_payment_civireport.actual_amount), 0) as civicrm_pledge_payment_total_paid, IF(pledge_civireport.status_id IN(3, ), 0, COALESCE(pledge_civireport.amount, 0) - COALESCE(sum(pledge_payment_civireport.actual_amount),0)) as civicrm_pledge_payment_balance_due, (address_civireport.street_number % 2) as civicrm_address_address_odd_street_number  
          FROM civicrm_pledge pledge_civireport
               LEFT JOIN civicrm_contact contact_civireport
                    ON (contact_civireport.id =
                        pledge_civireport.contact_id )
  
      LEFT JOIN civicrm_pledge_payment pledge_payment_civireport ON
        pledge_civireport.id = pledge_payment_civireport.pledge_id
        AND pledge_payment_civireport.status_id = 1
  
               LEFT JOIN civicrm_address address_civireport
                         ON (contact_civireport.id =
                             address_civireport.contact_id)  AND
                             address_civireport.is_primary = 1
  WHERE (pledge_civireport.is_test=0 )   GROUP BY pledge_civireport.id, pledge_civireport.currency  ORDER BY contact_civireport.sort_name, contact_civireport.id  LIMIT 0, 50 [nativecode=1064 ** You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '), 0, COALESCE(pledge_civireport.amount, 0) - COALESCE(sum(pledge_payment_civire' at line 1]
  [type] =&gt; DB_Error
  [user_info] =&gt; SELECT SQL_CALC_FOUND_ROWS contact_civireport.sort_name as civicrm_contact_sort_name, pledge_civireport.id as civicrm_pledge_id, pledge_civireport.contact_id as civicrm_pledge_contact_id, pledge_civireport.amount as civicrm_pledge_amount, pledge_civireport.currency as civicrm_pledge_currency, pledge_civireport.status_id as civicrm_pledge_status_id, COALESCE(sum(pledge_payment_civireport.actual_amount), 0) as civicrm_pledge_payment_total_paid, IF(pledge_civireport.status_id IN(3, ), 0, COALESCE(pledge_civireport.amount, 0) - COALESCE(sum(pledge_payment_civireport.actual_amount),0)) as civicrm_pledge_payment_balance_due, (address_civireport.street_number % 2) as civicrm_address_address_odd_street_number  
          FROM civicrm_pledge pledge_civireport
               LEFT JOIN civicrm_contact contact_civireport
                    ON (contact_civireport.id =
                        pledge_civireport.contact_id )
  
      LEFT JOIN civicrm_pledge_payment pledge_payment_civireport ON
        pledge_civireport.id = pledge_payment_civireport.pledge_id
        AND pledge_payment_civireport.status_id = 1
  
               LEFT JOIN civicrm_address address_civireport
                         ON (contact_civireport.id =
                             address_civireport.contact_id)  AND
                             address_civireport.is_primary = 1
  WHERE (pledge_civireport.is_test=0 )   GROUP BY pledge_civireport.id, pledge_civireport.currency  ORDER BY contact_civireport.sort_name, contact_civireport.id  LIMIT 0, 50 [nativecode=1064 ** You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '), 0, COALESCE(pledge_civireport.amount, 0) - COALESCE(sum(pledge_payment_civire' at line 1]"]
  </code></pre>
  
  <p>Is this a bug? or is it the result of errors in setting the fields?</p>
  
  <p>Thx&amp;Bye.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-10-18T13:32:52.933Z
Comments.Text: You posted the backtrace, but not the error itself.  Could you please post the error?  And per Stack Exchange guidelines, could you please edit your question to post the backtrace here instead of on Pastebin?  Otherwise it's harder for others to find this question if they have the same problem.  Thanks!
Comments.UserDisplayName: Jon G - Megaphone Tech
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-10-18T18:16:19.190Z
Comments.Text: @JonG-MegaphoneTech - Thanks for your directions, I changed everything.
Comments.UserDisplayName: Alessandro Letizia
Tags: <reports><pledges>
Title: SYNTAX ERROR in Pledge Report when Balance Due is selected (ver. 5.18.2)
ThreadText: # SYNTAX ERROR in Pledge Report when Balance Due is selected (ver. 5.18.2)
  
  (Asked by: username_0 on 2019-10-18)
  
  CiviCRM ver. 5.18.2 (or 5.14.2) on Wordpress.
  
  Hi all.
  
  When **Balance Due** is selected in **Pledge Report > Details** we get a **syntax error**. Here is the error log:
  
  ```
   [error] $Fatal Error Details = Array
  (
  [callback] => Array
      (
          [0] => CRM_Core_Error
          [1] => handle
      )
  [code] => -2
  [message] => DB Error: syntax error
  [mode] => 16
  [debug_info] => SELECT SQL_CALC_FOUND_ROWS contact_civireport.sort_name as civicrm_contact_sort_name, pledge_civireport.id as civicrm_pledge_id, pledge_civireport.contact_id as civicrm_pledge_contact_id, pledge_civireport.amount as civicrm_pledge_amount, pledge_civireport.currency as civicrm_pledge_currency, pledge_civireport.status_id as civicrm_pledge_status_id, COALESCE(sum(pledge_payment_civireport.actual_amount), 0) as civicrm_pledge_payment_total_paid, IF(pledge_civireport.status_id IN(3, ), 0, COALESCE(pledge_civireport.amount, 0) - COALESCE(sum(pledge_payment_civireport.actual_amount),0)) as civicrm_pledge_payment_balance_due, (address_civireport.street_number % 2) as civicrm_address_address_odd_street_number  
          FROM civicrm_pledge pledge_civireport
               LEFT JOIN civicrm_contact contact_civireport
                    ON (contact_civireport.id =
                        pledge_civireport.contact_id )
  
      LEFT JOIN civicrm_pledge_payment pledge_payment_civireport ON
        pledge_civireport.id = pledge_payment_civireport.pledge_id
        AND pledge_payment_civireport.status_id = 1
  
               LEFT JOIN civicrm_address address_civireport
                         ON (contact_civireport.id =
                             address_civireport.contact_id)  AND
                             address_civireport.is_primary = 1
  WHERE (pledge_civireport.is_test=0 )   GROUP BY pledge_civireport.id, pledge_civireport.currency  ORDER BY contact_civireport.sort_name, contact_civireport.id  LIMIT 0, 50 [nativecode=1064 ** You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '), 0, COALESCE(pledge_civireport.amount, 0) - COALESCE(sum(pledge_payment_civire' at line 1]
  [type] => DB_Error
  [user_info] => SELECT SQL_CALC_FOUND_ROWS contact_civireport.sort_name as civicrm_contact_sort_name, pledge_civireport.id as civicrm_pledge_id, pledge_civireport.contact_id as civicrm_pledge_contact_id, pledge_civireport.amount as civicrm_pledge_amount, pledge_civireport.currency as civicrm_pledge_currency, pledge_civireport.status_id as civicrm_pledge_status_id, COALESCE(sum(pledge_payment_civireport.actual_amount), 0) as civicrm_pledge_payment_total_paid, IF(pledge_civireport.status_id IN(3, ), 0, COALESCE(pledge_civireport.amount, 0) - COALESCE(sum(pledge_payment_civireport.actual_amount),0)) as civicrm_pledge_payment_balance_due, (address_civireport.street_number % 2) as civicrm_address_address_odd_street_number  
          FROM civicrm_pledge pledge_civireport
               LEFT JOIN civicrm_contact contact_civireport
                    ON (contact_civireport.id =
                        pledge_civireport.contact_id )
  
      LEFT JOIN civicrm_pledge_payment pledge_payment_civireport ON
        pledge_civireport.id = pledge_payment_civireport.pledge_id
        AND pledge_payment_civireport.status_id = 1
  
               LEFT JOIN civicrm_address address_civireport
                         ON (contact_civireport.id =
                             address_civireport.contact_id)  AND
                             address_civireport.is_primary = 1
  WHERE (pledge_civireport.is_test=0 )   GROUP BY pledge_civireport.id, pledge_civireport.currency  ORDER BY contact_civireport.sort_name, contact_civireport.id  LIMIT 0, 50 [nativecode=1064 ** You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '), 0, COALESCE(pledge_civireport.amount, 0) - COALESCE(sum(pledge_payment_civire' at line 1]"]
  
  ```
  
  Is this a bug? or is it the result of errors in setting the fields?
  
  Thx&Bye.
  
  **Tags:** reports, pledges
  
  > **Comments:**
  > **username_1**: You posted the backtrace, but not the error itself.  Could you please post the error?  And per Stack Exchange guidelines, could you please edit your question to post the backtrace here instead of on Pastebin?  Otherwise it's harder for others to find this question if they have the same problem.  Thanks!  
  > **username_0**: @username_1 - Thanks for your directions, I changed everything.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2019-10-18. Score: 2 | Accepted answer
  
  This is a bug. It only happens when you have modified the name of the pledge status "Completed" or "Cancelled". In your case, "Completed" has been modified.
  
  While you could change that label back, the report shouldn't crash regardless. It was easy to fix, so I [reported the issue](https://github.com/civicrm/civicrm-core/pull/15543) then [made the fix](https://lab.civicrm.org/dev/report/issues/22).
  
  You literally need to change one word in one file, so if you feel comfortable changing the contents of a file in your CiviCRM directory, you can look at the fix I made and make the change on your site. If you do, please report back on Github that it works - that will speed up the process of getting this fixed merged into CiviCRM for everyone.
  
  > **Comments:**
  > **username_0**: We do not feel confident about changing the code. Meanwhile we restored "Completed" instead of "Completato" (translate by I10n)  in "pledge_status" options and everything works. Thank you and we hope that the bug resolution request will be implemented.  
  > **username_1**: @username_0 The fix has been accepted, it will be in CiviCRM 5.20 and above.  
  
  ---
  
  