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

[BUG] JSQLParser 4.6: RDBMS : SetStatement getName returns Object instead of String or NameExpr #1746

Closed
rhuddbiz opened this issue Mar 14, 2023 · 4 comments · Fixed by #1745

Comments

@rhuddbiz
Copy link

Software Information:

  • JSqlParser 4.6

net.sf.jsqlparser.statement.SetStatement.getName() returns Object whereas in 4.5 it returned a String. There is no method that returns a getName method maybe should return NameExpr instead of String, I'm not sure of the expected behavoir, but the Object seems incorrect.

@manticore-projects
Copy link
Contributor

manticore-projects commented Mar 15, 2023

Greetings.

It is explicitly defined as an Object for making variable assignments possible, such as:

set @Flag = 1

or

SET @@global.time_zone = '01:00'

Whenever you get an Object, you can use toString() to get your expected String since all Entities de-parse using toString() method.

@rhuddbiz
Copy link
Author

Ok, but why upcast from NameExp to Object ? I'd prefer to work with a NameExp which is the internal variable type .

@manticore-projects
Copy link
Contributor

manticore-projects commented Mar 17, 2023

Ok, but why upcast from NameExp to Object ? I'd prefer to work with a NameExp which is the internal variable type .

The Name of the NameExp can be a UserVariable or a String.
The method getName returns this Name of the NameExpression, but not the NameExpression itself.

Although it would make sense to provide a Getter/Setter for the NameExpression:

setStatement.addKeyValuePairs(
                new SetStatement.NameExpr("test", Arrays.asList(new StringValue("1")), false));
setStatement.getKeyValuePairs().get(0).setUseEqual(true);

manticore-projects added a commit to manticore-projects/JSqlParser that referenced this issue Mar 17, 2023
@wumpz wumpz closed this as completed in 31ef1aa Mar 21, 2023
@rhuddbiz
Copy link
Author

The commit looks like it will solve my issue, thank you so much !

wumpz pushed a commit that referenced this issue Apr 27, 2023
* Fixes #1684: Support CREATE MATERIALIZED VIEW with AUTO REFRESH

Support parsing create view statements in Redshift with AUTO REFRESH
option.

* Reduce cyclomatic complexity in CreateView.toString

Extract adding the force option into a dedicated method resulting in the
cyclomatic complexity reduction of the CreateView.toString method.

* Enhanced Keywords

Add Keywords and document, which keywords are allowed for what purpose

* Fix incorrect tests

* Define Reserved Keywords explicitly
Derive All Keywords from Grammar directly
Generate production for Object Names (semi-) automatically
Add parametrized Keyword Tests

* Fix test resources

* Adjust Gradle to JUnit 5

Parallel Test execution
Gradle Caching
Explicitly request for latest JavaCC 7.0.10

* Do not mark SpeedTest for concurrent execution

* Remove unused imports

* Adjust Gradle to JUnit 5

Parallel Test execution
Gradle Caching
Explicitly request for latest JavaCC 7.0.10

* Do not mark SpeedTest for concurrent execution

* Remove unused imports

* Sphinx Documentation

Update the MANTICORE Sphinx Theme, but ignore it in GIT
Add the content to the Sphinx sites
Add a Gradle function to derive Stable and Snapshot version from GIT Tags
Add a Gradle GIT change task
Add a Gradle sphinx task
Add a special Test case for illustrating the use of JSQLParser

* doc: request for `Conventional Commit` messages

* feat: make important Classes Serializable

Implement Serializable for persisting via ObjectOutputStream

* chore: Make Serializable

* doc: Better integration of the RR diagrams

- apply neutral Sphinx theme
- insert the RR diagrams into the sphinx sources
- better documentation on Gradle dependencies
- link GitHub repository

* Merge

* feat: Oracle Alternative Quoting

