Skip to content

WIP query #27

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

Merged
merged 72 commits into from
Oct 21, 2019
Merged
Show file tree
Hide file tree
Changes from 40 commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
88dd2d3
Implement query and builder related ffi functions
Buggaboo Sep 19, 2019
bb470cd
at least op overloading is working...
Buggaboo Sep 20, 2019
bd7a32e
minor typo
Buggaboo Sep 20, 2019
a8c849b
another attempt to fix the test
Buggaboo Sep 20, 2019
26e5b33
focus, do aliases later
Buggaboo Sep 20, 2019
39e6a8c
streamline enums
Buggaboo Sep 20, 2019
e820156
Finalized query condition design, also got tests running
Buggaboo Sep 20, 2019
15e9b7a
added operator overloads for int properties
Buggaboo Oct 2, 2019
7698354
added queryAny and queryAll to the box
Buggaboo Oct 2, 2019
23bb90f
added contains / contain to the party
Buggaboo Oct 2, 2019
004bcd2
added close to new queries
Buggaboo Oct 2, 2019
07a5059
updated dummy type for isNull / notNull
Buggaboo Oct 2, 2019
0d2e907
cleaned up tests
Buggaboo Oct 2, 2019
2b3b91b
added tests for double and booleans (both are not supported atm)
Buggaboo Oct 2, 2019
0b19c16
added implementation and tests for `in`, `notIn`, `greater`, `less`
Buggaboo Oct 2, 2019
b14c10c
updated test for `contain` and `contains` for String
Buggaboo Oct 2, 2019
b9c5189
* Modified function signature of find find_ids, maybe unnecessary
Buggaboo Oct 3, 2019
e81d351
Merge branch 'query' into dev-query
Buggaboo Oct 3, 2019
6690bd2
minor cleanup
Buggaboo Oct 3, 2019
231c781
updated readme
Buggaboo Oct 3, 2019
e80fe14
forgot symbol associativity
Buggaboo Oct 8, 2019
42f1152
added bool and double to supported types, still segfaulting on isNull…
Buggaboo Oct 9, 2019
b9ae9d9
try finally resource release
Buggaboo Oct 9, 2019
7481113
Merge branch 'dev' into dev-query
Buggaboo Oct 9, 2019
81895fd
renamed disjunctive normal form (dnf) to anyGroup
Buggaboo Oct 9, 2019
6c5bc56
Implemented other `free` functions for struct pointers
Buggaboo Oct 9, 2019
114d183
changed limit default to zero
Buggaboo Oct 9, 2019
462f74c
renamed condition operators
Buggaboo Oct 9, 2019
06fe677
_queryBuilderPtr -> _cBuilder
Buggaboo Oct 9, 2019
1f868a2
oops, corrected cop in params
Buggaboo Oct 9, 2019
0e2f88e
Added comment about type aliases
Oct 10, 2019
e34f02a
changed the ffi function return types for query_find(_ids) to Uint64,
Buggaboo Oct 10, 2019
55d7f70
kill your darlings: removed queryAll/queryAny that applies a reduce o…
Buggaboo Oct 10, 2019
dbcbe0f
kill your darlings: removed qb_strings_contain for Vector<String> types
Buggaboo Oct 10, 2019
768a7ef
moved out QueryBuilder into its own file within the internal library …
Buggaboo Oct 10, 2019
c9c0a0e
Merge branch 'dev-query' of github.com:Buggaboo/objectbox-dart into d…
Buggaboo Oct 10, 2019
be2aa90
Introduced support for other int-ish types.
Buggaboo Oct 11, 2019
e454a52
Moved out OBXOrderFlag to constants
Buggaboo Oct 11, 2019
ce1e0e3
removed unused generic param
Buggaboo Oct 11, 2019
1e91e20
Merge branch 'dev' into dev-query
Buggaboo Oct 11, 2019
bc05781
wrong number of params
Buggaboo Oct 12, 2019
df00e23
implemented manual type mapping
Buggaboo Oct 12, 2019
cbb44aa
fixed bad merge
Buggaboo Oct 12, 2019
9e8f49a
reimplemented find/findFirst
Buggaboo Oct 13, 2019
9497784
added bounds check to findFirst
Buggaboo Oct 13, 2019
75101fe
fixed minor issues with tests
Buggaboo Oct 13, 2019
b164fb5
added describe(_params)
Buggaboo Oct 13, 2019
d4d6613
oops
Buggaboo Oct 13, 2019
43324e0
added bool to integer conditions
Buggaboo Oct 13, 2019
5b36eda
corrected "dynamic" issue (dart type analysis hickup), and fixed oops…
Buggaboo Oct 13, 2019
ddeef77
corrected skewed tree construction and minimized the number of condit…
Buggaboo Oct 14, 2019
2987190
Merge branch 'dev' into dev-query
Buggaboo Oct 14, 2019
13e8c0e
Merge branch 'dev' into dev-query
Buggaboo Oct 14, 2019
aebd560
IntegerQuery apply simplification
vaind Oct 15, 2019
81c3ac5
create scoped TestEnv for tests
vaind Oct 15, 2019
b1fae6a
define and use OBX_id_array ffi struct
vaind Oct 15, 2019
00f60cc
updated README
Buggaboo Oct 16, 2019
02c656a
Merge pull request #1 from vaind/dev-query
Buggaboo Oct 16, 2019
92259ae
Merge branch 'dev-query' of github.com:Buggaboo/objectbox-dart into d…
Buggaboo Oct 16, 2019
4f0c2cf
replaced fields from Entity_ with named params
Buggaboo Oct 16, 2019
bfc0bc4
removed unused variables
Buggaboo Oct 16, 2019
3fae217
Renamed QueryCondition to ConditionGroup
Buggaboo Oct 16, 2019
57d9325
Renamed
Buggaboo Oct 16, 2019
3cccbf3
bindings no longer looks in lib automagically
Buggaboo Oct 16, 2019
196f964
streamline Query any/all grouping using ConditionGroup
vaind Oct 17, 2019
c6579ad
privatize QueryProperty internals so they don't pollute query code co…
vaind Oct 17, 2019
479e8a6
Revert "bindings no longer looks in lib automagically"
Buggaboo Oct 19, 2019
dabcaa9
Merge pull request #2 from vaind/dev-query
Buggaboo Oct 19, 2019
9cc3318
Merge branch 'dev-query' of github.com:Buggaboo/objectbox-dart into d…
Buggaboo Oct 19, 2019
0538b4d
Merge branch 'dev' into dev-query
Buggaboo Oct 19, 2019
075f5bd
Added workaround for signed dart binary issue from brew
Buggaboo Oct 19, 2019
e693c07
comment clean up
Buggaboo Oct 19, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 41 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,12 @@ As specified in step 3 of the _Getting started_ section, Dart's _build\_runner_
import "../lib/objectbox.dart";
part "basics_test.g.dart";

