Skip to content

Commit 032c96e

Browse files
committed
fix(models): correct Row.fromMap constructor to handle columns named data
- Changed data assignment to use complete map instead of data field - This fixes TypeError when table has column named data - Added tests to verify the fix - Fixes #281
1 parent 7c92317 commit 032c96e

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

lib/src/models/row.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ class Row implements Model {
4545
$createdAt: map['\$createdAt'].toString(),
4646
$updatedAt: map['\$updatedAt'].toString(),
4747
$permissions: List.from(map['\$permissions'] ?? []),
48+
// Assign the entire map to data
4849
data: map,
4950
);
5051
}

test/src/models/row_test.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ void main() {
2727
expect(result.$permissions, []);
2828
});
2929

30-
// Test for the specific bug reported in issue #281
30+
// Test for the specific bug
31+
//reported in issue #281
3132
test('fromMap should handle columns named data without type errors', () {
3233
final map = {
3334
'\$id': 'row123',

0 commit comments

Comments
 (0)