I am using the following code to query an ECK entity.
$query = \Drupal::database()->select('object__field_amount', 'f');
$query->fields('f', array('object__field_amount_value'));
$query->addExpression('MAX(object__field_amount_value)', 'maxvalue');
$query->execute()->fetchAssoc();
It raises the following exception.
Drupal\Core\Entity\EntityStorageException: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'maxvalue FROM object__field_amount f'
I've tried multiple other options, without result.
How do I avoid the code raises an exception?