Skip to content

Commit 09d6dfe

Browse files
feat: Postgres Contains and ContainedBy Operators
- sourced from https://github.com/MathewJoseph31/JSqlParser/tree/add-postgress-nested-WithClause - resolves PR #361
1 parent 59104fd commit 09d6dfe

File tree

12 files changed

+124
-2839
lines changed

12 files changed

+124
-2839
lines changed

src/main/java/net/sf/jsqlparser/expression/ExpressionVisitor.java

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,12 @@
4343
import net.sf.jsqlparser.expression.operators.relational.MinorThan;
4444
import net.sf.jsqlparser.expression.operators.relational.MinorThanEquals;
4545
import net.sf.jsqlparser.expression.operators.relational.NotEqualsTo;
46-
import net.sf.jsqlparser.expression.operators.relational.DoubleAnd;//Added by mathew on 21st Nov 2016
47-
import net.sf.jsqlparser.expression.operators.relational.Contains;//Added by mathew on 21st Nov 2016
48-
import net.sf.jsqlparser.expression.operators.relational.ContainedBy;//Added by mathew on 21st Nov 2016
46+
import net.sf.jsqlparser.expression.operators.relational.DoubleAnd;// Added by mathew on 21st Nov
47+
// 2016
48+
import net.sf.jsqlparser.expression.operators.relational.Contains;// Added by mathew on 21st Nov
49+
// 2016
50+
import net.sf.jsqlparser.expression.operators.relational.ContainedBy;// Added by mathew on 21st Nov
51+
// 2016
4952
import net.sf.jsqlparser.expression.operators.relational.RegExpMatchOperator;
5053
import net.sf.jsqlparser.expression.operators.relational.SimilarToExpression;
5154
import net.sf.jsqlparser.schema.Column;
@@ -126,13 +129,13 @@ public interface ExpressionVisitor {
126129

127130
void visit(MinorThanEquals minorThanEquals);
128131

129-
void visit(NotEqualsTo notEqualsTo);
132+
void visit(NotEqualsTo notEqualsTo);
130133

131-
void visit(DoubleAnd doubleAnd);//Added by mathew on 21st Nov 2016
132-
133-
void visit(Contains contains);//Added by mathew on 21st Nov 2016
134+
void visit(DoubleAnd doubleAnd);// Added by mathew on 21st Nov 2016
134135

135-
void visit(ContainedBy containedBy);//Added by mathew on 21st Nov 2016
136+
void visit(Contains contains);// Added by mathew on 21st Nov 2016
137+
138+
void visit(ContainedBy containedBy);// Added by mathew on 21st Nov 2016
136139

137140
void visit(ParenthesedSelect selectBody);
138141

src/main/java/net/sf/jsqlparser/expression/ExpressionVisitorAdapter.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@
2525
import net.sf.jsqlparser.expression.operators.conditional.OrExpression;
2626
import net.sf.jsqlparser.expression.operators.conditional.XorExpression;
2727
import net.sf.jsqlparser.expression.operators.relational.Between;
28+
import net.sf.jsqlparser.expression.operators.relational.ContainedBy;
29+
import net.sf.jsqlparser.expression.operators.relational.Contains;
30+
import net.sf.jsqlparser.expression.operators.relational.DoubleAnd;
2831
import net.sf.jsqlparser.expression.operators.relational.EqualsTo;
2932
import net.sf.jsqlparser.expression.operators.relational.ExistsExpression;
3033
import net.sf.jsqlparser.expression.operators.relational.ExpressionList;
@@ -254,26 +257,22 @@ public void visit(MinorThanEquals expr) {
254257
public void visit(NotEqualsTo expr) {
255258
visitBinaryExpression(expr);
256259
}
257-
258-
/*Added by mathew on 21st Nov 2016*/
260+
259261
@Override
260262
public void visit(DoubleAnd expr) {
261263
visitBinaryExpression(expr);
262264
}
263-
264-
/*Added by mathew on 21st Nov 2016*/
265+
265266
@Override
266267
public void visit(Contains expr) {
267268
visitBinaryExpression(expr);
268269
}
269270

270-
/*Added by mathew on 21st Nov 2016*/
271271
@Override
272272
public void visit(ContainedBy expr) {
273273
visitBinaryExpression(expr);
274274
}
275275

276-
277276
@Override
278277
public void visit(Column column) {
279278

src/main/java/net/sf/jsqlparser/expression/operators/relational/ContainedBy.java

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,12 @@
1-
/*
1+
/*-
22
* #%L
33
* JSQLParser library
44
* %%
5-
* Copyright (C) 2004 - 2013 JSQLParser
5+
* Copyright (C) 2004 - 2023 JSQLParser
66
* %%
7-
* This program is free software: you can redistribute it and/or modify
8-
* it under the terms of the GNU Lesser General Public License as
9-
* published by the Free Software Foundation, either version 2.1 of the
10-
* License, or (at your option) any later version.
11-
*
12-
* This program is distributed in the hope that it will be useful,
13-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15-
* GNU General Lesser Public License for more details.
16-
*
17-
* You should have received a copy of the GNU General Lesser Public
18-
* License along with this program. If not, see
19-
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
7+
* Dual licensed under GNU LGPL 2.1 or Apache License 2.0
208
* #L%
219
*/
22-
/*Added by Mathew on 21st Nov 2016*/
2310
package net.sf.jsqlparser.expression.operators.relational;
2411

2512
import net.sf.jsqlparser.expression.ExpressionVisitor;
@@ -30,10 +17,6 @@ public ContainedBy() {
3017
super("<&");
3118
}
3219

33-
public ContainedBy(String operator) {
34-
super(operator);
35-
}
36-
3720
@Override
3821
public void accept(ExpressionVisitor expressionVisitor) {
3922
expressionVisitor.visit(this);

src/main/java/net/sf/jsqlparser/expression/operators/relational/Contains.java

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,12 @@
1-
/*
1+
/*-
22
* #%L
33
* JSQLParser library
44
* %%
5-
* Copyright (C) 2004 - 2013 JSQLParser
5+
* Copyright (C) 2004 - 2023 JSQLParser
66
* %%
7-
* This program is free software: you can redistribute it and/or modify
8-
* it under the terms of the GNU Lesser General Public License as
9-
* published by the Free Software Foundation, either version 2.1 of the
10-
* License, or (at your option) any later version.
11-
*
12-
* This program is distributed in the hope that it will be useful,
13-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15-
* GNU General Lesser Public License for more details.
16-
*
17-
* You should have received a copy of the GNU General Lesser Public
18-
* License along with this program. If not, see
19-
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
7+
* Dual licensed under GNU LGPL 2.1 or Apache License 2.0
208
* #L%
219
*/
22-
/*Added by Mathew on 21st Nov 2016*/
2310
package net.sf.jsqlparser.expression.operators.relational;
2411

2512
import net.sf.jsqlparser.expression.ExpressionVisitor;
@@ -30,10 +17,6 @@ public Contains() {
3017
super("&>");
3118
}
3219

33-
public Contains(String operator) {
34-
super(operator);
35-
}
36-
3720
@Override
3821
public void accept(ExpressionVisitor expressionVisitor) {
3922
expressionVisitor.visit(this);

src/main/java/net/sf/jsqlparser/expression/operators/relational/DoubleAnd.java

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,12 @@
1-
/*
1+
/*-
22
* #%L
33
* JSQLParser library
44
* %%
5-
* Copyright (C) 2004 - 2013 JSQLParser
5+
* Copyright (C) 2004 - 2023 JSQLParser
66
* %%
7-
* This program is free software: you can redistribute it and/or modify
8-
* it under the terms of the GNU Lesser General Public License as
9-
* published by the Free Software Foundation, either version 2.1 of the
10-
* License, or (at your option) any later version.
11-
*
12-
* This program is distributed in the hope that it will be useful,
13-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15-
* GNU General Lesser Public License for more details.
16-
*
17-
* You should have received a copy of the GNU General Lesser Public
18-
* License along with this program. If not, see
19-
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
7+
* Dual licensed under GNU LGPL 2.1 or Apache License 2.0
208
* #L%
219
*/
22-
/*Added by Mathew on 1st Aug 2016*/
2310
package net.sf.jsqlparser.expression.operators.relational;
2411

2512
import net.sf.jsqlparser.expression.ExpressionVisitor;
@@ -30,10 +17,6 @@ public DoubleAnd() {
3017
super("&&");
3118
}
3219

33-
public DoubleAnd(String operator) {
34-
super(operator);
35-
}
36-
3720
@Override
3821
public void accept(ExpressionVisitor expressionVisitor) {
3922
expressionVisitor.visit(this);

src/main/java/net/sf/jsqlparser/util/TablesNamesFinder.java

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@
7878
import net.sf.jsqlparser.expression.operators.conditional.OrExpression;
7979
import net.sf.jsqlparser.expression.operators.conditional.XorExpression;
8080
import net.sf.jsqlparser.expression.operators.relational.Between;
81+
import net.sf.jsqlparser.expression.operators.relational.ContainedBy;
82+
import net.sf.jsqlparser.expression.operators.relational.Contains;
83+
import net.sf.jsqlparser.expression.operators.relational.DoubleAnd;
8184
import net.sf.jsqlparser.expression.operators.relational.EqualsTo;
8285
import net.sf.jsqlparser.expression.operators.relational.ExistsExpression;
8386
import net.sf.jsqlparser.expression.operators.relational.ExpressionList;
@@ -469,26 +472,17 @@ public void visit(Multiplication multiplication) {
469472
public void visit(NotEqualsTo notEqualsTo) {
470473
visitBinaryExpression(notEqualsTo);
471474
}
472-
473-
/* Added by Mathew on 21st Nov 2016
474-
*
475-
*/
475+
476476
@Override
477477
public void visit(DoubleAnd doubleAnd) {
478478
visitBinaryExpression(doubleAnd);
479479
}
480-
481-
/* Added by Mathew on 21st Nov 2016
482-
*
483-
*/
480+
484481
@Override
485482
public void visit(Contains contains) {
486483
visitBinaryExpression(contains);
487484
}
488-
489-
/* Added by Mathew on 21st Nov 2016
490-
*
491-
*/
485+
492486
@Override
493487
public void visit(ContainedBy containedBy) {
494488
visitBinaryExpression(containedBy);

0 commit comments

Comments
 (0)