Skip to content

Conversation

rathboma
Copy link
Contributor

Oracle supports statement-level blocks (because...reasons)
This adds support for them.
It also adds oracle as a dialect

@rathboma rathboma requested a review from MasterOdin May 29, 2022 03:48
@rathboma
Copy link
Contributor Author

@MasterOdin be good to get eyes on this briefly before merging, but it's working. Going to use in BKS either way

});

describe('identifying statements with anonymous blocks', () => {
it('should identify a create table then a block', () => {
Copy link
Member

@MasterOdin MasterOdin May 30, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why have this test repeated here and in parser/oracle.spec.ts? Given that identify is a relative shallow operation over the result of the parser, I'd rather just beef up the asserts there, and get rid of this test.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just as an idiot check to be honest. Costs very little, gives me some assurances

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For example, I changed the execution type that this returns, the tests reflect that. Nothing wrong with over testing.

Copy link
Member

@MasterOdin MasterOdin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For all the tests in test/parser/oracle.spec.ts, I think it would be good to have test:

  • Number of statements
  • Type of each statement
  • Start of each statement
  • End of each statement

So that it's nice and uniform, and we're testing the full scope of things.

expect(result.body[0].type).to.eq('ANON_BLOCK');
expect(result.body[0].start).to.eq(0);
expect(result.body[0].end).to.eq(120);
expect(result.body.length).to.eql(2);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be the first assert where if there were no statements found, then we'd get an undefined error for a test failure, which isn't as meaningful imo.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I reorganized this incorrectly, moving the other way around

@rathboma
Copy link
Contributor Author

I'll address these couple of issues, then I'll merge it.

@rathboma
Copy link
Contributor Author

rathboma commented Jun 13, 2022

@MasterOdin I've added a few changes:

  1. Tidied up the tests sufficiently
  2. Added a new execution type, ANON_BLOCK. This accounts for the fact that ANON_BLOCKs should be identifiable in strict mode. I didn't want to overload UNKNOWN.
  3. Updated the README to show the new dialect and new statement and execution types.

I don't think this change requires a major version bump, as the new execution and statement types are only valid for Oracle, so no behavior has changed for any other databases.

@rathboma rathboma requested a review from MasterOdin June 13, 2022 15:34
@rathboma
Copy link
Contributor Author

@MasterOdin I'll merge this tomorrow if you don't have any other changes.

@MasterOdin MasterOdin changed the title Support Anonymous blocks for Oracle (also new dialect!) Support anonymous blocks for new Oracle dialect Jun 22, 2022
@MasterOdin MasterOdin merged commit 334ffa5 into main Jun 22, 2022
@MasterOdin MasterOdin deleted the oracle-blocks-redux branch June 22, 2022 01:06
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.

2 participants