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

Duplicated semicolons on oracle toString() / toQuery() #4045

Closed
guilhermedalleprane opened this issue Sep 22, 2020 · 1 comment
Closed

Duplicated semicolons on oracle toString() / toQuery() #4045

guilhermedalleprane opened this issue Sep 22, 2020 · 1 comment

Comments

@guilhermedalleprane
Copy link
Contributor

Environment

Knex version: 0.21.5
Database + version: Oracle
OS: any
@atiertant

Bug

toQuery() & toSql() are returning duplicate semicolons for queries that pass through the method wrapSqlWithCatch()

Example:

var knex = require('knex')({
    client: 'oracledb',
    connection: {
        host: '127.0.0.1',
        user: 'your_database_user',
        password: 'your_database_password',
        database: 'myapp_test'
    }
});

var builder = knex.schema.dropTableIfExists('book');

console.log(builder.toQuery())

outputs:

begin execute immediate 'drop table "book"'; exception when others then if sqlcode != -942 then raise; end if; end;;
begin execute immediate 'drop sequence "book_seq"'; exception when others then if sqlcode != -2289 then raise; end if; end;

It happens because both wrapSqlWithCatch() and toQuery() are appending a semicolon to end of query.
https://github.com/knex/knex/blob/master/lib/dialects/oracle/utils.js#L30
https://github.com/knex/knex/blob/master/lib/interface.js#L14

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants