-
Notifications
You must be signed in to change notification settings - Fork 18
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
fix: Added meals column to the RESTAURANTS table #1380
base: develop
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #1380 +/- ##
=======================================
- Coverage 12% 12% -0%
=======================================
Files 266 266
Lines 7201 7212 +11
=======================================
Hits 806 806
- Misses 6395 6406 +11 |
2eb7ba4
to
9da87ef
Compare
created a new column named meals and changed the way of inserting the restaurant and meals in the database
f14947b
to
ae1186c
Compare
@@ -104,7 +111,15 @@ class RestaurantDatabase extends AppDatabase<List<Restaurant>> { | |||
|
|||
/// Insert restaurant and meals in database | |||
Future<void> insertRestaurant(Transaction txn, Restaurant restaurant) async { | |||
final id = await txn.insert('RESTAURANTS', restaurant.toJson()); |
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.
If you see the sentry catch (ask permission to enter), the problem originates here because Restaurants
table has different attributes than resturant.toJson()
. Look at the Restaurant Model, you easily see the meals
property, which is defined as @JsonKey
.
This problem could be easily fixed if you just remove meals key
from restaurant.toJson()
returned object and insert the filtered restaurant to database. As you can see, there is another table called meals
which will deal with the meals as a one-to-many relationship.
However, since you already started to add meals to restaurants table and we recently implement serialization, we can go further with your solution!
Delete dead code:
- meals table
getRestaurantMeals
methodRestaurant.fromMap()
, whereRestaurant.fromJson()
already done the job
Make all the adjustments you need to make it work!
Feel free to send me a message on Slack for help
@@ -104,7 +111,15 @@ class RestaurantDatabase extends AppDatabase<List<Restaurant>> { | |||
|
|||
/// Insert restaurant and meals in database | |||
Future<void> insertRestaurant(Transaction txn, Restaurant restaurant) async { | |||
final id = await txn.insert('RESTAURANTS', restaurant.toJson()); | |||
final mealsJson = jsonEncode(restaurant.meals); |
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.
No need for jsonEncode()
you have restaurant.toJson()
method!
Closes #1370
Created a new column for meals in RESTAURANTS table and changed the way of inserting the restaurant and meals in the database.
Review checklist
whatsnew/whatsnew-pt-PT
changelog.md
with the change