Skip to content
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

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from

Conversation

R0drig0-P
Copy link

@R0drig0-P R0drig0-P commented Nov 3, 2024

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

  • Terms and conditions reflect the current change
  • Contains enough appropriate tests
  • If aimed at production, writes a new summary in whatsnew/whatsnew-pt-PT
  • Properly adds an entry in changelog.md with the change
  • If PR includes UI updates/additions, its description has screenshots
  • Behavior is as expected
  • Clean, well-structured code

Copy link

codecov bot commented Nov 3, 2024

Codecov Report

Attention: Patch coverage is 0% with 13 lines in your changes missing coverage. Please review.

Project coverage is 12%. Comparing base (249fc86) to head (8e21cd3).
Report is 2 commits behind head on develop.

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     

@DGoiana DGoiana requested a review from a team November 3, 2024 21:20
@R0drig0-P R0drig0-P force-pushed the fix/meals-column-not-in-restaurant-table branch from 2eb7ba4 to 9da87ef Compare November 4, 2024 14:44
created a new column named meals and changed the way of inserting the restaurant and meals in the database
@R0drig0-P R0drig0-P force-pushed the fix/meals-column-not-in-restaurant-table branch from f14947b to ae1186c Compare November 5, 2024 23:01
@@ -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());
Copy link
Member

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 method
  • Restaurant.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

@R0drig0-P R0drig0-P marked this pull request as draft November 8, 2024 21:55
@R0drig0-P R0drig0-P marked this pull request as ready for review November 20, 2024 18:27
@thePeras thePeras requested review from a team and thePeras December 6, 2024 21:50
@thePeras thePeras mentioned this pull request Dec 9, 2024
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DatabaseException - table RESTAURANTS
2 participants