- First commit to issue fork.
- Status changed to Needs review
12 months ago 8:22am 11 March 2024
With Drupal 10.2.4 set up running against a Postgres database, loading the totals report results in a generic Drupal error.
Simply load the /admin/reports/donation/totals endpoint. The generic error page will come up. Logs show the following:
Drupal\Core\Database\DatabaseExceptionWrapper: Exception in Donations[give_donations]: SQLSTATE[42883]: Undefined function: 7 ERROR: function from_unixtime(integer) does not exist LINE 1: SELECT TO_CHAR(FROM_UNIXTIME(give_donation.created), 'YYYY')... ^ HINT: No function matches the given name and argument types. You might need to add explicit type casts.: SELECT TO_CHAR(FROM_UNIXTIME(give_donation.created), 'YYYY') AS "give_donation_created", COUNT(give_donation.id) AS "id", SUM(give_donation.amount) AS "give_donation_amount", MIN(give_donation.id) AS "id_1", MIN(users_field_data_give_donation.uid) AS "users_field_data_give_donation_uid" FROM "give_donation" "give_donation" INNER JOIN "users_field_data" "users_field_data_give_donation" ON give_donation.uid = users_field_data_give_donation.uid GROUP BY "give_donation_created" ORDER BY "give_donation_created" DESC NULLS LAST LIMIT 26 OFFSET 0; Array ( ) in main() (line 19 of /var/www/html/drupal/web/index.php).
Replace line 100 of src/Plugin/views/field/ViewsDateFormatSqlField.php
:
$formula = $this->query->getDateFormat("FROM_UNIXTIME($this->tableAlias.$this->realField)", $this->format_string);
with:
$db_driver = \Drupal\Core\Database\Database::getConnection()->driver();
if ($db_driver == "pgsql") {
$formula = $this->query->getDateFormat("DATE(TO_TIMESTAMP($this->tableAlias.$this->realField))", $this->format_string);
} else {
$formula = $this->query->getDateFormat("FROM_UNIXTIME($this->tableAlias.$this->realField)", $this->options['format_string']);
}
This solution was found in a similar issue on another plugin here 🐛 PostgreSQL SQL Error: Undefined function FROM_UNIXTIME Active .
N/A
N/A
N/A
Needs review
2.0
Code
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.