Skip to content

Commit 0e571d1

Browse files
committed
fixes #338
1 parent ab7e29b commit 0e571d1

File tree

4 files changed

+20
-4
lines changed

4 files changed

+20
-4
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ Also I would like to know about needed examples or documentation stuff.
4444

4545
## Extensions in the latest SNAPSHOT version 1.2
4646

47+
* support for bitwise not **~**
4748
* support for **drop view**
4849
* support for indexed JDBC parameters at multiple places
4950
* allowed **index** as object name

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
import net.sf.jsqlparser.parser.ASTNodeAccessImpl;
2525

2626
/**
27-
* It represents a "-" or "+" before an expression
27+
* It represents a "-" or "+" or "~" before an expression
2828
*/
2929
public class SignedExpression extends ASTNodeAccessImpl implements Expression {
3030

@@ -42,8 +42,8 @@ public char getSign() {
4242

4343
public final void setSign(char sign) {
4444
this.sign = sign;
45-
if (sign != '+' && sign != '-') {
46-
throw new IllegalArgumentException("illegal sign character, only + - allowed");
45+
if (sign != '+' && sign != '-' && sign != '~') {
46+
throw new IllegalArgumentException("illegal sign character, only + - ~ allowed");
4747
}
4848
}
4949

src/main/jjtree/net/sf/jsqlparser/parser/JSqlParserCC.jjt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2420,7 +2420,7 @@ Expression PrimaryExpression() #PrimaryExpression:
24202420
ColDataType type = null;
24212421
}
24222422
{
2423-
[sign="+" | sign="-"]
2423+
[sign="+" | sign="-" | sign="~"]
24242424
(
24252425
<K_NULL> { retval = new NullValue(); }
24262426

src/test/java/net/sf/jsqlparser/test/update/UpdateTest.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,4 +116,19 @@ public void testUpdateWithFunctions() throws JSQLParserException {
116116
public void testUpdateIssue508LeftShift() throws JSQLParserException {
117117
assertSqlCanBeParsedAndDeparsed("UPDATE user SET num = 1 << 1 WHERE id = 1");
118118
}
119+
120+
@Test
121+
public void testUpdateIssue338() throws JSQLParserException {
122+
assertSqlCanBeParsedAndDeparsed("UPDATE mytable SET status = (status & ~1)");
123+
}
124+
125+
@Test
126+
public void testUpdateIssue338_1() throws JSQLParserException {
127+
assertSqlCanBeParsedAndDeparsed("UPDATE mytable SET status = (status & 1)");
128+
}
129+
130+
@Test
131+
public void testUpdateIssue338_2() throws JSQLParserException {
132+
assertSqlCanBeParsedAndDeparsed("UPDATE mytable SET status = (status + 1)");
133+
}
119134
}

0 commit comments

Comments
 (0)