summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Beyer <matthias.beyer@atos.net>2021-01-11 10:24:57 +0100
committerMatthias Beyer <matthias.beyer@atos.net>2021-01-14 13:29:41 +0100
commit4a92855656e30ca4d22531eb41f263afa607d1f3 (patch)
tree0026f74ce95b29449dfdfc622fc7004a1138ffc4
parent7c40da3f5e15d52183500e1b48aab79415ecea7a (diff)
Fix: Submit is associated with Package and Image
Make sure the inner_join() in the "submits" command implementation joins on the jobs table, not on the packages table. Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
-rw-r--r--src/commands/db.rs3
-rw-r--r--src/db/models/submit.rs5
2 files changed, 5 insertions, 3 deletions
diff --git a/src/commands/db.rs b/src/commands/db.rs
index 9f438c9..b69d733 100644
--- a/src/commands/db.rs
+++ b/src/commands/db.rs
@@ -226,8 +226,7 @@ fn submits(conn_cfg: DbConnectionConfig, matches: &ArgMatches) -> Result<()> {
let data = if let Some(pkgname) = matches.value_of("with_pkg").map(String::from) {
schema::packages::table
.filter(schema::packages::name.eq(pkgname))
- .inner_join(schema::jobs::table)
- .inner_join(schema::submits::table)
+ .inner_join(schema::jobs::table.inner_join(schema::submits::table))
.select(schema::submits::all_columns)
.load::<models::Submit>(&conn)?
} else {
diff --git a/src/db/models/submit.rs b/src/db/models/submit.rs
index e6bc8af..63f72b1 100644
--- a/src/db/models/submit.rs
+++ b/src/db/models/submit.rs
@@ -22,7 +22,10 @@ use crate::db::models::Package;
use crate::schema::submits::*;
use crate::schema::submits;
-#[derive(Clone, Debug, Identifiable, Queryable)]
+#[derive(Clone, Debug, Identifiable, Queryable, Associations)]
+#[belongs_to(Package, foreign_key = "requested_package_id")]
+#[belongs_to(Image, foreign_key = "requested_image_id")]
+#[table_name="submits"]
pub struct Submit {
pub id: i32,
pub uuid: ::uuid::Uuid,