@Entity(id: 1, uid: 1)
@Entity()
class Note {
@Id(id: 1, uid: 1001) // automatically always 'int' in Dart code and 'Long' in ObjectBox
@Id() // automatically always 'int' in Dart code and 'Long' in ObjectBox
int id;

@Property(id: 2, uid: 1002)
@Property(uid: 1002)
String text;

Note(); // empty default constructor needed
Expand All @@ -98,6 +98,44 @@ print("refetched note: ${box.get(note.id)}");
store.close();
```

Query and QueryBuilder
----------------------

Basic querying can be done with e.g.:

```dart
// var store ...
// var box ...

box.putMany([Note(), Note(), Note()]);
box.put(Note.construct("Hello world!"));

final text = Note_.text;
final queryNullText = box.query(text.isNull()).build();

assert (queryNullText.count() == 3);

queryNullText.close(); // We have to manually close queries and query builders.
```

More complex queries can be constructed using `and/or` operators.
Also there is basic operator overloading support for `equal`, `greater`, `less`, `and` and `or`,
respectively `==`, `>`, `<`, `&`, `|`.

```dart
final anyGroup = <QueryCondition>[text.equals("meh"), text.equals("bleh"), text.contains("Hello")];
final queryAny = box.queryAny(anyGroup).build();

// equivalent to

box.query(text.equal("meh").or(text.equal("bleh")).or(text.contains("Hello"))).build();

// equivalent to

final overloaded = ((text == "meh") | (text == "bleh")) | text.contains("Hello");
box.query(overloaded as QueryCondition).build(); // the cast is necessary due to the type analyzer
```

Basic technical approach
------------------------
ObjectBox offers a [C API](https://github.com/objectbox/objectbox-c) which can be called by [Dart FFI](https://dart.dev/server/c-interop).
Expand Down
58 changes: 58 additions & 0 deletions bin/objectbox_model_generator/lib/src/code_chunks.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import "package:objectbox/src/modelinfo/index.dart";
import "package:analyzer/dart/element/element.dart";
import "package:objectbox/src/bindings/constants.dart" show OBXPropertyType;
import "package:source_gen/source_gen.dart" show InvalidGenerationSourceError;

class CodeChunks {
static String modelInfoLoader(String allModelsJsonFilename) => """
Expand Down Expand Up @@ -43,4 +46,59 @@ class CodeChunks {
const ${name}_OBXDefs = EntityDefinition<${name}>(_${name}_OBXModelGetter, _${name}_OBXReader, _${name}_OBXBuilder);
""";
}

static String _queryConditionBuilder(ModelEntity readEntity) {
final ret = <String>[];
for (var f in readEntity.properties) {

final name = f.name;

// see OBXPropertyType
String fieldType;
switch(f.type) {
case OBXPropertyType.Bool:
fieldType = "Boolean";
break;
case OBXPropertyType.String:
fieldType = "String";
break;
float:
case OBXPropertyType.Double:
fieldType = "Double";
break;
case OBXPropertyType.Float:
continue float;
integer:
case OBXPropertyType.Int:
fieldType = "Integer";
break;
case OBXPropertyType.Byte:
continue integer;
case OBXPropertyType.Short:
continue integer;
case OBXPropertyType.Char:
continue integer;
case OBXPropertyType.Long:
continue integer;
default:
throw InvalidGenerationSourceError("Unsupported property type (${f.type}): ${readEntity.name}.${name}");
}

ret.add("""
static final ${name}PropertyType = ${f.type};
static final ${name}PropertyId = ${f.id.id};
static final ${name} = Query${fieldType}Property(entityId, ${name}PropertyId, ${name}PropertyType);
""");
}
return ret.join();
}

static String queryConditionClasses(ModelEntity readEntity) {
// TODO add entity.id check to throw an error Box if the wrong entity.property is used
return """
class ${readEntity.name}_ {
static final entityId = ${readEntity.id.id};
${_queryConditionBuilder(readEntity)}
}""";
}
}
10 changes: 9 additions & 1 deletion bin/objectbox_model_generator/lib/src/generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ class EntityGenerator extends GeneratorForAnnotation<obx.Entity> {
flags |= OBXPropertyFlag.ID;
hasIdProperty = true;
} else if (annotType == "Property") {
// nothing special
fieldType = annotVal.getField("type")?.toIntValue();
flags |= annotVal.getField("flag")?.toIntValue();
} else {
// skip unknown annotations
print(
Expand All @@ -93,6 +94,10 @@ class EntityGenerator extends GeneratorForAnnotation<obx.Entity> {
fieldType = OBXPropertyType.Int;
else if (fieldTypeStr == "String")
fieldType = OBXPropertyType.String;
else if (fieldTypeStr == "bool")
fieldType = OBXPropertyType.Bool;
else if (fieldTypeStr == "double")
fieldType = OBXPropertyType.Double;
else {
print(
"warning: skipping field '${f.name}' in entity '${element.name}', as it has the unsupported type '$fieldTypeStr'");
Expand All @@ -119,6 +124,9 @@ class EntityGenerator extends GeneratorForAnnotation<obx.Entity> {
// main code for instance builders and readers
ret += CodeChunks.instanceBuildersReaders(readEntity);

// for building queries
ret += CodeChunks.queryConditionClasses(readEntity);

return ret;
} catch (e, s) {
print(s);
Expand Down
1 change: 1 addition & 0 deletions lib/objectbox.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ export "src/model.dart";
export "src/store.dart";
export "src/box.dart";
export "src/modelinfo/index.dart";
export "src/query/index.dart";
14 changes: 12 additions & 2 deletions lib/src/annotations.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,19 @@ class Entity {
const Entity({this.uid = null});
}

/**
* A dart int value can map to different OBXPropertyTypes,
* e.g. Short (Int16), Int (Int32), Long (Int64), all signed values.
* Also a dart double can also map to e.g. Float and Double
*
* Property allows the mapping to be specific. The defaults are
* e.g. Int -> Int64, double -> Float64, bool -> Bool.
*
* Use OBXPropertyType and OBXPropertyFlag values, resp. for type and flag.
*/
class Property {
final int uid;
const Property({this.uid = null});
final int uid, type, flag;
const Property({this.type = null, this.flag = null, this.uid = null});
}

class Id {
Expand Down
131 changes: 129 additions & 2 deletions lib/src/bindings/bindings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ class _ObjectBoxBindings {
// common functions
void Function(Pointer<Int32> major, Pointer<Int32> minor, Pointer<Int32> patch) obx_version;
Pointer<Uint8> Function() obx_version_string;
void Function(Pointer<Uint64> array) obx_bytes_array_free;
void Function(Pointer<Uint64> structPtr)
obx_bytes_array_free, obx_id_array_free, obx_string_array_free,
obx_int64_array_free, obx_int32_array_free,
obx_int16_array_free, obx_int8_array_free,
obx_double_array_free, obx_float_array_free;

// error info
int Function() obx_last_error_code;
Expand Down Expand Up @@ -59,6 +63,57 @@ class _ObjectBoxBindings {
int Function(Pointer<Void> box, Pointer<Uint64> objects, Pointer<Uint64> ids, int mode) obx_box_put_many;
int Function(Pointer<Void> box, int id) obx_box_remove;

// query builder
obx_query_builder_dart_t obx_qb_create;
obx_qb_close_dart_t obx_qb_close;
obx_qb_close_dart_t obx_qb_error_code;
obx_qb_error_message_t obx_qb_error_message;

obx_qb_cond_operator_0_dart_t obx_qb_null, obx_qb_not_null;

obx_qb_cond_operator_1_dart_t<int>
obx_qb_int_equal, obx_qb_int_not_equal,
obx_qb_int_greater, obx_qb_int_less;

obx_qb_cond_operator_2_dart_t<int> obx_qb_int_between;

obx_qb_cond_operator_in_dart_t<Int64> obx_qb_int64_in, obx_qb_int64_not_in;
obx_qb_cond_operator_in_dart_t<Int32> obx_qb_int32_in, obx_qb_int32_not_in;

obx_qb_cond_string_op_1_dart_t
obx_qb_string_equal,
obx_qb_string_not_equal,
obx_qb_string_contains,
obx_qb_string_starts_with,
obx_qb_string_ends_with;

obx_qb_cond_operator_1_dart_t<double> obx_qb_double_greater, obx_qb_double_less;
obx_qb_cond_operator_2_dart_t<double> obx_qb_double_between;

obx_qb_string_lt_gt_op_dart_t obx_qb_string_greater, obx_qb_string_less;
obx_qb_string_in_dart_t obx_qb_string_in;

obx_qb_bytes_eq_dart_t obx_qb_bytes_equal;
obx_qb_bytes_lt_gt_dart_t obx_qb_bytes_greater, obx_qb_bytes_less;

obx_qb_join_op_dart_t obx_qb_all, obx_qb_any;

obx_qb_param_alias_dart_t obx_qb_param_alias;

obx_qb_order_dart_t obx_qb_order;

// query
obx_query_t obx_query_create;
obx_query_close_dart_t obx_query_close;
obx_query_find_t<int> obx_query_find;
obx_query_find_t<int> obx_query_find_ids;

obx_query_count_dart_t obx_query_count, obx_query_remove;

obx_query_describe_t obx_query_describe, obx_query_describe_params;

obx_query_visit_dart_t obx_query_visit;

// TODO return .asFunction() -> requires properly determined static return type
Pointer<NativeFunction<T>> _fn<T extends Function>(String name) {
return objectbox.lookup<NativeFunction<T>>(name);
Expand All @@ -79,7 +134,15 @@ class _ObjectBoxBindings {
// common functions
obx_version = _fn<obx_version_native_t>("obx_version").asFunction();
obx_version_string = _fn<obx_version_string_native_t>("obx_version_string").asFunction();
obx_bytes_array_free = _fn<obx_bytes_array_free_native_t>("obx_bytes_array_free").asFunction();
obx_bytes_array_free = _fn<obx_free_struct_native_t>("obx_bytes_array_free").asFunction();
obx_id_array_free = _fn<obx_free_struct_native_t>("obx_id_array_free").asFunction();
obx_string_array_free = _fn<obx_free_struct_native_t>("obx_string_array_free").asFunction();
obx_int64_array_free = _fn<obx_free_struct_native_t>("obx_int64_array_free").asFunction();
obx_int32_array_free = _fn<obx_free_struct_native_t>("obx_int32_array_free").asFunction();
obx_int16_array_free = _fn<obx_free_struct_native_t>("obx_int16_array_free").asFunction();
obx_int8_array_free = _fn<obx_free_struct_native_t>("obx_int8_array_free").asFunction();
obx_double_array_free = _fn<obx_free_struct_native_t>("obx_double_array_free").asFunction();
obx_float_array_free = _fn<obx_free_struct_native_t>("obx_float_array_free").asFunction();

// error info
obx_last_error_code = _fn<obx_last_error_code_native_t>("obx_last_error_code").asFunction();
Expand Down Expand Up @@ -126,6 +189,70 @@ class _ObjectBoxBindings {
obx_box_put = _fn<obx_box_put_native_t>("obx_box_put").asFunction();
obx_box_put_many = _fn<obx_box_put_many_native_t>("obx_box_put_many").asFunction();
obx_box_remove = _fn<obx_box_remove_native_t>("obx_box_remove").asFunction();

// query builder
obx_qb_create = _fn<obx_query_builder_native_t>("obx_query_builder").asFunction();
obx_qb_close = _fn<obx_qb_close_native_t>("obx_qb_close").asFunction();
obx_qb_error_code = _fn<obx_qb_close_native_t>("obx_qb_error_code").asFunction();
obx_qb_error_message = _fn<obx_qb_error_message_t>("obx_qb_error_message").asFunction();

obx_qb_null = _fn<obx_qb_cond_operator_0_native_t>("obx_qb_null").asFunction();
obx_qb_not_null = _fn<obx_qb_cond_operator_0_native_t>("obx_qb_not_null").asFunction();

obx_qb_int_equal = _fn<obx_qb_cond_operator_1_native_t<Int64>>("obx_qb_int_equal").asFunction();
obx_qb_int_not_equal = _fn<obx_qb_cond_operator_1_native_t<Int64>>("obx_qb_int_not_equal").asFunction();
obx_qb_int_greater = _fn<obx_qb_cond_operator_1_native_t<Int64>>("obx_qb_int_greater").asFunction();
obx_qb_int_less = _fn<obx_qb_cond_operator_1_native_t<Int64>>("obx_qb_int_less").asFunction();

obx_qb_int_between = _fn<obx_qb_cond_operator_2_native_t<Int64>>("obx_qb_int_between").asFunction();

obx_qb_int64_in = _fn<obx_qb_cond_operator_in_native_t<Int64>>("obx_qb_int64_in").asFunction();
obx_qb_int64_not_in = _fn<obx_qb_cond_operator_in_native_t<Int64>>("obx_qb_int64_not_in").asFunction();

obx_qb_int32_in = _fn<obx_qb_cond_operator_in_native_t<Int32>>("obx_qb_int32_in").asFunction();
obx_qb_int32_not_in = _fn<obx_qb_cond_operator_in_native_t<Int32>>("obx_qb_int32_not_in").asFunction();

obx_qb_string_equal = _fn<obx_qb_cond_string_op_1_native_t>("obx_qb_string_equal").asFunction();
obx_qb_string_not_equal = _fn<obx_qb_cond_string_op_1_native_t>("obx_qb_string_not_equal").asFunction();
obx_qb_string_contains = _fn<obx_qb_cond_string_op_1_native_t>("obx_qb_string_contains").asFunction();

obx_qb_string_starts_with = _fn<obx_qb_cond_string_op_1_native_t>("obx_qb_string_starts_with").asFunction();
obx_qb_string_ends_with = _fn<obx_qb_cond_string_op_1_native_t>("obx_qb_string_ends_with").asFunction();

obx_qb_string_greater = _fn<obx_qb_string_lt_gt_op_native_t>("obx_qb_string_greater").asFunction();
obx_qb_string_less = _fn<obx_qb_string_lt_gt_op_native_t>("obx_qb_string_less").asFunction();

obx_qb_string_in = _fn<obx_qb_string_in_native_t>("obx_qb_string_in").asFunction();

obx_qb_double_greater = _fn<obx_qb_cond_operator_1_native_t<Double>>("obx_qb_double_greater").asFunction();
obx_qb_double_less = _fn<obx_qb_cond_operator_1_native_t<Double>>("obx_qb_double_less").asFunction();

obx_qb_double_between = _fn<obx_qb_cond_operator_2_native_t<Double>>("obx_qb_double_between").asFunction();

obx_qb_bytes_equal = _fn<obx_qb_bytes_eq_native_t>("obx_qb_bytes_equal").asFunction();
obx_qb_bytes_greater = _fn<obx_qb_bytes_lt_gt_native_t>("obx_qb_bytes_greater").asFunction();
obx_qb_bytes_less = _fn<obx_qb_bytes_lt_gt_native_t>("obx_qb_bytes_less").asFunction();

obx_qb_all = _fn<obx_qb_join_op_native_t>("obx_qb_all").asFunction();
obx_qb_any = _fn<obx_qb_join_op_native_t>("obx_qb_any").asFunction();

obx_qb_param_alias = _fn<obx_qb_param_alias_native_t>("obx_qb_param_alias").asFunction();

obx_qb_order = _fn<obx_qb_order_native_t>("obx_qb_order").asFunction();

// query
obx_query_create = _fn<obx_query_t>("obx_query").asFunction();
obx_query_close = _fn<obx_query_close_native_t>("obx_query_close").asFunction();

obx_query_find_ids = _fn<obx_query_find_t<Uint64>>("obx_query_find_ids").asFunction();
obx_query_find = _fn<obx_query_find_t<Uint64>>("obx_query_find").asFunction();

obx_query_count = _fn<obx_query_count_native_t>("obx_query_count").asFunction();
obx_query_remove = _fn<obx_query_count_native_t>("obx_query_remove").asFunction();
obx_query_describe = _fn<obx_query_describe_t>("obx_query_describe").asFunction();
obx_query_describe_params = _fn<obx_query_describe_t>("obx_query_describe_params").asFunction();

obx_query_visit = _fn<obx_query_visit_native_t>("obx_query_visit").asFunction();
}
}

Expand Down
22 changes: 22 additions & 0 deletions lib/src/bindings/constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,25 @@ class OBXError {
/// A requested schema object (e.g. entity or property) was not found in the schema
static const int OBX_ERROR_SCHEMA_OBJECT_NOT_FOUND = 10503;
}

// query builder

class OBXOrderFlag {
/// Reverts the order from ascending (default) to descending.
static final DESCENDING = 1;

/// Makes upper case letters (e.g. "Z") be sorted before lower case letters (e.g. "a").
/// If not specified, the default is case insensitive for ASCII characters.
static final CASE_SENSITIVE = 2;

/// For scalars only: changes the comparison to unsigned (default is signed).
static final UNSIGNED = 4;

/// null values will be put last.
/// If not specified, by default null values will be put first.
static final NULLS_LAST = 8;

/// null values should be treated equal to zero (scalars only).
static final NULLS_ZERO = 16;
}

12 changes: 12 additions & 0 deletions lib/src/bindings/flatbuffers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ class OBXFlatbuffersManager<T> {
case OBXPropertyType.String:
builder.addOffset(field, offsets[p.name]);
break;
case OBXPropertyType.Float:
builder.addFloat32(field, value);
break;
case OBXPropertyType.Double:
builder.addFloat64(field, value);
break;
default:
throw Exception("unsupported type: ${p.type}"); // TODO: support more types
}
Expand Down Expand Up @@ -111,6 +117,12 @@ class OBXFlatbuffersManager<T> {
case OBXPropertyType.String:
propReader = fb.StringReader();
break;
case OBXPropertyType.Float:
propReader = fb.Float32Reader();
break;
case OBXPropertyType.Double:
propReader = fb.Float64Reader();
break;
default:
throw Exception("unsupported type: ${p.type}"); // TODO: support more types
}
Expand Down
Loading