Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nullable Map<String, dynamic> converted to empty map in _$ToSqlite #531

Closed
TillJohanndeiter opened this issue Jan 24, 2025 · 2 comments
Closed

Comments

@TillJohanndeiter
Copy link

Here is my class

@ConnectOfflineFirstWithSupabase(
  supabaseConfig: SupabaseSerializable(tableName: 'metric'),
)
class Metric extends OfflineFirstWithSupabaseModel
    with {
  Metric(
      {required this.id,
      required this.shortName,
      required this.longName,
      required this.num,
      required this.type});

  @override
  @Supabase(unique: true)
  @Sqlite(index: true, unique: true)
  final String id;
  final Map<String, dynamic> shortName;
  final Map<String, dynamic>? longName;
  @override
  final int num;
  @Supabase(enumAsString: true)
  @Sqlite(enumAsString: true)
  final MetricType type;
}

The generated $toSqlite method looks like this.

Future<Map<String, dynamic>> _$MetricToSqlite(Metric instance,
{required SqliteProvider provider,
OfflineFirstWithSupabaseRepository? repository}) async {
return {
'id': instance.id,
'short_name': jsonEncode(instance.shortName),
'long_name': jsonEncode(instance.longName ?? {}),
'num': instance.num,
'type': instance.type.name
};
}

As a result a null is converted to an empty Map.

Is this is a bug or a feature 🤔

@tshedor
Copy link
Collaborator

tshedor commented Jan 25, 2025

@TillJohanndeiter For sure a bug. Fixing in #532

@tshedor
Copy link
Collaborator

tshedor commented Jan 27, 2025

@TillJohanndeiter fixed in brick_sqlite_generators 3.3.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants