-
Notifications
You must be signed in to change notification settings - Fork 86
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
Const schema refactoring #903
base: main
Are you sure you want to change the base?
Changes from all commits
6cdc36e
7e6b76a
46f7922
7059737
839906b
1e4445a
206b072
2b46291
6aa8ccf
5c1e29e
4ca6dcc
49fddf9
d343b82
9929a0a
65e2399
2aaab5d
70535f5
7eaab2e
9b52515
0aefb15
7ae42f4
9238c80
c20df78
ddcf598
eb7a07b
b80d580
f4ea3a0
625102a
cba8206
6e436f9
ad31e7d
165df3f
e000282
fd4a878
4bef442
0895676
d74b40b
d5f965d
70769e6
d39de76
2bf0a3b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ | |
}, | ||
"dart.lineLength": 160, | ||
"cSpell.words": [ | ||
"apikey", | ||
"apikeys", | ||
"bson", | ||
"deallocated", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,36 +21,65 @@ import 'dart:typed_data'; | |
import 'package:objectid/objectid.dart'; | ||
import 'package:sane_uuid/uuid.dart'; | ||
|
||
/// All supported `Realm` property types. | ||
/// {@category Configuration} | ||
/// @nodoc | ||
abstract class RealmAccessorMarker { | ||
T getValue<T>(RealmObjectMarker object, String propertyName); | ||
T? getObject<T>(RealmObjectMarker object, String propertyName); | ||
List<T> getList<T>(RealmObjectMarker object, String propertyName); | ||
void set<T>(RealmObjectMarker object, String propertyName, T value, {bool isDefault = false, bool update = false}); | ||
} | ||
|
||
Type _typeOf<T>() => T; // TODO(kasper): Replace with public version once realm_common contains all | ||
|
||
/// @nodoc | ||
class Mapping<T> { | ||
const Mapping(); | ||
|
||
// Types | ||
Type get type => T; | ||
Type get nullableType => _typeOf<T?>(); | ||
Type get listType => List<T>; | ||
Type get listOfNullablesType => List<T?>; | ||
|
||
// Factories | ||
T? getObject(RealmAccessorMarker accessor, RealmObjectMarker object, String propertyName) => accessor.getObject<T>(object, propertyName); | ||
T getValue(RealmAccessorMarker accessor, RealmObjectMarker object, String propertyName) => accessor.getValue<T>(object, propertyName); | ||
T? getNullableValue(RealmAccessorMarker accessor, RealmObjectMarker object, String propertyName) => accessor.getValue<T?>(object, propertyName); | ||
List<T> getList(RealmAccessorMarker accessor, RealmObjectMarker object, String propertyName) => accessor.getList<T>(object, propertyName); | ||
List<T?> getListOfNullables(RealmAccessorMarker accessor, RealmObjectMarker object, String propertyName) => accessor.getList<T?>(object, propertyName); | ||
} | ||
|
||
const _intMapping = Mapping<int>(); | ||
const _boolMapping = Mapping<bool>(); | ||
const _doubleMapping = Mapping<double>(); | ||
Comment on lines
+52
to
+54
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why this types are special and we have constants only for them? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. because int, bool, and double are both members of the enum and primitive types in dart.. Hence this little trick |
||
|
||
/// @nodoc | ||
enum RealmPropertyType { | ||
int, | ||
bool, | ||
string, | ||
// ignore: unused_field, constant_identifier_names | ||
_3, | ||
binary, | ||
// ignore: unused_field, constant_identifier_names | ||
_5, | ||
mixed, | ||
// ignore: unused_field, constant_identifier_names | ||
_7, | ||
timestamp, | ||
float, | ||
double, | ||
int(_intMapping), | ||
bool(_boolMapping), | ||
string(Mapping<String>()), | ||
_3, // ignore: unused_field, constant_identifier_names | ||
binary(Mapping<Uint8List>()), | ||
_5, // ignore: unused_field, constant_identifier_names | ||
mixed(Mapping<RealmAny>()), | ||
_7, // ignore: unused_field, constant_identifier_names | ||
timestamp(Mapping<DateTime>()), | ||
float(Mapping<Float>()), | ||
double(_doubleMapping), | ||
decimal128, | ||
object, | ||
// ignore: unused_field, constant_identifier_names | ||
_13, | ||
object(Mapping<RealmObjectMarker>()), | ||
_13, // ignore: unused_field, constant_identifier_names | ||
linkingObjects, | ||
objectid, | ||
// ignore: unused_field, constant_identifier_names | ||
_16, | ||
uuid, | ||
objectid(Mapping<ObjectId>()), | ||
_16, // ignore: unused_field, constant_identifier_names | ||
uuid(Mapping<Uuid>()); | ||
|
||
const RealmPropertyType([this.mapping = const Mapping<Never>()]); | ||
|
||
final Mapping<dynamic> mapping; | ||
} | ||
|
||
/// All supported `Realm` collection types. | ||
/// {@category Configuration} | ||
/// @nodoc | ||
enum RealmCollectionType { | ||
none, | ||
list, | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a breaking change? I guess people just need to re-run the generator?