Skip to content

Commit

Permalink
Adds CURRENT_DATE special form to parser
Browse files Browse the repository at this point in the history
  • Loading branch information
RCHowell committed Sep 25, 2023
1 parent e1b1e96 commit b9a81a0
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- Adds overridden `toString()` method for Sprout-generated code.
- Adds CURRENT_DATE session variable to PartiQL.g4 and PartiQLParser
### Changed
Expand Down
4 changes: 4 additions & 0 deletions buildSrc/src/main/kotlin/partiql.conventions.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ configure<KtlintExtension> {
}
}

tasks.named("build") {
dependsOn("ktlintFormat")
}

sourceSets {
main {
java.srcDir(generatedSrc)
Expand Down
1 change: 1 addition & 0 deletions partiql-ast/src/main/resources/partiql_ast.ion
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ expr::[
session_attribute::{
attribute: [
CURRENT_USER,
CURRENT_DATE,
],
},

Expand Down
1 change: 1 addition & 0 deletions partiql-parser/src/main/antlr/PartiQL.g4
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,7 @@ exprPrimary
exprTerm
: PAREN_LEFT expr PAREN_RIGHT # ExprTermWrappedQuery
| CURRENT_USER # ExprTermCurrentUser
| CURRENT_DATE # ExprTermCurrentDate
| parameter # ExprTermBase
| varRefExpr # ExprTermBase
| literal # ExprTermBase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1475,6 +1475,10 @@ internal class PartiQLParserDefault : PartiQLParser {
exprSessionAttribute(Expr.SessionAttribute.Attribute.CURRENT_USER)
}

override fun visitExprTermCurrentDate(ctx: org.partiql.parser.antlr.PartiQLParser.ExprTermCurrentDateContext) = translate(ctx) {
exprSessionAttribute(Expr.SessionAttribute.Attribute.CURRENT_DATE)
}

/**
*
* FUNCTIONS
Expand Down

0 comments on commit b9a81a0

Please sign in to comment.