When deleting a content type it throws the following issue:

ERROR: invalid syntax for integer: «node.contenido_de_prueba.default» en carácter 111
2017-01-18 14:51:50 CET [9613-2] SENTENCE: DELETE FROM simple_sitemap_entity_overrides
WHERE (entity_type = 'entity_view_display') AND (entity_id IN ('node.contenido_de_prueba.default'))

Digging in the code table is defined as:

'entity_id' => [
'description' => 'ID of the overriding entity.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
],

It is called on function:

public function removeEntityInstanceSettings($entity_type_id, $entity_ids = NULL)

Triggered by:
removeEntityInstanceSettings($entity->getEntityTypeId(), $entity->id());

According to API:
/**
* Gets the identifier.
*
* @return string|int|null
* The entity identifier, or NULL if the object does not yet have an
* identifier.
*/
public function id();

This function can answer string or integer, the easiest way of fixing it would be changing field type to varchar

CommentFileSizeAuthor
#10 bundle_delete.diff954 byteslamigo
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

lamigo created an issue. See original summary.

gbyte’s picture

Assigned: lamigo » Unassigned
Status: Active » Postponed (maintainer needs more info)

Hi there! Why would you post an issue against a module version that is over 7 months old? I would advise to use the most recent stable version for production, but make sure to test the dev version before submitting issues. If you can reproduce the problem on dev, please update this issue accordingly.

lamigo’s picture

Version: 8.x-2.5 » 8.x-2.8

Sorry, it was a select box mistake, it's 8.x-2.8

lamigo’s picture

Current dev is 8.x-2.7+9-dev and I diffed them with no changes on this issue

gbyte’s picture

Version: 8.x-2.8 » 8.x-2.x-dev
Status: Postponed (maintainer needs more info) » Active

Thanks for reporting. As mentioned, anything that needs fixing needs to be tracked for the dev version.

removeEntityInstanceSettings() is called in hook_entity_delete. I have just deleted a content type (a node bundle) and have not encountered this error. It appears from your error that the removal of an entity_view_display is responsible. Can you please try and reproduce this error on a fresh drupal instance? If you succeed, would you mind providing your server configuration?

lamigo’s picture

Version: 8.x-2.x-dev » 8.x-2.8
Status: Active » Postponed (maintainer needs more info)

Hello,

I will make a fresh install and let you know, but it's worth mentioning it's on a postgresql 9.4 install, postgres uses to be a lot more strict than Mysql, I see tests are run on mysql, have you tried it on postgres?

Best Regards

lamigo’s picture

Made a new machine and a fresh new install 8.2.5 , default install, database postgres 9.4, nothing changed, installed simple_sitemap_8.x.2.x-dev created a dummy content type and while trying to delete:

Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[22P02]: Invalid text representation: 7 ERROR: invalid input syntax for integer: "node.blabla.default" LINE 2: ...type = 'entity_view_display') AND (entity_id IN ('node.blab... ^: DELETE FROM {simple_sitemap_entity_overrides} WHERE (entity_type = :db_condition_placeholder_0) AND (entity_id IN (:db_condition_placeholder_1)); Array ( [:db_condition_placeholder_0] => entity_view_display [:db_condition_placeholder_1] => node.blabla.default ) en Drupal\simple_sitemap\Simplesitemap->removeEntityInstanceSettings() (linea 325 de /var/www/drupal/modules/simple_sitemap/src/Simplesitemap.php).

Again, entity_id IN (:db_condition_placeholder_1) but [:db_condition_placeholder_1] => node.blabla.default while the field is defined as integer, maybe mysql does not complain on you trying to compare a string with an integer but this field must be defined as a varchar.

gbyte’s picture

Title: Field entity_id should not be integer » PostgreSQL throws error on bundle delete
Version: 8.x-2.8 » 8.x-2.x-dev
Status: Postponed (maintainer needs more info) » Active

For the third time: This issue needs to be set for the dev version of the module (in this case 8.x-2.x-dev). Please do not change the version. Also, why did you change 'Status' to 'postponed'?

Anyhow I'm sure you are right as it makes perfect sense that postgre triggers the error. Will look into it soon.

ma10’s picture

Just FYI, I'm seeing the same error, with PostgreSQL 9.6.1.

lamigo’s picture

FileSize
954 bytes

I uploaded the file with the changes I made myself, it was committed with git too but unsure if it worked.

  • gbyte.co committed 856a237 on 8.x-2.x
    Issue #2844636 by lamigo: PostgreSQL throws error on bundle delete
    
gbyte’s picture

Status: Active » Fixed

@lamigo Thanks for the patch, I fixed your update hook as it failed and used a non-deprecated method. Pushed to the development version.

Status: Fixed » Closed (fixed)

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