-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix EHR sql server error #5123
Fix EHR sql server error #5123
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4548,12 +4548,16 @@ protected JSONObject executeJson(JSONObject json, CommandType commandType, boole | |
{ | ||
if (behaviorType != null && behaviorType != AuditBehaviorType.NONE) | ||
{ | ||
if (transaction.getAuditEvent() != null) | ||
auditEvent = transaction.getAuditEvent(); | ||
DbScope.Transaction auditTransaction = transacted ? transaction : table.getSchema().getScope().getCurrentTransaction(); | ||
if (auditTransaction == null) | ||
auditTransaction = transaction; | ||
|
||
if (auditTransaction.getAuditEvent() != null) | ||
auditEvent = auditTransaction.getAuditEvent(); | ||
else | ||
{ | ||
auditEvent = AbstractQueryUpdateService.createTransactionAuditEvent(container, commandType.getAuditAction()); | ||
AbstractQueryUpdateService.addTransactionAuditEvent(transaction, getUser(), auditEvent); | ||
AbstractQueryUpdateService.addTransactionAuditEvent(auditTransaction, getUser(), auditEvent); | ||
} | ||
} | ||
|
||
|
@@ -4976,7 +4980,7 @@ else if (scope != tableInfo.getSchema().getScope()) | |
} | ||
commandObject.put("extraContext", commandExtraContext); | ||
|
||
JSONObject commandResponse = executeJson(commandObject, command, transacted, errors); | ||
JSONObject commandResponse = executeJson(commandObject, command, !transacted, errors); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't quite get why this got switched to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It has been like this for 12 years. I think it got flipped because it was trying to avoid nested transaction and have the outer transaction used only. Attempt to reverse is resulted in sql server transaction already rolled back error. |
||
// Bail out immediately if we're going to return a failure-type response message | ||
if (commandResponse == null || (errors.hasErrors() && !isSuccessOnValidationError())) | ||
return null; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I understand this. If
transacted
is true, we use the ensured transaction from the try block and if it's false we get the transaction from the table schema. Presumably if it's transacted, these are the same thing. If there is no transaction on the table schema, we use theNO_OP_TRANSACTION
. So could this be`
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've modified the logic a little bit more to only get scope transaction when the outer caller is indeed transacted.