Hi All,

we recently had to migrate a Drupal 8 installation from mysql to postgres database. In the beginning it went susprisingly smooth, but now we found a problem:
Complex views create sql-queries with very long table aliases, and postgres truncates all names to 64 characters, so it results in the following SQL-error (stripped to show the relevant parts)

: Exception in Booking request overviews[booking_request_overviews]: SQLSTATE[42712]: Duplicate alias: 7 ERROR:  table name "service_entity_field_data_node__field_package__service_entity__" specified more than once: SELECT COUNT(*) AS expression
LEFT JOIN {service_entity__field_service} service_entity_field_data_node__field_package__service_entity__field_service ON  ... 
LEFT JOIN {service_entity__field_series} service_entity_field_data_node__field_package__service_entity__field_series ON  ...

The limit seems to be hardcoded with the postgres code, so I can't change anything on the database (correct me please, if I'm wrong)

So my question is, how can I handle this best?
My first though is, to implement the hook_views_query_alter and replace all created aliases with shorter names.
But this seems to be quite a dirty hack...

Thanks for all suggestions


mmjvb’s picture

mmbk’s picture

Thanks for the link, this issue is so long in the queue already :-(

I guess I will check the 8.3.x-dev branch, it seems to be fixed there.