Skip to content

Commit

Permalink
Address review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
SevInf committed Sep 19, 2022
1 parent bd57fc4 commit 3eb13fb
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
10 changes: 8 additions & 2 deletions query-engine/core/src/executor/interpreting_executor.rs
@@ -1,6 +1,6 @@
use super::execute_operation::{execute_many_operations, execute_many_self_contained, execute_single_self_contained};
use crate::{
BatchDocumentTransaction, OpenTx, Operation, QueryExecutor, ResponseData, TransactionActorManager,
BatchDocumentTransaction, CoreError, OpenTx, Operation, QueryExecutor, ResponseData, TransactionActorManager,
TransactionError, TransactionManager, TxId,
};

Expand Down Expand Up @@ -84,6 +84,12 @@ where
trace_id: Option<String>,
) -> crate::Result<Vec<crate::Result<ResponseData>>> {
if let Some(tx_id) = tx_id {
let batch_isolation_level = transaction.and_then(|t| t.isolation_level());
if batch_isolation_level.is_some() {
return Err(CoreError::UnsupportedFeatureError(
"Can not set batch isolation level within interactive transaction".into(),
));
}
self.itx_manager.batch_execute(&tx_id, operations, trace_id).await
} else if let Some(transaction) = transaction {
let connection_name = self.connector.name();
Expand All @@ -93,7 +99,7 @@ where
"db.type" = connection_name.as_str()
);
let mut conn = self.connector.get_connection().instrument(conn_span).await?;
let mut tx = conn.start_transaction(transaction.isolation_level).await?;
let mut tx = conn.start_transaction(transaction.isolation_level()).await?;

let results = execute_many_operations(query_schema, tx.as_connection_like(), &operations, trace_id).await;

Expand Down
6 changes: 5 additions & 1 deletion query-engine/core/src/query_document/mod.rs
Expand Up @@ -88,13 +88,17 @@ impl BatchDocument {

#[derive(Debug)]
pub struct BatchDocumentTransaction {
pub isolation_level: Option<String>,
isolation_level: Option<String>,
}

impl BatchDocumentTransaction {
pub fn new(isolation_level: Option<String>) -> Self {
Self { isolation_level }
}

pub fn isolation_level(&self) -> Option<String> {
self.isolation_level.clone()
}
}

#[derive(Debug, Clone)]
Expand Down
8 changes: 5 additions & 3 deletions query-engine/request-handlers/src/graphql/body.rs
Expand Up @@ -67,9 +67,11 @@ impl GraphQlBody {
.into_iter()
.map(|body| GraphQLProtocolAdapter::convert_query_to_operation(&body.query, body.operation_name))
.collect();
let transaction = bodies
.transaction
.then(|| BatchDocumentTransaction::new(bodies.isolation_level));
let transaction = if bodies.transaction {
Some(BatchDocumentTransaction::new(bodies.isolation_level))
} else {
None
};

Ok(QueryDocument::Multi(BatchDocument::new(operations?, transaction)))
}
Expand Down

0 comments on commit 3eb13fb

Please sign in to comment.