Skip to content
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

Merged
merged 4 commits into from
Jan 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions query/src/org/labkey/query/controllers/QueryController.java
Original file line number Diff line number Diff line change
Expand Up @@ -4435,6 +4435,11 @@ protected String getTargetContainerProp()
}

protected JSONObject executeJson(JSONObject json, CommandType commandType, boolean allowTransaction, Errors errors) throws Exception
{
return executeJson(json, commandType, allowTransaction, errors, false);
}

protected JSONObject executeJson(JSONObject json, CommandType commandType, boolean allowTransaction, Errors errors, boolean isNestedTransaction) throws Exception
{
JSONObject response = new JSONObject();
Container container = getContainerForCommand(json);
Expand Down Expand Up @@ -4548,12 +4553,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 && isNestedTransaction ? table.getSchema().getScope().getCurrentTransaction() : transaction;
if (auditTransaction == null)
auditTransaction = NO_OP_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);
}
}

Expand Down Expand Up @@ -4976,7 +4985,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, transacted);
// Bail out immediately if we're going to return a failure-type response message
if (commandResponse == null || (errors.hasErrors() && !isSuccessOnValidationError()))
return null;
Expand Down