diff --git a/src/ViewsQueryAlter.php b/src/ViewsQueryAlter.php
index 696c3a5..8c2a95f 100644
--- a/src/ViewsQueryAlter.php
+++ b/src/ViewsQueryAlter.php
@@ -140,7 +140,7 @@ class ViewsQueryAlter implements ContainerInjectionInterface {
     // ensure that we just return not deleted entities.
     if (!$has_delete_condition) {
       $groups = $query->where;
-      $group = empty($groups) ? 1 : max(array_keys($groups)) + 1;
+      $group = empty($groups) ? 1 : (int) max(array_keys($groups)) + 1;
       $query->addWhere($group, "{$deleted_table_name}.{$deleted_table_column}", NULL, 'IS NULL');
     }
     // Otherwise ignore trash for the duration of this view, so it can load and
