-
Notifications
You must be signed in to change notification settings - Fork 192
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
Return last inserted ID/s #44
Comments
* Add configuration files * Add submodules example and floor generator * Add license (#14) * Add code generation for database creation (#13) Resolves #2 * Add static function to instantiate database (#15) * Add code generator for query methods (#17) * Singularize directory names (#18) * Database writer improvements (#19) * Add insert methods code generation (#20) * Add update methods code generation (#21) * Add delete methods code generation and fix update methods (#22) * Improve change method generators (#24) * Add test setup and test for type utils (#26) * Add Travis CI config (#27) * Update README with note to not use the library (#28) * Cleanup code and add simple string escaping in SQL statements (#29) * Return empty list of empty list query result (#32) * Add database tests (#34) * Fix grammar in README (#35) * Exclude hashCode from mapping (#38) * Enable custom column name mapping (#39) * Enable NOT NULL columns (#40) * Support custom entity name (#41) * Add support for changing (insert, update, delete) lists (#42) * Add LICENSE file (#43) * Add support for transactions (#49) * Return ID/s of inserted item/s (#51) #44 * Return updated rows count on update (#52) * Return deleted row count on delete (#53) * Only use async modifier when necessary (#54) * Make all method/constructor parameters final (#55) * Cleanup example app (#56) * Add parameter verification for query methods (#57) Resolves #50. * Add support for foreign keys (#59) * Add documentation on how to use the library (#60) * Add support for running queries that return void (#61) * Generate CREATE TABLE statements in models instead of writer (#63) * Update README (#64) * Add release drafter configuration (#65) * Update dependencies (#66) * Support conflict strategies when inserting or updating records (#67) * Move annotations to separate module to make the generator testable (#68) * Enable CI (analyzer, dartfmt) for annotations module (#69) * Add more tests for insert method writer, database writer (#71) * Update version number to 0.1.0 (#72) * Update README (#73) * Add support for migrations (#74) Resolves #8. * Add database adapters (#75) * Run Flutter tests on CI (#76) * Add support for returning Streams as query result (#77) * Add CHANGELOG (#78) * Support accessing data from Data Access Objects (#82) * Move value objects to value_objects directory (#83) * Map elements into value objects in processors (#85) * Add entity classes to database annotation (#86) * Add files for release (#89)
This feature is already available in last version 0.12.0? If yes, how can I perform it? |
You can use @insert
Future<int> insertPerson(Person person); will return a primary id which was generated and used by sqlite. See also the README |
In the previous version if I am not wrong the returned int value was 0 or 1 (true or false), just to represent if the insert/update were done/committed without errors. Now it's pretty better providing the accuracy ID information. But seems to be an issue in @update annotation. In @update the floor API seems to returning always 1 instead of the ID. In @insert it's Ok returning the correct Id. #personDao.dart #instantiating the dao In that case, the id is always == 1, instead of the committed _person.id |
In the case of
And this is (at least from my PoV) the amount of rows that were changed by the operation, just like the titles of the referenced PRs indicate. If you want the id of your updated row(s), look inside the id field of the Entity you provided to the update function, as this will not be changed(in the db and in your app) by either update nor delete operations. |
@mqus ok, it was very clear. Really this way similar to Room got better, thks! |
And honestly, if you had read the README link I gave you, this would have been obvious:
|
Yeap indeed. I didn't understand correctly. It's very clear in docs! |
Whenever inserting objects open up the possibility to return the inserted ID or IDs in case a list is getting inserted.
Investigate what Room returns on update and delete and decide if support these as well.
The text was updated successfully, but these errors were encountered: