From 2d805caccc51694b23b23cb9eea46426260879d8 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 23 Nov 2025 18:06:26 +0000 Subject: [PATCH 1/2] Initial plan From ec92e75dde7dc261ff29af87e99c816612f58a81 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 23 Nov 2025 18:13:04 +0000 Subject: [PATCH 2/2] Replace int64MaxValue with web-safe JavaScript MAX_SAFE_INTEGER Co-authored-by: anidotnet <696662+anidotnet@users.noreply.github.com> --- .../lib/src/collection/operations/read_operations.dart | 7 +++++-- packages/nitrite/test/collection/nitrite_id_test.dart | 6 +++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/packages/nitrite/lib/src/collection/operations/read_operations.dart b/packages/nitrite/lib/src/collection/operations/read_operations.dart index bd83dea..a0dcf50 100644 --- a/packages/nitrite/lib/src/collection/operations/read_operations.dart +++ b/packages/nitrite/lib/src/collection/operations/read_operations.dart @@ -1,4 +1,3 @@ -import 'package:dart_numerics/dart_numerics.dart'; import 'package:nitrite/nitrite.dart'; import 'package:nitrite/src/collection/document_cursor.dart'; import 'package:nitrite/src/collection/operations/find_optimizer.dart'; @@ -10,6 +9,10 @@ import 'package:nitrite/src/common/stream/processed_document_stream.dart'; import 'package:nitrite/src/common/stream/sorted_document_stream.dart'; import 'package:rxdart/rxdart.dart'; +/// Maximum safe integer value for JavaScript (2^53 - 1). +/// This is used instead of int64MaxValue to ensure compatibility with Flutter web. +const int _maxSafeInteger = 9007199254740991; + /// @nodoc class ReadOperations { final String _collectionName; @@ -137,7 +140,7 @@ class ReadOperations { if (findPlan.limit != null || findPlan.skip != null) { rawStream = rawStream.skip(findPlan.skip ?? 0); - rawStream = rawStream.take(findPlan.limit ?? int64MaxValue); + rawStream = rawStream.take(findPlan.limit ?? _maxSafeInteger); } } diff --git a/packages/nitrite/test/collection/nitrite_id_test.dart b/packages/nitrite/test/collection/nitrite_id_test.dart index 94599a1..fb7d14c 100644 --- a/packages/nitrite/test/collection/nitrite_id_test.dart +++ b/packages/nitrite/test/collection/nitrite_id_test.dart @@ -1,4 +1,3 @@ -import 'package:dart_numerics/dart_numerics.dart' as num; import 'package:nitrite/nitrite.dart'; import 'package:test/test.dart'; @@ -11,8 +10,9 @@ void main() async { }); test('Test Limit', () { - var one = NitriteId.createId(num.int64MaxValue.toString()); - var two = NitriteId.createId(num.int64MinValue.toString()); + // Using max safe integer for JavaScript (2^53 - 1) to ensure web compatibility + var one = NitriteId.createId('9007199254740991'); + var two = NitriteId.createId('-9007199254740991'); expect(one.compareTo(two), 1); });