Skip to content

Commit

Permalink
fix for WrapMysqlModifySubqueryTransformation when using join builder
Browse files Browse the repository at this point in the history
Fixes and error where .andOnIn() causes:
"TypeError: parentQuery.isUpdate is not a function"
  • Loading branch information
marcinlee authored and falkenhawk committed Jul 20, 2022
1 parent 26b3197 commit ca5eef2
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

const { QueryTransformation } = require('./QueryTransformation');
const { isMySql } = require('../../utils/knexUtils');
const { once } = require('../../utils/objectUtils');
const getJoinBuilder = once(() => require('../JoinBuilder').JoinBuilder);

/**
* Mysql doesn't allow queries like this:
Expand Down Expand Up @@ -30,6 +32,13 @@ class WrapMysqlModifySubqueryTransformation extends QueryTransformation {
return query;
}

// This transformation should not apply to join builder, otherwise it causes:
// "TypeError: parentQuery.isUpdate is not a function"
const JoinBuilder = getJoinBuilder();
if (parentQuery instanceof JoinBuilder) {
return query;
}

// This transformation only applies to update and delete queries.
if (!parentQuery.isUpdate() && !parentQuery.isDelete()) {
return query;
Expand Down

0 comments on commit ca5eef2

Please # to comment.