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

feat(oracle): adds initial support to the oracle database (WIP) #825

Draft
wants to merge 9 commits into
base: master
Choose a base branch
from
Draft

feat(oracle): adds initial support to the oracle database (WIP) #825

wants to merge 9 commits into from

Conversation

guilhermedalleprane
Copy link

This PR brings some initial work for compatibility with oracle databases. It's still a WIP and it is not yet stable. Still lacks automated testing and review of some features.

@B4nan B4nan marked this pull request as draft September 8, 2020 08:25
@B4nan
Copy link
Member

B4nan commented Oct 20, 2020

What's the status? I still don't see any test cases in the PR.

@guilhermedalleprane
Copy link
Author

guilhermedalleprane commented Oct 20, 2020

Hi, Martin!
I had to solve some bugs on knex side that was affecting the oracle driver and after that I went on vacation from work and decided to take some time off for myself.
I will keep working on it soon!

@B4nan
Copy link
Member

B4nan commented Oct 20, 2020

Sure, no rush :]

@guilhermedalleprane
Copy link
Author

I'm back!

@guilhermedalleprane
Copy link
Author

I thought it would be easier to bring support to oracle, but oracle driver (and the oracle knex dialect) has several details incompatible with the current implementation, especially when it comes to SchemaGenerator.

An example is the execution of raw sql, where the oracle driver does not accept the termination with semicolons, except in statements ending with END;

Another example is that to load a .sql file, I had to change here to run it line by line.

I think it's necessary to take a look at all the necessary changes to the existing code for everything to work properly (not just for all tests to pass, but to ensure if there is no loss of performance or unexpected effects). I confess that I am little afraid to change the existing framework code for this.

For now, as this is taking much longer than I imagined, I am using other alternatives to meet my initial need (which was relatively small compared to the amount of work to be done here), but it will be a pleasure to continue helping if more people want to help implement this in the future, otherwise it is not extremely priority for me too.

@B4nan
Copy link
Member

B4nan commented Nov 16, 2020

An example is the execution of raw sql, where the oracle driver does not accept the termination with semicolons, except in statements ending with END;

Do you have some links about that? As from what I searched I cannot find a place that would say so. It sounds very weird, hard to believe it :]

@guilhermedalleprane
Copy link
Author

guilhermedalleprane commented Nov 16, 2020

I explained it very badly, sorry.

statements ending with a END;

I mean Oracle PL/SQL blocks.

Semicolons are for separating multiple statements, except when the semicolon is part of the statement as is the case with Oracle PL/SQL blocks. In this case, the semicolon at the end is part of a single statement.

Knex internally uses the execute() method from oracle-nodedb, that does not allow the execution of multiple statements, and consequently, I believe, statements ending with semicolons. AbstractSqlConnection.loadFile() would not work for oracle because of that.

This also causes SchemaGenerator.createSchema() to not work, since it first calls SchemaGenerator.getCreateSchemaSQL(), and then executes the returned multiline sql). SchemaGenerator.dump() would also add an extra semicolon at the end here. (double semicolons in case of PL/SQL blocks, which syntactically already have a semicolon at the end).

Ok, now why are PL/SQL blocks important? Because Knex wrap some instructions with it, to catch exceptions (like in dropTableIfExists). Knex had a similar problem and I solved it here.

As from what I searched I cannot find a place that would say so.

If you search, you won't find examples where the knex is using semicolons in simple statements as well. Except when the driver itself supports, like as is the case with mysql, when the parameter multipleStatements is added. But this is not something officially supported by knex, is merely supported by each driver, as stated here.

So if knex does not officially support it, is not a guarantee of operation in all cases and it's not so hard to believe that it doesn't work in oracle. I haven't tested if removing multipleStatements, it would work with single statements ending with semicolons for MySQL, but with oracle I haven't found a way to make it work.

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

Successfully merging this pull request may close these issues.

None yet

2 participants