I am using a entity_query, where I get a fatal error because the sort field is not found. The integer field (field_year exists) and exists in the database in the membership__field_year table in the field_year_value row.
query = $this->entity_query->get('membership');
$query->condition('field_membership_member', $this->member->id());
$query->condition('status', 1);
$query->sort('field_year' , 'DESC');
This is the error I get:
Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'membership__field_year.field_year_value' in 'field list'
How do I sort on an integer field?