File tree Expand file tree Collapse file tree 2 files changed +39
-1
lines changed Expand file tree Collapse file tree 2 files changed +39
-1
lines changed Original file line number Diff line number Diff line change @@ -543,7 +543,19 @@ class MockSupabaseHttpClient extends BaseClient {
543543 return (row) => row[columnName].toString () != value;
544544 } else if (postrestFilter.startsWith ('gt.' )) {
545545 final value = postrestFilter.substring (3 );
546- return (row) => row[columnName] > num .tryParse (value);
546+
547+ if (DateTime .tryParse (value) != null ) {
548+ final dateTime = DateTime .parse (value);
549+
550+ return (row) {
551+ final rowDate = DateTime .tryParse (row[columnName].toString ());
552+ return rowDate != null && rowDate.isAfter (dateTime);
553+ };
554+ } else if (num .tryParse (value) != null ) {
555+ return (row) => row[columnName] > num .tryParse (value);
556+ } else {
557+ throw UnimplementedError ('Unsupported value type' );
558+ }
547559 } else if (postrestFilter.startsWith ('lt.' )) {
548560 final value = postrestFilter.substring (3 );
549561 return (row) => row[columnName] < num .tryParse (value);
Original file line number Diff line number Diff line change @@ -691,6 +691,32 @@ void main() {
691691 expect (count, 2 );
692692 });
693693
694+ test ('count with gt filter with datetime format' , () async {
695+ await mockSupabase.from ('data' ).insert ([
696+ {
697+ 'title' : 'First post' ,
698+ 'author_id' : 1 ,
699+ 'createdAt' : '2021-08-01 11:26:15.307+00'
700+ },
701+ {
702+ 'title' : 'Second post' ,
703+ 'author_id' : 2 ,
704+ 'createdAt' : '2021-08-02 11:26:15.307+00'
705+ },
706+ {
707+ 'title' : 'Third post' ,
708+ 'author_id' : 1 ,
709+ 'createdAt' : '2021-08-03 11:26:15.307+00'
710+ }
711+ ]);
712+ final count = await mockSupabase
713+ .from ('data' )
714+ .count ()
715+ .gt ('createdAt' , '2021-08-02 10:26:15.307+00' );
716+
717+ expect (count, 2 );
718+ });
719+
694720 test ('count with data and filter' , () async {
695721 await mockSupabase.from ('posts' ).insert ([
696722 {'title' : 'First post' , 'author_id' : 1 },
You can’t perform that action at this time.
0 commit comments