- add support for Oracle Alternative Quoting e.g. `q'(...)'`
- fixes #1718
- add a Logo and FavIcon to the Website
- document recent changes on Quoting/Escaping
- add an example on building SQL from Java
- rework the README.md, promote the Website
- add Spotless Formatter, using Google Java Style (with Tab=4 Spaces)

* style: Appease PMD/Codacy

* doc: fix the issue template

- fix the issue template
- fix the -SNAPSHOT version number

* Update issue templates

* Update issue templates

* feat: Support more Statement Separators

- `GO`
- Slash `/`
- Two empty lines

* feat: FETCH uses EXPRESSION

- `FETCH` uses `EXPRESSION` instead of SimpleJDBCParameter only
- Visit/Accept `FETCH` `EXPRESSION` instead of `append` to String
- Visit/Accept `OFFSET` `EXPRESSION` instead of `append` to String
- Gradle: remove obsolete/incompatible `jvmArgs` from Test()

* style: apply Spotless

* test: commit missing test

* fix: JSon Operator can use Simple Function

Supports `Function() ->> Literal` (although `Function()` would not allow Nested Expression Parameters)

fixes #1571

* style: Reformat changed files and headers

* style: Remove unused variable

* feat: Add support for Hangul "\uAC00"-"\uD7A3"

fixes #1747

* style: expose `SetStatement` key-value list

fixes #1746

* style: Appease PMD/Codacy

* feat: `ConflictTarget` allows multiple `IndexColumnNames`

fixes #1749
fixes #1633
fixes #955

* doc: fix reference in the Java Doc

* build: better Upload Groovy Task

* feat: ParenthesedSelectBody and ParenthesedFromItem

- First properly working version
- Work in progress, 13 tests failing

* feat: ParenthesedSelectBody and ParenthesedFromItem

- delete unneeded ParenthesedJoin
- rename ParenthesisFromItem into ParenthesedFromItem

* feat: ParenthesedSelectBody and ParenthesedFromItem

- fix `NULLS FIRST` and `NULLS LAST`

* feat: ParenthesedSelectBody and ParenthesedFromItem

- fix Oracle Hints

* feat: ParenthesedSelectBody and ParenthesedFromItem

- parse `SetOperation` only after a (first plain) SelectBody has found, this fixes the performance issue
- one more special Oracle Test succeeds
- 5 remaining test failures

* feat: ParenthesedSelectBody and ParenthesedFromItem

- extract `OrderByElements` into `SelectBody`
- one more special Oracle Test succeeds
- all tests succeed

* style: Appease PMD/Codacy

* style: Appease PMD/Codacy

* feat: Refactor SelectBody implementations

- `SelectBody` implements `FromItem`
- get rid of `SubSelect` and `SpecialSubSelect`
- `Merge` can use `FromItem` instead of `SubSelect` or `Table`
- `LateralSubSelect` extends `ParenthesedSelectBody` directly
- Simplify the `Select` statement, although it is still redundant since     `SelectBody` also could implement `Statement` directly
- `WithItem` can use `SelectBody` directly, which allows for nested `WithItems`

BREAKING-CHANGE: Lots of redundant methods and intermediate removed

* feat: Refactor SelectBody implementations

- `SelectBody` implements `Statement` and so makes `Select` redundant
- get rid of `ValuesList`
- refactor `ValuesStatement` into `Values` which just implements `SelectBody` (and becomes a `Statement` and a `FromItem`), move to `select` package

BREAKING-CHANGE: Lots of redundant methods and intermediate removed

* style: Code cleanup

- remove 3 unused/obsolete productions
- appease PMD/Codacy

* feat: Merge `SelectBody` into `Select` Statement

- former `SelectBody` implements `Statement` and so becomes `Select`
- this reduces the AST by 1 hierarchy level

* style: Remove unused import

* test: @disabled invalid Test

* style: Appease PMD/Codacy

* test: Add a SubSelect Parsing Test

---------

Co-authored-by: zaza <tzarna@gmail.com>
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 a pull request may close this issue.

2 participants