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