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

Add support for AT TIME ZONE expressions #1196

Merged
merged 3 commits into from
May 25, 2021
Merged

Add support for AT TIME ZONE expressions #1196

merged 3 commits into from
May 25, 2021

Conversation

tomershay
Copy link
Contributor

@tomershay tomershay commented May 14, 2021

Adding support for AT TIME ZONE expressions, used for example in PostgreSQL.
Sample usages:
SELECT creation_date AT TIME ZONE 'UTC';
SELECT DATE(date1 AT TIME ZONE 'UTC' AT TIME ZONE 'australia/sydney') AS another_date;

This PR doesn't cover all time zone related options that can be done on an expression, but is only a start.

Documentation and samples (some of the capabilities described aren't yet supported):
https://www.postgresql.org/docs/9.2/functions-datetime.html#FUNCTIONS-DATETIME-ZONECONVERT
https://www.enterprisedb.com/postgres-tutorials/postgres-time-zone-explained

This PR potentially fixes or makes progress with issues: #214, #1115

@coveralls
Copy link

coveralls commented May 14, 2021

Coverage Status

Coverage increased (+0.1%) to 88.582% when pulling 1fd0c00 on tomershay:add_support_for_at_time_zone into 86b613c on JSQLParser:master.

@tomershay
Copy link
Contributor Author

@wumpz, can you please share if there is a way to add further tests to increase coverage for the uncovered parts? Didn't see a way to do that as part of the existing testing suite. Thanks!

@manticore-projects
Copy link
Contributor

Greetings @tomershay, I ran into the same issue a few days ago.

  1. The Coveralls checks if each line of the Java Code has been executed/touched by your tests and the Details Report will show you which Java Code lines have NOT been touched

  2. You will need to write tests, which trigger these Java Code Lines.

An over simplified example:

private int foo(int i) {
    if (i>0) {
         return 1;
    } else {
         return 0;
   }
}

@test 
private void fooTest() {
    assertEquals(1, foo(1));
}

The test above will execute the foo() method but will not run through all code lines and Coveralls would complain, that else return(0) is never touched.

You would need to add another test, that triggers that part.

@wumpz wumpz merged commit a5204f6 into JSQLParser:master May 25, 2021
@wumpz
Copy link
Member

wumpz commented May 25, 2021

@tomershay Thx for adding this.

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

4 participants