From 1ee8e44912a02feb77fd9640a5cc4782b494820b Mon Sep 17 00:00:00 2001 From: BlackDex Date: Wed, 15 Apr 2020 16:49:33 +0200 Subject: [PATCH] Fixed issue #965 PostgreSQL updates/inserts ignored None/null values. This is nice for new entries, but not for updates. Added derive option to allways add these none/null values for Option<> variables. This solves issue #965 --- src/db/models/attachment.rs | 1 + src/db/models/cipher.rs | 1 + src/db/models/device.rs | 1 + src/db/models/user.rs | 1 + 4 files changed, 4 insertions(+) diff --git a/src/db/models/attachment.rs b/src/db/models/attachment.rs index e43a6a82..d75420cd 100644 --- a/src/db/models/attachment.rs +++ b/src/db/models/attachment.rs @@ -5,6 +5,7 @@ use crate::CONFIG; #[derive(Debug, Identifiable, Queryable, Insertable, Associations, AsChangeset)] #[table_name = "attachments"] +#[changeset_options(treat_none_as_null="true")] #[belongs_to(Cipher, foreign_key = "cipher_uuid")] #[primary_key(id)] pub struct Attachment { diff --git a/src/db/models/cipher.rs b/src/db/models/cipher.rs index b2e29c36..10d96b33 100644 --- a/src/db/models/cipher.rs +++ b/src/db/models/cipher.rs @@ -7,6 +7,7 @@ use super::{ #[derive(Debug, Identifiable, Queryable, Insertable, Associations, AsChangeset)] #[table_name = "ciphers"] +#[changeset_options(treat_none_as_null="true")] #[belongs_to(User, foreign_key = "user_uuid")] #[belongs_to(Organization, foreign_key = "organization_uuid")] #[primary_key(uuid)] diff --git a/src/db/models/device.rs b/src/db/models/device.rs index 4fa91fa2..c9d1d9c2 100644 --- a/src/db/models/device.rs +++ b/src/db/models/device.rs @@ -5,6 +5,7 @@ use crate::CONFIG; #[derive(Debug, Identifiable, Queryable, Insertable, Associations, AsChangeset)] #[table_name = "devices"] +#[changeset_options(treat_none_as_null="true")] #[belongs_to(User, foreign_key = "user_uuid")] #[primary_key(uuid)] pub struct Device { diff --git a/src/db/models/user.rs b/src/db/models/user.rs index 3a6e95d2..5fee310d 100644 --- a/src/db/models/user.rs +++ b/src/db/models/user.rs @@ -6,6 +6,7 @@ use crate::CONFIG; #[derive(Debug, Identifiable, Queryable, Insertable, AsChangeset)] #[table_name = "users"] +#[changeset_options(treat_none_as_null="true")] #[primary_key(uuid)] pub struct User { pub uuid: String,