-
Notifications
You must be signed in to change notification settings - Fork 106
Open
Description
What happened?
The first time I insert data, it works successfully in Realm. But when I try to update it, the app crashes.
It data large. size of data from model
listOfConfigM: 2 record, activeConfig: 38 record, paramsActive: 629 record
Repro steps
- Convert json to Realm Model
- Call realm.addAll($realmObject, update: true); inside realm.writeAsync
- Data saved in realm
- Repeat it again from step 1, 2
- App crash
Version
realm: ^20.1.1, Flutter 3.32.2, Dart 3.8.1
What Atlas Services are you using?
Local Database only
What type of application is this?
Flutter Application
Client OS and version
iOs 18.3
Code snippets
@RealmModel()
class $ConfigurationSchema {
@PrimaryKey()
late String name;
late ConfigurationType? configType;
late DateTime? lastModified;
late DateTime? lastUpdated;
}
@RealmModel(ObjectType.embeddedObject)
class $ConfigurationType {
late String? type;
late MyConfituration? myConfiguration;
}
@RealmModel(ObjectType.embeddedObject)
class $MyConfituration {
late List<$ConfigM> listOfConfigM;
}
@RealmModel(ObjectType.embeddedObject)
class $ConfigM {
late String id;
late String? name;
late List<$ActiveConfig> activeConfig;
}
@RealmModel(ObjectType.embeddedObject)
class $ActiveConfig {
late String id;
late String? name;
late String? type;
late List<$PararamActive> paramsActive;
}
@RealmModel(ObjectType.embeddedObject)
class $PararamActive {
late String id;
late String? name;
late RealmValue value;
}
var simpleConfigJson = '''
{
"name": "simpleConfig",
"configType": {
"type": "myConfiguration",
"myConfiguration": {
"listOfConfigM": [
{
"id": "1",
"name": "Config1",
"activeConfig": [
{
"id": "1.1",
"name": "ActiveConfig1",
"type": "TypeA",
"paramsActive": [
{
"id": "1.1.1",
"name": "Param1",
"value": {"stringValue": "Value1"}
},
{
"id": "1.1.2",
"name": "Param2",
"value": false
},
{
"id": "1.1.3",
"name": "Param3",
"value": ["hello", "world"]
}
]
}
]
},
{
"id": "2",
"name": "Config2",
"activeConfig": [
{
"id": "2.1",
"name": "ActiveConfig2",
"type": "TypeB",
"paramsActive": [
{
"id": "2.1.1",
"name": "Param2",
"value": 0
}
]
}
]
}
]
}
},
"lastModified": "${DateTime.now().toIso8601String()}",
"lastUpdated": "${DateTime.now().toIso8601String()}"
}
''';
var confMap = jsonDecode(simpleConfigJson);
var configurationSchema = ConfigurationSchema(
name: confMap['name'],
configType: ConfigurationType(
type: confMap['configType']['type'],
myConfiguration: MyConfituration(
listOfConfigM: (confMap['configType']['myConfiguration']['listOfConfigM'] as List)
.map((item) => ConfigM(
id: item['id'],
name: item['name'],
activeConfig: (item['activeConfig'] as List)
.map((activeItem) => ActiveConfig(
id: activeItem['id'],
name: activeItem['name'],
type: activeItem['type'],
paramsActive: (activeItem['paramsActive'] as List)
.map((param) => PararamActive(
id: param['id'],
name: param['name'],
value: RealmValue.fromJson(param['value'])
)).toList()
)).toList()
)).toList()
)
),
lastModified: DateTime.parse(confMap['lastModified']),
lastUpdated: DateTime.parse(confMap['lastUpdated'])
);
realm.writeAsync(() {
realm.addAll([configurationSchema], update: true);
});
Stacktrace of the exception/crash you're getting
-
Relevant log output
-