Updated dependencies and adjusted code to update.
This commit is contained in:
+4
-4
@@ -7,11 +7,11 @@ authors = ["Matthias Lodner <matthias@lodner.de>"]
|
||||
[dependencies]
|
||||
# Deserialize/Serialize
|
||||
serde = { version = "1.0.228", features = ["derive"] }
|
||||
serde_json = "1.0.149"
|
||||
serde_json = "1.0.150"
|
||||
|
||||
# Database
|
||||
sqlx = { version = "0.8.6", features = [ "runtime-async-std-native-tls", "postgres", "chrono" ] }
|
||||
sqlx = { version = "0.9.0", features = [ "runtime-async-std", "postgres", "chrono" ] }
|
||||
|
||||
# Etc.
|
||||
chrono = { version = "0.4.44", features = [ "serde" ] }
|
||||
log = "0.4.29"
|
||||
chrono = { version = "0.4.45", features = [ "serde" ] }
|
||||
log = "0.4.32"
|
||||
|
||||
@@ -2,7 +2,7 @@ use serde::{Deserialize, Serialize};
|
||||
use sqlx::{FromRow, PgPool};
|
||||
use crate::models::origin::Origin;
|
||||
use crate::models::variant::{load_article_variants, Variant};
|
||||
use sqlx::{Arguments, Pool, Row, Postgres, Error};
|
||||
use sqlx::{Arguments, Pool, Row, Postgres, Error, AssertSqlSafe};
|
||||
use sqlx::postgres::{PgArguments, PgQueryResult, PgRow};
|
||||
use log::{debug, error, info};
|
||||
use crate::models::unit::Unit;
|
||||
@@ -83,7 +83,7 @@ pub async fn load_articles(pool: PgPool) -> Option<Vec<Article>> {
|
||||
);
|
||||
|
||||
let res = sqlx::query(
|
||||
statement.as_str())
|
||||
AssertSqlSafe(statement.as_str()))
|
||||
.fetch_all(&pool).await;
|
||||
|
||||
let mut articles: Vec<Article> = Vec::new();
|
||||
@@ -115,7 +115,7 @@ pub async fn load_article(id: i64, pool: PgPool) -> Option<Article> {
|
||||
args.add(id);
|
||||
|
||||
let res = sqlx::query_with(
|
||||
statement.as_str(), args)
|
||||
AssertSqlSafe(statement.as_str()), args)
|
||||
.fetch_one(&pool).await;
|
||||
|
||||
match res {
|
||||
@@ -152,7 +152,7 @@ pub async fn insert_article(article: &Article, pool: PgPool) -> Option<Article>
|
||||
);
|
||||
|
||||
let res = sqlx::query_with(
|
||||
statement.as_str(),
|
||||
AssertSqlSafe(statement.as_str()),
|
||||
args)
|
||||
.fetch_one(&pool).await;
|
||||
|
||||
@@ -193,7 +193,7 @@ pub async fn update_article(article_id: i64, article: &Article, pool: PgPool) ->
|
||||
);
|
||||
|
||||
let res = sqlx::query_with(
|
||||
statement.as_str(),
|
||||
AssertSqlSafe(statement.as_str()),
|
||||
args)
|
||||
.fetch_one(&pool).await;
|
||||
|
||||
@@ -213,10 +213,10 @@ pub async fn update_article(article_id: i64, article: &Article, pool: PgPool) ->
|
||||
|
||||
pub async fn delete_article(article_id: i64, pool: PgPool) -> Option<()> {
|
||||
let result = sqlx::query(
|
||||
format!("DELETE FROM {} WHERE id = {}",
|
||||
AssertSqlSafe(format!("DELETE FROM {} WHERE id = {}",
|
||||
"article",
|
||||
article_id
|
||||
).as_str()
|
||||
).as_str())
|
||||
).execute(&pool).await;
|
||||
|
||||
match result {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use log::{error, info};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use sqlx::{Arguments, Decode, Encode, FromRow, PgPool, Row};
|
||||
use sqlx::{Arguments, AssertSqlSafe, Decode, Encode, FromRow, PgPool, Row};
|
||||
use sqlx::postgres::{PgArguments, PgRow};
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize, Clone, FromRow, Decode, Encode)]
|
||||
@@ -23,7 +23,7 @@ pub async fn load_labels(pool: PgPool) -> Option<Vec<Label>> {
|
||||
);
|
||||
|
||||
let res = sqlx::query(
|
||||
statement.as_str())
|
||||
AssertSqlSafe(statement.as_str()))
|
||||
.fetch_all(&pool).await;
|
||||
|
||||
let mut labels: Vec<Label> = Vec::new();
|
||||
@@ -55,7 +55,7 @@ pub async fn load_label(id: i64, pool: &PgPool) -> Option<Label> {
|
||||
args.add(id);
|
||||
|
||||
let res = sqlx::query_with(
|
||||
statement.as_str(), args)
|
||||
AssertSqlSafe(statement.as_str()), args)
|
||||
.fetch_one(pool).await;
|
||||
|
||||
match res {
|
||||
@@ -79,7 +79,7 @@ pub async fn insert_label(label: &Label, pool: PgPool) -> Option<Label> {
|
||||
);
|
||||
|
||||
let res = sqlx::query_with(
|
||||
statement.as_str(),
|
||||
AssertSqlSafe(statement.as_str()),
|
||||
args)
|
||||
.fetch_one(&pool).await;
|
||||
|
||||
@@ -109,7 +109,7 @@ pub async fn update_label(label_id: i64, label: &Label, pool: PgPool) -> Option<
|
||||
);
|
||||
|
||||
let res = sqlx::query_with(
|
||||
statement.as_str(),
|
||||
AssertSqlSafe(statement.as_str()),
|
||||
args)
|
||||
.fetch_one(&pool).await;
|
||||
|
||||
@@ -129,10 +129,10 @@ pub async fn update_label(label_id: i64, label: &Label, pool: PgPool) -> Option<
|
||||
|
||||
pub async fn delete_label(label_id: i64, pool: PgPool) -> Option<()> {
|
||||
let result = sqlx::query(
|
||||
format!("DELETE FROM {} WHERE id = {}",
|
||||
AssertSqlSafe(format!("DELETE FROM {} WHERE id = {}",
|
||||
"label",
|
||||
label_id
|
||||
).as_str()
|
||||
).as_str())
|
||||
).execute(&pool).await;
|
||||
|
||||
match result {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use log::{error, info};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use sqlx::{Arguments, Decode, Encode, FromRow, PgPool, Row};
|
||||
use sqlx::{Arguments, AssertSqlSafe, Decode, Encode, FromRow, PgPool, Row};
|
||||
use sqlx::postgres::{PgArguments, PgRow};
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize, Clone, FromRow, Decode, Encode)]
|
||||
@@ -29,7 +29,7 @@ pub async fn load_settings(pool: &PgPool) -> Option<Settings> {
|
||||
);
|
||||
|
||||
let res = sqlx::query(
|
||||
statement.as_str())
|
||||
AssertSqlSafe(statement.as_str()))
|
||||
.fetch_one(pool).await;
|
||||
|
||||
match res {
|
||||
@@ -57,7 +57,7 @@ pub async fn update_settings(settings: &Settings, pool: PgPool) -> Option<Settin
|
||||
);
|
||||
|
||||
let res = sqlx::query_with(
|
||||
statement.as_str(),
|
||||
AssertSqlSafe(statement.as_str()),
|
||||
args)
|
||||
.fetch_one(&pool).await;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use log::{error, info};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use sqlx::{Arguments, FromRow, PgPool, Row};
|
||||
use sqlx::{Arguments, AssertSqlSafe, FromRow, PgPool, Row};
|
||||
use sqlx::postgres::{PgArguments, PgRow};
|
||||
use crate::models::label::{load_label, Label};
|
||||
use crate::models::unit::Unit;
|
||||
@@ -54,7 +54,7 @@ pub async fn load_article_variants(article_id: i64, pool: &PgPool) -> Option<Vec
|
||||
args.add(article_id);
|
||||
|
||||
let res = sqlx::query_with(
|
||||
statement.as_str(), args)
|
||||
AssertSqlSafe(statement.as_str()), args)
|
||||
.fetch_all(pool).await;
|
||||
|
||||
let mut variants: Vec<Variant> = Vec::new();
|
||||
@@ -104,7 +104,7 @@ pub async fn insert_variant(article_id: i64, variant: &Variant, pool: PgPool) ->
|
||||
);
|
||||
|
||||
let res = sqlx::query_with(
|
||||
statement.as_str(),
|
||||
AssertSqlSafe(statement.as_str()),
|
||||
args)
|
||||
.fetch_one(&pool).await;
|
||||
|
||||
@@ -152,7 +152,7 @@ pub async fn update_variant(variant_id: i64, variant: &Variant, pool: PgPool) ->
|
||||
);
|
||||
|
||||
let res = sqlx::query_with(
|
||||
statement.as_str(),
|
||||
AssertSqlSafe(statement.as_str()),
|
||||
args)
|
||||
.fetch_one(&pool).await;
|
||||
|
||||
@@ -172,10 +172,10 @@ pub async fn update_variant(variant_id: i64, variant: &Variant, pool: PgPool) ->
|
||||
|
||||
pub async fn delete_variant(variant_id: i64, pool: PgPool) -> Option<()> {
|
||||
let result = sqlx::query(
|
||||
format!("DELETE FROM {} WHERE id = {}",
|
||||
AssertSqlSafe(format!("DELETE FROM {} WHERE id = {}",
|
||||
"variant",
|
||||
variant_id
|
||||
).as_str()
|
||||
).as_str())
|
||||
).execute(&pool).await;
|
||||
|
||||
match result {
|
||||
|
||||
Reference in New Issue
Block a user