Answers.Body: <p>After a lot of digging, I realised what was happening. For some reason, there was a second <code>civicrm_saved_search</code> table in the database named <code>civicrm_saved_search-b</code> .</p>
  
  <p>That hyphen <code>-</code> is an 'illegal' character unless you escape it. </p>
  
  <p>To resolve the issue, all I did was change the <code>-</code> to a <code>_</code> which cleared everything up and enabled me to upgrade my site within minutes.</p>
  
  <p>Hopefully, this will help someone else one day who has a similar issue!</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-06-07T17:09:21.580Z
Answers.Text: That does bring up an interesting point though - maybe this function should escape the trigger names? https://github.com/civicrm/civicrm-core/blob/5.14/CRM/Logging/Schema.php#L250
Answers.UserDisplayName: Demerit
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-06-07T17:19:04.040Z
Answers.Text: I was thinking that myself,  decided against changing the core files. I'm not sure whether this would be an issue or just an isolated incident...
Answers.UserDisplayName: Jade
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-06-07T16:27:51.560Z
Answers.LastActivityDate: 2019-06-07T16:27:51.560Z
Answers.UserDisplayName: Jade
Body: <p>I  have a website that is on Drupal 7 and I am attempting to upgrade the version of Civi from 5.10 to 5.13 but when I attempt to upgrade it, I'm receiving the following error: </p>
  
  <pre><code>Database Error Code: 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 '-b_before_insert' at line 1, 1064
  </code></pre>
  
  <p>I have tried doing the upgrade through drush and also through the /civicrm/upgrade URL with the same error.</p>
  
  <p>It's a bit of a long shot but I was hoping that someone has seen the error before and knows of a fix or how I can determine exactly what is going on.</p>
  
  <p>Taking a look at the debugging information, I can see it has something to do with triggers:</p>
  
  <pre><code>DROP TRIGGER IF EXISTS civicrm_saved_search-b_before_insert [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 '-b_before_insert' at line 1]
  </code></pre>
  
Tags: <drupal><upgrade><error><database><trigger>
Title: Database Syntax Error when attempting upgrade
ThreadText: # Database Syntax Error when attempting upgrade
  
  (Asked by: username_0 on 2019-06-07)
  
  I have a website that is on Drupal 7 and I am attempting to upgrade the version of Civi from 5.10 to 5.13 but when I attempt to upgrade it, I'm receiving the following error:
  
  ```
  Database Error Code: 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 '-b_before_insert' at line 1, 1064
  
  ```
  
  I have tried doing the upgrade through drush and also through the /civicrm/upgrade URL with the same error.
  
  It's a bit of a long shot but I was hoping that someone has seen the error before and knows of a fix or how I can determine exactly what is going on.
  
  Taking a look at the debugging information, I can see it has something to do with triggers:
  
  ```
  DROP TRIGGER IF EXISTS civicrm_saved_search-b_before_insert [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 '-b_before_insert' at line 1]
  
  ```
  
  **Tags:** drupal, upgrade, error, database, trigger
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2019-06-07. Score: 1 | Accepted answer
  
  After a lot of digging, I realised what was happening. For some reason, there was a second `civicrm_saved_search` table in the database named `civicrm_saved_search-b` .
  
  That hyphen `-` is an 'illegal' character unless you escape it.
  
  To resolve the issue, all I did was change the `-` to a `_` which cleared everything up and enabled me to upgrade my site within minutes.
  
  Hopefully, this will help someone else one day who has a similar issue!
  
  > **Comments:**
  > **username_1**: That does bring up an interesting point though - maybe this function should escape the trigger names? https://github.com/civicrm/civicrm-core/blob/5.14/CRM/Logging/Schema.php#L250  
  > **username_0**: I was thinking that myself,  decided against changing the core files. I'm not sure whether this would be an issue or just an isolated incident...  
  
  ---
  
  