Problem/Motivation

While updating the module (drush updatedb):

Failed: 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                  [error]
FROM
node_revision__field_address f
INNER JOIN paragraphs_item_revision_fiel' at line 1: SELECT f.entity_id AS entity_id, f. AS
FROM
{node_revision__field_address} f
INNER JOIN {paragraphs_item_revision_field_data} p ON f. = p.revision_id
WHERE ((p.parent_id <> f.entity_id)) OR (p.parent_type <> :db_condition_placeholder_0) OR (p.parent_field_name <> :db_condition_placeholder_1)
ORDER BY p.revision_id ASC
LIMIT 100 OFFSET 0; Array
(
    [:db_condition_placeholder_0] => node
    [:db_condition_placeholder_1] => field_address
)
 in paragraphs_post_update_rebuild_parent_fields() (regel 240 van /var/www/html/web/modules/contrib/paragraphs/paragraphs.post_update.php).

If I check the $current_field array, the revision_column is NULL for multiple fields on my site. Strange?

array(6) {                                                                 
  ["entity_type_id"]=>                                                     
  string(4) "node"                                                         
  ["field_name"]=>                                                         
  string(13) "field_address"                                               
  ["revision_table"]=>                                                     
  string(28) "node_revision__field_address"                                
  ["entity_id_column"]=>                                                   
  string(9) "entity_id"                                                    
  ["revision_column"]=>                                                    
  NULL                                                                     
  ["langcode_column"]=>                                                    
  string(8) "langcode"                                                     
}   

Proposed resolution

See Patch.

Remaining tasks

Review patch.

User interface changes

None

API changes

None

Data model changes

None

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

tomhollevoet created an issue. See original summary.

Spokje’s picture

Exact same error using the same (drush updb) method.
Weirdly this is the first out of 25 sites that fails in this way. All others had no problems at all.

Anyway: RTBC for me.

Spokje’s picture

Status: Needs review » Reviewed & tested by the community
Berdir’s picture

field_address? Is that really a paragraph field or is it something else?

Spokje’s picture

@Berdir:

In my case the error is/was:

>  [error]  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
> FROM
> paragraph_revision__field_p_tl_tiles f
> INNER JOIN paragraphs_item_revis' at line 1: SELECT f.entity_id AS entity_id, f. AS
> FROM
> {paragraph_revision__field_p_tl_tiles} f
> INNER JOIN {paragraphs_item_revision_field_data} p ON f. = p.revision_id
> WHERE (((p.parent_id <> f.entity_id)) OR (p.parent_type <> :db_condition_placeholder_0) OR (p.parent_field_name <> :db_condition_placeholder_1)) AND ((p.langcode = f.langcode))
> ORDER BY p.revision_id ASC
> LIMIT 100 OFFSET 0; Array
> (
>     [:db_condition_placeholder_0] => paragraph
>     [:db_condition_placeholder_1] => field_p_tl_tiles
> )

So at the very least the parent is a paragraph.

Looking at the report at /admin/reports/fields:

Field name 	        Entity type  Field type 	
field_p_tl_tiles 	paragraph    Entity reference revisions (module: entity_reference_revisions) 	
Spokje’s picture

(Semi?) Interesting addendum: If I do the paragraphs update together with a Drupal Core update from D8.6.17 => D8.7.7, the patch is not needed and the post-update does not fail on the mentioned field.

Berdir’s picture

I'm more interested in the target entity type of field_p_tl_tiles than its host entity type :)

Spokje’s picture

Its parent is another Paragraph.

Berdir’s picture

Status: Reviewed & tested by the community » Fixed

I still don't understand when this happens, but it shouldn't interfere with anything that currently works. We have upgrade path tests now, they work, the sqlite fails seem unrelated.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.