On the low lever of the WPDB driver, we're indeed executing an unknown query,
and we can't say that they are by themeselves fully safe. It's higher levels of
abstraction in Doctrine that aim to prevent us from generating unsafe querires.
[MAILPOET-6150]
I looked into using DBAL events for this but found that DBAL events
are deprecated so I went with middleware as they are recommended
as a replacement for the DBAL events.
[MAILPOET-6142]
The conversion is done by MailPoetVendor\Doctrine\DBAL\Driver\API\MySQL\ExceptionConverter
that is returned from MailPoetVendor\Doctrine\DBAL\Driver\AbstractMySQLDriver.
[MAILPOET-6142]