Skip to content

Commit a058ee3

Browse files
Date(time) sorting does not take time into account (#295)
* Take time into account when enabled for datetime sorting * 🍺 --------- Co-authored-by: Ryan Mitchell <[email protected]>
1 parent dc7851c commit a058ee3

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/Entries/EntryQueryBuilder.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,12 @@ public function orderBy($column, $direction = 'asc')
6363
} elseif (in_array($fieldType, ['integer'])) {
6464
$castType = 'float'; // bit sneaky but mysql doesnt support casting as integer, it wants unsigned
6565
} elseif (in_array($fieldType, ['date'])) {
66-
$castType = 'date';
66+
// Take time into account when enabled
67+
if ($blueprintField->get('time_enabled')) {
68+
$castType = 'datetime';
69+
} else {
70+
$castType = 'date';
71+
}
6772

6873
// sqlite casts dates to year, which is pretty unhelpful
6974
if (str_contains(get_class($grammar), 'SQLiteGrammar')) {

0 commit comments

Comments
 (0)