-
-
Notifications
You must be signed in to change notification settings - Fork 64
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
Autoincrement Key type and stringMapStoreFactory #304
Comments
That's definitely a bug. Yes the key returned should be a string. Do you have a way to reproduce it? Here is a simple test showing that it returns an int if the factory is intMapStoreFactory and a string if the factory is stringMapStoreFactory: import 'package:sembast/sembast.dart';
import 'package:sembast/sembast_memory.dart';
import 'package:test/test.dart';
void main() {
test('add type', () async {
var factory = newDatabaseFactoryMemory();
var db = await factory.openDatabase('test_add');
var intKeyStore1 = intMapStoreFactory.store('store1');
var stringKeyStore2 = stringMapStoreFactory.store('store2');
var key1 = await intKeyStore1.add(db, {'test': 'value1'});
var key2 = await stringKeyStore2.add(db, {'test': 'value1'});
// key1 should be an int, key2 should be a string
expect(key1, const TypeMatcher<int>());
expect(key2, const TypeMatcher<String>());
});
} |
Version: sembast: ^3.1.2 The code: DB init:
Adding an item:
The trace: |
Arg. It should even crash before as the return type of .add is String. Which flutter version are you using (and can you ensure that you have the lints and null safety enabled) ? Can you manage to reproduce in a unit test as I show above? (Sorry to ask but I cannot image how it can happen so far) |
I don't know if it is a bug or not but
When using a stringMapStoreFactory, the key returned after a "store.add(_db, )" is of int type.
I was thinking the returned key type would by String.
The documentation is not clear on this topic.
Can you please advice ?
The text was updated successfully, but these errors were encountered: