mirror of
https://github.com/knex/knex.git
synced 2025-12-29 07:59:31 +00:00
Ensure that semicolon is not appended to statements that already end with a semicolon (#4052)
This commit is contained in:
parent
6f817a3b6e
commit
975b5a919e
@ -11,7 +11,7 @@ module.exports = function (Target) {
|
||||
.map((statement) => {
|
||||
return this.client._formatQuery(statement.sql, statement.bindings, tz);
|
||||
})
|
||||
.join(';\n');
|
||||
.reduce((a, c) => a.concat(a.endsWith(';') ? '\n' : ';\n', c));
|
||||
};
|
||||
|
||||
// Create a new instance of the `Runner`, passing in the current object.
|
||||
|
||||
@ -963,4 +963,12 @@ describe('Oracle SchemaBuilder', function () {
|
||||
expect(spy.thirdCall.args).to.deep.equal(['users', 'table context']);
|
||||
});
|
||||
});
|
||||
|
||||
it('test converting a sql wrapped with catch to string, #4045', function () {
|
||||
tableSql = client.schemaBuilder().dropTableIfExists('book');
|
||||
|
||||
expect(tableSql.toQuery()).to.equal(
|
||||
'begin execute immediate \'drop table "book"\'; exception when others then if sqlcode != -942 then raise; end if; end;\nbegin execute immediate \'drop sequence "book_seq"\'; exception when others then if sqlcode != -2289 then raise; end if; end;'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@ -963,4 +963,12 @@ describe('OracleDb SchemaBuilder', function () {
|
||||
expect(spy.thirdCall.args).to.deep.equal(['users', 'table context']);
|
||||
});
|
||||
});
|
||||
|
||||
it('test converting a sql wrapped with catch to string, #4045', function () {
|
||||
tableSql = client.schemaBuilder().dropTableIfExists('book');
|
||||
|
||||
expect(tableSql.toQuery()).to.equal(
|
||||
'begin execute immediate \'drop table "book"\'; exception when others then if sqlcode != -942 then raise; end if; end;\nbegin execute immediate \'drop sequence "book_seq"\'; exception when others then if sqlcode != -2289 then raise; end if; end;'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user