From 79b14882306c114b15c67522df1e3558a23521f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Ayd=C4=B1n?= <84200491+ahmtydn@users.noreply.github.com> Date: Sun, 15 Sep 2024 07:30:48 +0300 Subject: [PATCH 1/7] Fix: Add Type parameter to resolve bug with generic types in mixin usage - Added Type parameter in adapter registration to fix issues with generic types when using mixins. - This change addresses the bug where mixin-based models were not correctly recognized by the type registry. --- lib/src/hive.dart | 3 ++- lib/src/impl/type_registry.dart | 8 ++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/src/hive.dart b/lib/src/hive.dart index 3f106f107..1361f4bdf 100644 --- a/lib/src/hive.dart +++ b/lib/src/hive.dart @@ -38,8 +38,9 @@ class Hive { static void registerAdapter( String typeName, T? Function(dynamic json) fromJson, + Type? type, ) { - _typeRegistry.register(Isar.fastHash(typeName), fromJson); + _typeRegistry.register(Isar.fastHash(typeName), fromJson, type); } /// Get or open the box with [name] in the given [directory]. If no directory diff --git a/lib/src/impl/type_registry.dart b/lib/src/impl/type_registry.dart index c8e0d7e8b..80399cead 100644 --- a/lib/src/impl/type_registry.dart +++ b/lib/src/impl/type_registry.dart @@ -12,14 +12,18 @@ class _TypeRegistry { final Map> _registry = {}; final Map> _reverseRegistry = {..._builtinTypes}; - void register(int typeId, T? Function(dynamic json) fromJson) { + void register( + int typeId, + T? Function(dynamic json) fromJson, + Type? type, + ) { if (T == dynamic) { throw ArgumentError('Cannot register dynamic type.'); } final handler = _TypeHandler(typeId, fromJson); _registry[typeId] = handler; - _reverseRegistry[T] = handler; + _reverseRegistry[type ?? T] = handler; } T fromJson(int? typeId, dynamic json) { From 5eb6fe59fdb70d332a27102ecccd4efc0bfde7fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Ayd=C4=B1n?= <84200491+ahmtydn@users.noreply.github.com> Date: Sun, 15 Sep 2024 07:39:57 +0300 Subject: [PATCH 2/7] set as optional parameter --- lib/src/hive.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/src/hive.dart b/lib/src/hive.dart index 1361f4bdf..865975f72 100644 --- a/lib/src/hive.dart +++ b/lib/src/hive.dart @@ -37,9 +37,9 @@ class Hive { /// ``` static void registerAdapter( String typeName, - T? Function(dynamic json) fromJson, + T? Function(dynamic json) fromJson, [ Type? type, - ) { + ]) { _typeRegistry.register(Isar.fastHash(typeName), fromJson, type); } From fdcf91915ec8b3e60ca069762d054427c06ef3a9 Mon Sep 17 00:00:00 2001 From: ahmtydn Date: Tue, 16 Sep 2025 19:21:17 +0300 Subject: [PATCH 3/7] Update isar dependency to use git reference for development --- pubspec.yaml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index 790179f50..aef1b41fb 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -17,7 +17,11 @@ environment: sdk: ">=3.1.0 <4.0.0" dependencies: - isar: ^4.0.0-dev.13 + isar: + git: + url: https://github.com/ahmtydn/isar.git + ref: isar-dev + path: packages/isar meta: ^1.9.0 dev_dependencies: From 20a9efd66f921d32f48a76eb017eea7bcd815890 Mon Sep 17 00:00:00 2001 From: ahmtydn Date: Tue, 16 Sep 2025 19:40:00 +0300 Subject: [PATCH 4/7] Revert "Update isar dependency to use git reference for development" This reverts commit fdcf91915ec8b3e60ca069762d054427c06ef3a9. --- pubspec.yaml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/pubspec.yaml b/pubspec.yaml index aef1b41fb..790179f50 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -17,11 +17,7 @@ environment: sdk: ">=3.1.0 <4.0.0" dependencies: - isar: - git: - url: https://github.com/ahmtydn/isar.git - ref: isar-dev - path: packages/isar + isar: ^4.0.0-dev.13 meta: ^1.9.0 dev_dependencies: From b3b0ec306ff9836d6aab5e91276398eda2d5d52c Mon Sep 17 00:00:00 2001 From: ahmtydn Date: Wed, 17 Sep 2025 22:44:25 +0300 Subject: [PATCH 5/7] Replace isar dependency with isar_plus in multiple files --- lib/hive.dart | 6 +++--- lib/src/impl/frame.dart | 2 +- pubspec.yaml | 2 +- test/common.dart | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/hive.dart b/lib/hive.dart index ed5d8f023..59c0671dc 100644 --- a/lib/hive.dart +++ b/lib/hive.dart @@ -7,9 +7,9 @@ import 'dart:isolate' if (dart.library.html) 'package:hive/src/impl/isolate_stub.dart'; import 'package:hive/src/impl/frame.dart'; -import 'package:isar/isar.dart'; +import 'package:isar_plus/isar_plus.dart'; -part 'src/impl/box_impl.dart'; -part 'src/impl/type_registry.dart'; part 'src/box.dart'; part 'src/hive.dart'; +part 'src/impl/box_impl.dart'; +part 'src/impl/type_registry.dart'; diff --git a/lib/src/impl/frame.dart b/lib/src/impl/frame.dart index 084ba1f48..b7a5cf737 100644 --- a/lib/src/impl/frame.dart +++ b/lib/src/impl/frame.dart @@ -1,4 +1,4 @@ -import 'package:isar/isar.dart'; +import 'package:isar_plus/isar_plus.dart'; part 'frame.g.dart'; diff --git a/pubspec.yaml b/pubspec.yaml index 790179f50..bde26f505 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -17,7 +17,7 @@ environment: sdk: ">=3.1.0 <4.0.0" dependencies: - isar: ^4.0.0-dev.13 + isar_plus: ^1.0.1 meta: ^1.9.0 dev_dependencies: diff --git a/test/common.dart b/test/common.dart index 2a6d503c4..8820f38aa 100644 --- a/test/common.dart +++ b/test/common.dart @@ -4,7 +4,7 @@ import 'dart:math'; import 'package:hive/hive.dart'; import 'package:hive/src/impl/frame.dart'; -import 'package:isar/isar.dart'; +import 'package:isar_plus/isar_plus.dart'; import 'package:test/test.dart'; const _releases = 'https://github.com/isar/isar/releases/download/'; From aa61dcbe56f20babd5c4ffb949994c7ad0550728 Mon Sep 17 00:00:00 2001 From: ahmtydn Date: Wed, 17 Sep 2025 23:11:51 +0300 Subject: [PATCH 6/7] Update isar_plus dependency to version 1.0.3 --- pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index bde26f505..b269eb54a 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -17,7 +17,7 @@ environment: sdk: ">=3.1.0 <4.0.0" dependencies: - isar_plus: ^1.0.1 + isar_plus: ^1.0.3 meta: ^1.9.0 dev_dependencies: From 52384ded658ad573d16137ea643130ad18153c07 Mon Sep 17 00:00:00 2001 From: ahmtydn Date: Wed, 17 Sep 2025 23:45:02 +0300 Subject: [PATCH 7/7] Bump isar_plus dependency to version 1.0.4 --- pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index b269eb54a..6c0a6a3e4 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -17,7 +17,7 @@ environment: sdk: ">=3.1.0 <4.0.0" dependencies: - isar_plus: ^1.0.3 + isar_plus: ^1.0.4 meta: ^1.9.0 dev_dependencies: