Added additional name filed to article.

This commit is contained in:
2026-02-25 15:49:42 +01:00
parent ba5ebc3524
commit 75a178cbf4
7 changed files with 46 additions and 5 deletions
+7 -2
View File
@@ -22,6 +22,7 @@ pub struct Article {
pub allergens_text: Option<String>,
pub bio_info: Option<String>,
pub topm_id: Option<String>,
pub additional_name: Option<String>,
}
fn from_postgres_row_small(row: PgRow) -> Article {
@@ -39,6 +40,7 @@ fn from_postgres_row_small(row: PgRow) -> Article {
allergens_text: row.get(9),
bio_info: row.get(10),
topm_id: row.get(11),
additional_name: row.get(12),
}
}
@@ -70,6 +72,7 @@ async fn from_postgres_row(row: PgRow, pool: PgPool) -> Article {
allergens_text: row.get(9),
bio_info: row.get(10),
topm_id: row.get(11),
additional_name: row.get(12),
}
}
@@ -141,9 +144,10 @@ pub async fn insert_article(article: &Article, pool: PgPool) -> Option<Article>
args.add(&article.allergens_text);
args.add(&article.bio_info);
args.add(&article.topm_id);
args.add(&article.additional_name);
let statement = format!(
"INSERT INTO {} (name, bio, origin, description, ingredients, default_unit_id, mhd, bio_origin, allergens_text, bio_info, topm_id) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11) RETURNING *",
"INSERT INTO {} (name, bio, origin, description, ingredients, default_unit_id, mhd, bio_origin, allergens_text, bio_info, topm_id, additional_name) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12) RETURNING *",
"article",
);
@@ -181,9 +185,10 @@ pub async fn update_article(article_id: i64, article: &Article, pool: PgPool) ->
args.add(&article.allergens_text);
args.add(&article.bio_info);
args.add(&article.topm_id);
args.add(&article.additional_name);
let statement = format!(
"UPDATE {} SET name = $2, bio = $3, origin = $4, description = $5, ingredients = $6, default_unit_id = $7, mhd = $8, bio_origin = $9, allergens_text = $10, bio_info = $11, topm_id = $12 WHERE id = $1 RETURNING *",
"UPDATE {} SET name = $2, bio = $3, origin = $4, description = $5, ingredients = $6, default_unit_id = $7, mhd = $8, bio_origin = $9, allergens_text = $10, bio_info = $11, topm_id = $12, additional_name = $13 WHERE id = $1 RETURNING *",
"article",
);