I'm getting this error in SQL Server 2008:

PDOException: SQLSTATE[22018]: [Microsoft][SQL Server Native Client 10.0][SQL Server]Conversion failed when converting the nvarchar value 'full_html' to data type int.: SELECT entity_id, pathauto FROM {pathauto_persist} WHERE entity_type = :entity_type AND entity_id IN (:entity_ids_0, :entity_ids_1); Array ( [:entity_type] => wysiwyg_profile [:entity_ids_0] => filtered_html [:entity_ids_1] => full_html ) in pathauto_persist_entity_state_load_multiple() (line 66 of path-to-module\pathauto_persist.module).

This is kinda-sorta related to this problem: #1003788: PostgreSQL: PDOException:Invalid text representation when attempting to load an entity with a string or non-scalar ID

Anyhow, we can't be guaranteed that entity IDs will be integers, so the entity ID column in the pathauto_persist table needs to be varchar.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

azinck’s picture

Status: Active » Needs review
FileSize
1008 bytes
Dave Reid’s picture

Status: Needs review » Needs work

We could just instead do a filter on the array IDs using is_numeric() rather than having to convert a nicely performing int primary key field into a varchar.

azinck’s picture

Thanks for the response, Dave. Do we know that no entities with non-integer IDs will ever need to use Pathauto?

azinck’s picture

Patch per Dave's suggestion in #2

azinck’s picture

Status: Needs work » Needs review
azinck’s picture

Previous patch fails if array ends up empty after filtering.

torpy’s picture

Status: Needs review » Needs work

The patch in #6 doesn't work for me:

PDOException: SQLSTATE[22018]: [Microsoft][SQL Server Native Client 11.0][SQL Server]Conversion failed when converting the nvarchar value 'plain_text' to data type int.: SELECT entity_id, pathauto FROM {pathauto_persist} WHERE entity_type = :entity_type AND entity_id IN (:entity_ids_0, :entity_ids_1, :entity_ids_2); Array ( [:entity_type] => wysiwyg_profile [:entity_ids_0] => filtered_html [:entity_ids_1] => full_html [:entity_ids_2] => plain_text ) in pathauto_persist_entity_state_load_multiple() (line 70 of <snip>\pathauto_persist\pathauto_persist.module).

torpy’s picture

Status: Needs work » Needs review

Actually, never mind, I did something stupid when applying the patch. My apologies, it works :)

Fabianx’s picture

Issue summary: View changes
Status: Needs review » Reviewed & tested by the community

RTBC, works great!

stefan.r’s picture

There is patch (D8 backport) in #1003788: PostgreSQL: PDOException:Invalid text representation when attempting to load an entity with a string or non-scalar ID which solves this in Drupal 7 Core and needs review...

heddn’s picture

Dave Reid’s picture

Status: Reviewed & tested by the community » Closed (works as designed)

Agreed, I don't think we need to add this in now. I believe this would also be solved by #2476393: Performance issue since we wouldn't be attempting to query for anything that doesn't have records in the pathauto_persist table.