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

Support for TOP expressions #243

Closed
mlkammer opened this issue Apr 5, 2016 · 1 comment
Closed

Support for TOP expressions #243

mlkammer opened this issue Apr 5, 2016 · 1 comment
Assignees

Comments

@mlkammer
Copy link

mlkammer commented Apr 5, 2016

It would be great if JSQLParser could also parse TOP expressions.

Currently only two variants are supported as a TOP clause and these will parse successfully:

  1. Constant value, example: SELECT TOP (2) * FROM MyTable
  2. JDBC parameter, example: SELECT TOP (?) * FROM MyTable

More complex expressions are currently not supported and give a ParseException. Example queries that fail to be parsed:

  • SELECT TOP (? + 1) * FROM MyTable
  • SELECT TOP (CAST(? AS INT)) * FROM MyTable

I feel like it could be relatively simple to implement this, by letting net.sf.jsqlparser.statement.select.Top have a method getRowCountExpression which returns a scalar expression as a net.sf.jsqlparser.expression.Expression object.

On a side note: the JSQLParser library is greatly appreciated by us. Thanks to the authors!

@wumpz wumpz self-assigned this May 16, 2016
@wumpz wumpz closed this as completed in 780ba12 May 16, 2016
wumpz added a commit that referenced this issue May 16, 2016
@mlkammer
Copy link
Author

Great work, Tobias! Will check it out soon.

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

No branches or pull requests

2 participants