connell-class / revassess

this is a trial repo for making a template for the revature assessment
2 stars 11 forks source link

Tier 2 Test 4 model has different names than ERD table #16

Closed theo-gherman closed 4 years ago

theo-gherman commented 4 years ago

Describe the bug The model has different names that the ERD table. The Model defined at RevassessTier2\src\main\java\com\tier2\model\UserProblem4.java contains String username, String set_name, String category_name, String question, String answer But the ERD table column names do not correspond.

In order for the test to work the user is supposed to rename the columns in the query:

select app_user.username, study_set.name as set_name, category.name as category_name, flashcard.question, flashcard.answer from app_user inner join study_set on app_user.user_id = study_set.owner_id inner join study_set_card on study_set.study_set_id = study_set_card.study_set_id inner join flashcard on study_set_card.flashcard_id = flashcard.flashcard_id inner join category on flashcard.category_id = category.category_id where study_set.study_set_id =4;

because the category table has column name, not category_name and study_set table has column name, not set_name

Expected behavior The expected query should work without renaming the columns: select app_user.username, study_set.name, category.name, flashcard.question, flashcard.answer from app_user inner join study_set on app_user.user_id = study_set.owner_id inner join study_set_card on study_set.study_set_id = study_set_card.study_set_id inner join flashcard on study_set_card.flashcard_id = flashcard.flashcard_id inner join category on flashcard.category_id = category.category_id where study_set.study_set_id =4;

But this would create a conflict in the model because two variables have the name "name"

The solution might be to rename the columns in the ERD table

connellrobert commented 4 years ago

@theo-gherman Please try this. I did it with the template and it seemed to work, but not sure if its resilient.

add @Column(name = "name", insertable = false, updatable = false) above the set_name and category_name in com.tier2.model.UserProblem4.java.

I also ran into another problem with semi colons in the SQL script. On line 31, use this: answer4Contents = getFileContents("answer4").replace(';', ' ');

Let me know how these work for you and we can hopefully close this issue.