Skip to content

Commit e4428ce

Browse files
committed
add bitwise ops
1 parent b87c7eb commit e4428ce

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

pegjs/sqlite.pegjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2230,7 +2230,7 @@ multiplicative_expr
22302230
}
22312231

22322232
multiplicative_operator
2233-
= "*" / "/" / "%" / "||"
2233+
= "*" / "/" / "%" / "||" / '&' / '>>' / '<<' / '^' / '|'
22342234

22352235
primary
22362236
= cast_expr

test/sqlite.spec.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,4 +289,11 @@ describe('sqlite', () => {
289289
FROM response_sources rs`
290290
expect(getParsedSql(sql)).to.be.equal(`SELECT CASE WHEN "rs"."url" LIKE 'http://%' THEN SUBSTR("rs"."url", 8, INSTR(SUBSTR("rs"."url", 8), '/') - 1) WHEN "rs"."url" LIKE 'https://%' THEN SUBSTR("rs"."url", 9, INSTR(SUBSTR("rs"."url", 9), '/') - 1) ELSE SUBSTR("rs"."url", 1, INSTR("rs"."url", '/') - 1) END AS "domain", COUNT(*) AS "total_citations", COUNT(DISTINCT "mr"."model_id") AS "models_citing", COUNT(DISTINCT "mr"."response_id") AS "responses_citing", GROUP_CONCAT(DISTINCT "m"."model_name") AS "citing_models", AVG("mr"."brand_visibility_score") AS "avg_visibility_score", AVG("mr"."recommendation_quality_score") AS "avg_recommendation_quality" FROM "response_sources" AS "rs"`)
291291
})
292+
it('should support bitwise operators', () => {
293+
const bitwiseOperators = ['&', '|', '<<', '>>']
294+
bitwiseOperators.forEach(operator => {
295+
const sql = `SELECT * FROM "table_name" WHERE "column_name" ${operator} 5 = 10`
296+
expect(getParsedSql(sql)).to.be.equal(sql)
297+
});
298+
});
292299
})

0 commit comments

Comments
 (0)