Skip to content

Commit

Permalink
fix use of postgres keyword order
Browse files Browse the repository at this point in the history
  • Loading branch information
KavikaPalletenne committed Nov 5, 2024
1 parent 2d1eef7 commit 0e83c99
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion backend/migrations/20240406031400_create_questions.sql
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ CREATE TABLE multi_option_question_options (
id BIGINT PRIMARY KEY,
text TEXT NOT NULL,
question_id BIGINT NOT NULL,
order INTEGER NOT NULL,
display_order INTEGER NOT NULL,
CONSTRAINT FK_multi_option_question_options_questions
FOREIGN KEY(question_id)
REFERENCES questions(id)
Expand Down
12 changes: 6 additions & 6 deletions backend/server/src/models/question.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@ use snowflake::SnowflakeIdGenerator;
/// "options": [
/// {
/// "id": 7233828375387640938,
/// "order": 1,
/// "display_order": 1,
/// "text": "Rust"
/// },
/// {
/// "id": 7233828375387640954,
/// "order": 2,
/// "display_order": 2,
/// "text": "Java"
/// },
/// {
/// "id": 7233828375387640374,
/// "order": 3,
/// "display_order": 3,
/// "text": "TypeScript"
/// }
/// ]
Expand Down Expand Up @@ -82,7 +82,7 @@ pub struct MultiOptionData {
#[derive(Deserialize, Serialize)]
pub struct MultiOptionQuestionOption {
id: i32,
order: i32,
display_order: i32,
text: String,
}

Expand Down Expand Up @@ -111,11 +111,11 @@ impl QuestionData {
| Self::DropDown(data)
| Self::Ranking(data) => {
let mut query_builder =
QueryBuilder::new("INSERT INTO multi_option_question_options (id, text, question_id, order)");
QueryBuilder::new("INSERT INTO multi_option_question_options (id, text, question_id, display_order)");

query_builder.push_values(data.options, |mut b, option| {
let id = snowflake_generator.real_time_generate();
b.push_bind(id).push_bind(option.text).push_bind(question_id).push_bind(option.order);
b.push_bind(id).push_bind(option.text).push_bind(question_id).push_bind(option.display_order);
});

let query = query_builder.build();
Expand Down

0 comments on commit 0e83c99

Please sign in to comment.