diff --git a/src/backend/query_builder.rs b/src/backend/query_builder.rs index b91cfb1b4..6f6dd7ba9 100644 --- a/src/backend/query_builder.rs +++ b/src/backend/query_builder.rs @@ -657,6 +657,19 @@ pub trait QueryBuilder: } sql.write_str("*").unwrap(); } + ColumnRef::New(column) => { + sql.write_str("NEW.").unwrap(); + self.prepare_iden(column, sql); + } + ColumnRef::Old(column) => { + sql.write_str("OLD.").unwrap(); + self.prepare_iden(column, sql); + } + #[cfg(feature = "backend-postgres")] + ColumnRef::Excluded(column) => { + sql.write_str("excluded.").unwrap(); + self.prepare_iden(column, sql); + } } } diff --git a/src/types/iden/compound.rs b/src/types/iden/compound.rs index 7a49edb7b..999346545 100644 --- a/src/types/iden/compound.rs +++ b/src/types/iden/compound.rs @@ -135,6 +135,13 @@ pub enum ColumnRef { Column(ColumnName), /// An `*` expression, potentially qualified as `(database.)(schema.)(table.)*`. Asterisk(Option), + /// NEW. + New(DynIden), + /// OLD. + Old(DynIden), + #[cfg(feature = "backend-postgres")] + /// excluded. + Excluded(DynIden), } impl ColumnRef { @@ -144,6 +151,10 @@ impl ColumnRef { match self { ColumnRef::Column(ColumnName(_table_ref, column_itself)) => Some(column_itself), ColumnRef::Asterisk(..) => None, + ColumnRef::New(column_itself) => Some(column_itself), + ColumnRef::Old(column_itself) => Some(column_itself), + #[cfg(feature = "backend-postgres")] + ColumnRef::Excluded(column_itself) => Some(column_itself), } } }