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

Implement Joins with multiple trailing ON Expressions #1303

Merged
merged 5 commits into from
Sep 6, 2021

Conversation

manticore-projects
Copy link
Contributor

@manticore-projects manticore-projects commented Aug 14, 2021

Fixes #1302
Fixes #1229
Fixes SpecialOracleTest JOIN17, now 190/273 tests pass

Copy link
Member

@wumpz wumpz left a comment

Choose a reason for hiding this comment

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

I am not convinced that this StringBuilder approach is the way to go. What's the point?


@Override
public String toString() {
return appendTo(new StringBuilder()).toString();
Copy link
Member

Choose a reason for hiding this comment

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

Again. Whats the improvement of this type of generating a StringBuilder and populating it? IMHO this is no improvement over this older toString approach.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good Morning. Thank you for your feedback.
My thought process was like this:

  1. I have had to touch toString() because of the new Loop through the ON-Expressions
  2. String Addition += in Loops is still considered bad style and will be called out by many style checkers, because the Compiler won't substitute the concatenation by a StringBuilder
  3. providing an appendTo() method consistently for all Statements and Expressions would eventually allow the Deparser to work with one single StringBuilder only (initiated at the very top). Right now, many Statements and Expressions initiate and dispose their own StringBuilder, putting useless load onto the GC (think about deep nested expressions especially).
  4. I do not see any disadvantages of this pattern. toString() still works without any caveats. We just delegate the logic into a special method. You did the same for many other Statements and Expressions already -- just not calling it appendTo() and not applying a systematic pattern yet.

What counter arguments do you see? Why was the String concatenation better, especially with the newly needed Loops?

Cheers.

Copy link
Member

Choose a reason for hiding this comment

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

The main purpose of the deparsers is to provide a visitor type of working through the object tree and creating the string representation of the actual expression. If the deparser is somehow calling the toString method it is simply wrong or the result of lazyness. :(

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In my opinion, for the Leaves of the object tree, you will call toString(), or better appendTo().
You would walk through the Branches via the Visitor though.

Also, I have been using the term "De-parsing" rather lax, meaning both the toString() implementation as well as the Deparser implementation. I should have referred to it as "String Composition" instead.

When you call toString() on a complex, deeply nested Statement right now, you will create many instances of Strings and StringBuilder right now, often in loops.
With the appendTo() method, only one StringBuilder would be needed and I am eager to learn about the counter arguments against this approach.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have removed the appendTo() method and re-implemented the traditional toString() as you obviously do not like this approach.

…sLast

� Conflicts:
�	src/test/java/net/sf/jsqlparser/statement/select/SelectTest.java
�	src/test/resources/net/sf/jsqlparser/statement/select/oracle-tests/connect_by01.sql
�	src/test/resources/net/sf/jsqlparser/statement/select/oracle-tests/connect_by06.sql
Refactor the appendTo() method in favour of the traditional toString()
@coveralls
Copy link

Coverage Status

Coverage increased (+0.04%) to 88.842% when pulling c90fb62 on manticore-projects:JoinOnsLast into 2e87613 on JSQLParser:master.

@wumpz wumpz merged commit d18c59b into JSQLParser:master Sep 6, 2021
@manticore-projects manticore-projects deleted the JoinOnsLast branch May 31, 2022 11:57
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.

Can't parse with query inner join join missing the 'on' filter
3 participants