Skip to content

Commit

Permalink
[#1] ParseListener only available in commercial editions
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaseder committed Jun 1, 2022
1 parent d8b6603 commit d5e5671
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,26 +77,29 @@ create table book (

@Test
public void parseListener() {
title("The jOOQ parser might not support all of your vendor specific syntax. In some cases, you can simply extend it");
// Feature available in the commercial editions only




















try {
ctx.parser().parseSelect("select approx_avg(length) from film").fetch();
}
catch (ParserException e) {
e.printStackTrace();
}

title("Handle a few additional functions per dialect");
ctx.configuration().set(ParseListener.onParseField(c1 -> {
if (c1.parseFunctionNameIf("APPROX_SUM"))
return c1.parseParenthesised(c2 -> DSL.sum((Field) c2.parseField()));
else if (c1.parseFunctionNameIf("APPROX_AVG"))
return c1.parseParenthesised(c2 -> DSL.avg((Field) c2.parseField()));
// TODO: The rest

return null;
}));

ctx.parser().parseSelect("select approx_avg(length) from film").fetch();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,23 +69,26 @@ class Demo07Parser : AbstractDemo() {

@Test
fun parseListener() {
title("The jOOQ parser might not support all of your vendor specific syntax. In some cases, you can simply extend it")
try {
ctx.parser().parseSelect("select approx_avg(length) from film")!!.fetch()
}
catch (e: ParserException) {
e.printStackTrace()
}
// Feature available in the commercial editions only




















title("Handle a few additional functions per dialect")
ctx.configuration().set(ParseListener.onParseField { c1 ->
if (c1.parseFunctionNameIf("APPROX_SUM"))
c1.parseParenthesised { c2 -> DSL.sum(c2.parseField() as Field<out Number>) }
else if (c1.parseFunctionNameIf("APPROX_AVG"))
c1.parseParenthesised { c2 -> DSL.avg(c2.parseField() as Field<out Number>) }
else
null
})
ctx.parser().parseSelect("select approx_avg(length) from film")!!.fetch()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,23 +77,26 @@ class Demo07Parser extends AbstractDemo {

@Test
def parseListener(): Unit = {
title("The jOOQ parser might not support all of your vendor specific syntax. In some cases, you can simply extend it")
try ctx.parser.parseSelect("select approx_avg(length) from film").fetch
catch {
case e: ParserException =>
e.printStackTrace()
}
// Feature available in the commercial editions only




















title("Handle a few additional functions per dialect")
ctx.configuration.set(ParseListener.onParseField(c1 =>
if (c1.parseFunctionNameIf("APPROX_SUM"))
c1.parseParenthesised(c2 => DSL.sum(c2.parseField.asInstanceOf[Field[Number]]))
else if (c1.parseFunctionNameIf("APPROX_AVG"))
c1.parseParenthesised(c2 => DSL.avg(c2.parseField.asInstanceOf[Field[Number]]))
// TODO: The rest
else
null
))
ctx.parser.parseSelect("select approx_avg(length) from film").fetch
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ create table book (

@Test
public void parseListener() {
// Feature available in the commercial editions only
/* [pro] */
title("The jOOQ parser might not support all of your vendor specific syntax. In some cases, you can simply extend it");

try {
Expand All @@ -98,5 +100,6 @@ else if (c1.parseFunctionNameIf("APPROX_AVG"))
}));

ctx.parser().parseSelect("select approx_avg(length) from film").fetch();
/* [/pro] */
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ class Demo07Parser : AbstractDemo() {

@Test
fun parseListener() {
// Feature available in the commercial editions only
/* [pro] */
title("The jOOQ parser might not support all of your vendor specific syntax. In some cases, you can simply extend it")
try {
ctx.parser().parseSelect("select approx_avg(length) from film")!!.fetch()
Expand All @@ -87,5 +89,6 @@ class Demo07Parser : AbstractDemo() {
null
})
ctx.parser().parseSelect("select approx_avg(length) from film")!!.fetch()
/* [/pro] */
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ class Demo07Parser extends AbstractDemo {

@Test
def parseListener(): Unit = {
// Feature available in the commercial editions only
/* [pro] */
title("The jOOQ parser might not support all of your vendor specific syntax. In some cases, you can simply extend it")
try ctx.parser.parseSelect("select approx_avg(length) from film").fetch
catch {
Expand All @@ -95,5 +97,6 @@ class Demo07Parser extends AbstractDemo {
null
))
ctx.parser.parseSelect("select approx_avg(length) from film").fetch
/* [/pro] */
}
}

0 comments on commit d5e5671

Please sign in to comment.