|
@@ -62,8 +62,7 @@ pub trait EntityInterface {
|
|
|
fn run_custom(
|
|
|
ctx: &Self::Context,
|
|
|
cmd: Self::CustomCommand,
|
|
|
- query_ctx: impl Queryable<EntityOutput = Self::Entity>,
|
|
|
- insert_ctx: &impl Insertable<Self::Entity>,
|
|
|
+ query_ctx: impl Queryable<EntityOutput = Self::Entity> + Insertable<Self::Entity>,
|
|
|
) -> Result<(), Self::Error>;
|
|
|
|
|
|
/// Provide a summary of the entity, ideally a string with no newlines that can identify the
|
|
@@ -199,12 +198,11 @@ mod tests {
|
|
|
fn run_custom(
|
|
|
_ctx: &Self::Context,
|
|
|
cmd: Self::CustomCommand,
|
|
|
- _query_ctx: impl Queryable<EntityOutput = Self::Entity>,
|
|
|
- insert_ctx: &impl Insertable<Self::Entity>,
|
|
|
+ query_ctx: impl Queryable<EntityOutput = Self::Entity> + Insertable<Self::Entity>,
|
|
|
) -> Result<(), Self::Error> {
|
|
|
match cmd {
|
|
|
CCustom::Create { name } => {
|
|
|
- insert_ctx.insert(Customer {
|
|
|
+ query_ctx.insert(Customer {
|
|
|
name,
|
|
|
txs: Default::default(),
|
|
|
})?;
|
|
@@ -230,12 +228,11 @@ mod tests {
|
|
|
fn run_custom(
|
|
|
_ctx: &Self::Context,
|
|
|
cmd: Self::CustomCommand,
|
|
|
- _query_ctx: impl Queryable<EntityOutput = Self::Entity>,
|
|
|
- insert_ctx: &impl Insertable<Self::Entity>,
|
|
|
+ query_ctx: impl Queryable<EntityOutput = Self::Entity> + Insertable<Self::Entity>,
|
|
|
) -> Result<(), Self::Error> {
|
|
|
match cmd {
|
|
|
ECustom::Create { name } => {
|
|
|
- insert_ctx.insert(Employee {
|
|
|
+ query_ctx.insert(Employee {
|
|
|
name,
|
|
|
txs: Default::default(),
|
|
|
})?;
|
|
@@ -261,12 +258,11 @@ mod tests {
|
|
|
fn run_custom(
|
|
|
_ctx: &Self::Context,
|
|
|
cmd: Self::CustomCommand,
|
|
|
- _query_ctx: impl Queryable<EntityOutput = Self::Entity>,
|
|
|
- insert_ctx: &impl Insertable<Self::Entity>,
|
|
|
+ query_ctx: impl Queryable<EntityOutput = Self::Entity> + Insertable<Self::Entity>,
|
|
|
) -> Result<(), Self::Error> {
|
|
|
match cmd {
|
|
|
TCustom::Create { title, amount } => {
|
|
|
- insert_ctx.insert(Transaction {
|
|
|
+ query_ctx.insert(Transaction {
|
|
|
title,
|
|
|
amount,
|
|
|
customer: Default::default(),
|
|
@@ -297,15 +293,15 @@ mod tests {
|
|
|
fn run_cmd(db: &TransactionTestDB, args: &[&str]) {
|
|
|
match <Params as Parser>::try_parse_from(args) {
|
|
|
Ok(Params::Customer { cmd }) => {
|
|
|
- cmd.perform(&(), &db.customers, &db.customers)
|
|
|
+ cmd.perform(&(), &db.customers)
|
|
|
.expect("couldn't perform command");
|
|
|
},
|
|
|
Ok(Params::Employee { cmd }) => {
|
|
|
- cmd.perform(&(), &db.employees, &db.employees)
|
|
|
+ cmd.perform(&(), &db.employees)
|
|
|
.expect("couldn't perform command");
|
|
|
},
|
|
|
Ok(Params::Tx { cmd }) => {
|
|
|
- cmd.perform(&(), &db.transactions, &db.transactions)
|
|
|
+ cmd.perform(&(), &db.transactions)
|
|
|
.expect("couldn't perform command");
|
|
|
},
|
|
|
Err(e) => {
|