Commit f2bf568f authored by Robert Czechowski's avatar Robert Czechowski

Fix: Set min_grade and max_grade when saving contest. Was forgotten when...

Fix: Set min_grade and max_grade when saving contest. Was forgotten when rebasing branch cleanup_db_connectors on top of min-max-grade
parent fadffc92
......@@ -111,8 +111,9 @@ impl MedalObject<Connection> for Contest {
let id = match self.get_id() {
Some(id) => {
let query = "UPDATE contest
SET location = $1,filename = $2, name = $3, duration = $4, public = $5, start_date = $6, end_date = $7
WHERE id = $8";
SET location = $1,filename = $2, name = $3, duration = $4, public = $5, start_date = $6,
end_date = $7, min_grade = $8, max_grade = $9
WHERE id = $10";
conn.execute(query,
&[&self.location,
&self.filename,
......@@ -121,13 +122,16 @@ impl MedalObject<Connection> for Contest {
&self.public,
&self.start,
&self.end,
&self.min_grade,
&self.max_grade,
&id])
.unwrap();
id
}
None => {
let query = "INSERT INTO contest (location, filename, name, duration, public, start_date, end_date)
VALUES ($1, $2, $3, $4, $5, $6, $7)";
let query = "INSERT INTO contest (location, filename, name, duration, public, start_date, end_date,
min_grade, max_grade)
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)";
conn.execute(query,
&[&self.location,
&self.filename,
......@@ -135,7 +139,9 @@ impl MedalObject<Connection> for Contest {
&self.duration,
&self.public,
&self.start,
&self.end])
&self.end,
&self.min_grade,
&self.max_grade])
.unwrap();
conn.get_last_id().unwrap()
}
......
......@@ -207,8 +207,9 @@ impl MedalObject<Connection> for Contest {
let id = match self.get_id() {
Some(id) => {
let query = "UPDATE contest
SET location = $1,filename = $2, name = $3, duration = $4, public = $5, start_date = $6, end_date = $7
WHERE id = $8";
SET location = $1,filename = $2, name = $3, duration = $4, public = $5, start_date = $6,
end_date = $7, min_grade = $8, max_grade = $9
WHERE id = $10";
conn.execute(query,
&[&self.location,
&self.filename,
......@@ -217,13 +218,16 @@ impl MedalObject<Connection> for Contest {
&self.public,
&self.start,
&self.end,
&self.min_grade,
&self.max_grade,
&id])
.unwrap();
id
}
None => {
let query = "INSERT INTO contest (location, filename, name, duration, public, start_date, end_date)
VALUES ($1, $2, $3, $4, $5, $6, $7)";
let query = "INSERT INTO contest (location, filename, name, duration, public, start_date, end_date,
min_grade, max_grade)
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)";
conn.execute(query,
&[&self.location,
&self.filename,
......@@ -231,7 +235,9 @@ impl MedalObject<Connection> for Contest {
&self.duration,
&self.public,
&self.start,
&self.end])
&self.end,
&self.min_grade,
&self.max_grade])
.unwrap();
conn.get_last_id().unwrap()
}
......
......@@ -194,8 +194,9 @@ impl MedalObject<Connection> for Contest {
let id = match self.get_id() {
Some(id) => {
let query = "UPDATE contest
SET location = ?1,filename = ?2, name = ?3, duration = ?4, public = ?5, start_date = ?6, end_date = ?7
WHERE id = ?8";
SET location = ?1,filename = ?2, name = ?3, duration = ?4, public = ?5, start_date = ?6,
end_date = ?7, min_grade = ?8, max_grade = ?9
WHERE id = ?10";
conn.execute(query,
&[&self.location,
&self.filename,
......@@ -204,13 +205,16 @@ impl MedalObject<Connection> for Contest {
&self.public,
&self.start,
&self.end,
&self.min_grade,
&self.max_grade,
&id])
.unwrap();
id
}
None => {
let query = "INSERT INTO contest (location, filename, name, duration, public, start_date, end_date)
VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7)";
let query = "INSERT INTO contest (location, filename, name, duration, public, start_date, end_date,
min_grade, max_grade)
VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9)";
conn.execute(query,
&[&self.location,
&self.filename,
......@@ -218,7 +222,9 @@ impl MedalObject<Connection> for Contest {
&self.duration,
&self.public,
&self.start,
&self.end])
&self.end,
&self.min_grade,
&self.max_grade])
.unwrap();
conn.get_last_id().unwrap()
}
......
......@@ -207,8 +207,9 @@ impl MedalObject<Connection> for Contest {
let id = match self.get_id() {
Some(id) => {
let query = "UPDATE contest
SET location = ?1,filename = ?2, name = ?3, duration = ?4, public = ?5, start_date = ?6, end_date = ?7
WHERE id = ?8";
SET location = ?1,filename = ?2, name = ?3, duration = ?4, public = ?5, start_date = ?6,
end_date = ?7, min_grade = ?8, max_grade = ?9
WHERE id = ?10";
conn.execute(query,
&[&self.location,
&self.filename,
......@@ -217,13 +218,16 @@ impl MedalObject<Connection> for Contest {
&self.public,
&self.start,
&self.end,
&self.min_grade,
&self.max_grade,
&id])
.unwrap();
id
}
None => {
let query = "INSERT INTO contest (location, filename, name, duration, public, start_date, end_date)
VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7)";
let query = "INSERT INTO contest (location, filename, name, duration, public, start_date, end_date,
min_grade, max_grade)
VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9)";
conn.execute(query,
&[&self.location,
&self.filename,
......@@ -231,7 +235,9 @@ impl MedalObject<Connection> for Contest {
&self.duration,
&self.public,
&self.start,
&self.end])
&self.end,
&self.min_grade,
&self.max_grade])
.unwrap();
conn.get_last_id().unwrap()
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment