Error when viewing list of taxonomy terms I'm getting an "unexpected error" when I try to view a list of taxonomy terms. I recently updated to 8.7, though I have a feeling the problem has been around since before the update. Here's the error as it appears in watchdog:


  Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') AS expression FROM tfr INNER JOIN tr ON tfr. = tr. AND tr. = 0 INNER JOIN (S' at line 1: SELECT tfr.tid AS tid, MAX(tfr.) AS expression FROM {} tfr INNER JOIN {} tr ON tfr. = tr. AND tr. = 0 INNER JOIN (SELECT t.tid AS tid, t.langcode AS langcode, MAX(t.) AS expression FROM {} t WHERE t. = :db_condition_placeholder_0 GROUP BY t.tid, t.langcode) mr ON tfr. = mr. AND tfr.langcode = mr.langcode GROUP BY tfr.tid; Array ( [:db_condition_placeholder_0] => 1 ) in Drupal\taxonomy\TermStorage->getTermIdsWithPendingRevisions() (line 404 of /Applications/MAMP/htdocs/libnews/core/modules/taxonomy/src/TermStorage.php).


And I don't know if this related, but I am also getting an error when I try to update my database via drush:


  Error: Call to a member function getKey() on null in system_update_8702() (line 2278 of /Applications/MAMP/htdocs/libnews/core/modules/system/system.install) #0


This is outside my area of expertise, so I'm pretty stumped.
I got a similar error on my server too. 
I had to change the function in TermStorage.php to get it to work. 

Just a warning, this core hack and should be reverted once it is fixed in core. 
Replace getTermIdsWithPendingRevisions() with the following:

  public function getTermIdsWithPendingRevisions() {
$table_mapping = $this-&gt;getTableMapping();
$id_field = $table_mapping-&gt;getColumnNames($this-&gt;entityType-&gt;getKey('id'))['value'];
$revision_field = $table_mapping-&gt;getColumnNames($this-&gt;entityType-&gt;getKey('revision'))['value'];
$rta_field = $table_mapping-&gt;getColumnNames($this-&gt;entityType-&gt;getKey('revision_translation_affected'))['value'];
$langcode_field = $table_mapping-&gt;getColumnNames($this-&gt;entityType-&gt;getKey('langcode'))['value'];
$revision_default_field = $table_mapping-&gt;getColumnNames($this-&gt;entityType-&gt;getRevisionMetadataKey('revision_default'))['value'];

$query = $this-&gt;database-&gt;select($this-&gt;getRevisionDataTable(), 'tfr');
$query-&gt;fields('tfr', [$id_field]);
$query-&gt;addExpression("MAX(tfr.$revision_field)", $revision_field);

$query-&gt;join($this-&gt;getRevisionTable(), 'tr', "tfr.$revision_field = tr.$revision_field AND tr.$revision_default_field = 0");

$inner_select = $this-&gt;database-&gt;select($this-&gt;getRevisionDataTable(), 't');
$inner_select-&gt;condition("t.$rta_field", '1');
$inner_select-&gt;fields('t', [$id_field, $langcode_field]);
$inner_select-&gt;addExpression("MAX(t.$revision_field)", $revision_field);
$inner_select
  -&gt;groupBy("t.$id_field")
  -&gt;groupBy("t.$langcode_field");

$query-&gt;join($inner_select, 'mr', "tfr.$revision_field = mr.$revision_field AND tfr.$langcode_field = mr.$langcode_field");

$query-&gt;groupBy("tfr.$id_field");
return 0;
//return $query-&gt;execute()-&gt;fetchAllKeyed(1, 0);


}