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 @@ -558,7 +558,19 @@ class MockSupabaseHttpClient extends BaseClient {
558558 }
559559 } else if (postrestFilter.startsWith ('lt.' )) {
560560 final value = postrestFilter.substring (3 );
561- return (row) => row[columnName] < num .tryParse (value);
561+
562+ if (DateTime .tryParse (value) != null ) {
563+ final dateTime = DateTime .parse (value);
564+
565+ return (row) {
566+ final rowDate = DateTime .tryParse (row[columnName].toString ());
567+ return rowDate != null && rowDate.isBefore (dateTime);
568+ };
569+ } else if (num .tryParse (value) != null ) {
570+ return (row) => row[columnName] < num .tryParse (value);
571+ } else {
572+ throw UnimplementedError ('Unsupported value type' );
573+ }
562574 } else if (postrestFilter.startsWith ('gte.' )) {
563575 final value = postrestFilter.substring (4 );
564576 return (row) => row[columnName] >= num .tryParse (value);
Original file line number Diff line number Diff line change @@ -717,6 +717,32 @@ void main() {
717717 expect (count, 2 );
718718 });
719719
720+ test ('count with lt filter with datetime format' , () async {
721+ await mockSupabase.from ('data' ).insert ([
722+ {
723+ 'title' : 'First post' ,
724+ 'author_id' : 1 ,
725+ 'createdAt' : '2021-08-01 11:26:15.307+00'
726+ },
727+ {
728+ 'title' : 'Second post' ,
729+ 'author_id' : 2 ,
730+ 'createdAt' : '2021-08-02 11:26:15.307+00'
731+ },
732+ {
733+ 'title' : 'Third post' ,
734+ 'author_id' : 1 ,
735+ 'createdAt' : '2021-08-03 11:26:15.307+00'
736+ }
737+ ]);
738+ final count = await mockSupabase
739+ .from ('data' )
740+ .count ()
741+ .lt ('createdAt' , '2021-08-02 12:26:15.307+00' );
742+
743+ expect (count, 2 );
744+ });
745+
720746 test ('count with data and filter' , () async {
721747 await mockSupabase.from ('posts' ).insert ([
722748 {'title' : 'First post' , 'author_id' : 1 },
You can’t perform that action at this time.
0 commit comments