Skip to content

Commit

Permalink
fix enum errors
Browse files Browse the repository at this point in the history
  • Loading branch information
KavikaPalletenne committed Nov 5, 2024
1 parent 6d9f8f1 commit 06efb2c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
4 changes: 2 additions & 2 deletions backend/server/src/models/answer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ impl AnswerData {

pub async fn insert_into_db(self, answer_id: i64, pool: &Pool<Postgres>) -> Result<()> {
match self {
Self::ShortAnswer => {
Self::ShortAnswer(text) => {
let result = sqlx::query!(
"INSERT INTO short_answer_answers (text, answer_id) VALUES ($1, $2)",
self.text,
text,
answer_id
)
.execute(pool)
Expand Down
6 changes: 2 additions & 4 deletions backend/server/src/models/question.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,9 @@ impl QuestionData {
let mut query_builder =
QueryBuilder::new("INSERT INTO multi_option_question_options (id, text, question_id, rank)");

let mut rank = 1;
query_builder.push_values(self.options, |mut b, option| {
query_builder.push_values(data.options, |mut b, option| {
let id = snowflake_generator.real_time_generate();
b.push_bind(id).push_bind(option).push_bind(question_id).push_bind(rank);
rank += 1;
b.push_bind(id).push_bind(option.text).push_bind(question_id).push_bind(option.rank);
});

let query = query_builder.build();
Expand Down

0 comments on commit 06efb2c

Please sign in to comment.