Skip to content

Commit eb67a95

Browse files
authored
Merge pull request #88 from forrest79/postgresql-cast-operator
2 parents 28ffe8e + 4809d13 commit eb67a95

File tree

7 files changed

+16
-0
lines changed

7 files changed

+16
-0
lines changed

src/Tokenizer.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -710,6 +710,7 @@ final class Tokenizer
710710
private $boundaries = [
711711
',',
712712
';',
713+
'::', // PostgreSQL cast operator
713714
':',
714715
')',
715716
'(',

tests/clihighlight.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -975,3 +975,6 @@
975975
ORDER BY
976976
hire_date
977977
);
978+
---
979+
SELECT
980+
1 :: text;

tests/compress.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,3 +91,5 @@
9191
WITH cte1 AS (SELECT a, b FROM table1), cte2 AS (SELECT c, d FROM table2) SELECT b, d FROM cte1 JOIN cte2 WHERE cte1.a = cte2.c;
9292
---
9393
SELECT a, GROUP_CONCAT(b, '.') OVER (ORDER BY c GROUPS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW EXCLUDE NO OTHERS) AS no_others, GROUP_CONCAT(b, '.') OVER (ORDER BY c GROUPS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW EXCLUDE CURRENT ROW) AS current_row, GROUP_CONCAT(b, '.') OVER (ORDER BY c GROUPS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW EXCLUDE GROUP) AS grp, GROUP_CONCAT(b, '.') OVER (ORDER BY c GROUPS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW EXCLUDE TIES) AS tie, GROUP_CONCAT(b, '.') FILTER (WHERE c != 'two') OVER (ORDER BY a) AS filtered, CONVERT(VARCHAR(20), AVG(SalesYTD) OVER (PARTITION BY TerritoryID ORDER BY DATEPART(yy, ModifiedDate)), 1) AS MovingAvg, AVG(starting_salary) OVER w2 AVG, MIN(starting_salary) OVER w2 MIN_STARTING_SALARY, MAX(starting_salary) OVER (w1 ORDER BY hire_date), LISTAGG(arg, ',') OVER (PARTITION BY part ORDER BY ord ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING) AS LISTAGG_ROWS, LISTAGG(arg, ',') OVER (PARTITION BY part ORDER BY ord RANGE BETWEEN 1 PRECEDING AND 1 FOLLOWING) AS LISTAGG_RANGE, MIN(Revenue) OVER (PARTITION BY DepartmentID ORDER BY RevenueYear ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) AS MinRevenueBeyond FROM t1 WINDOW w1 AS (PARTITION BY department, division), w2 AS (w1 ORDER BY hire_date);
94+
---
95+
SELECT 1::text;

tests/format-highlight.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -975,3 +975,6 @@
975975
<span style="font-weight:bold;">ORDER BY</span>
976976
<span style="color: #333;">hire_date</span>
977977
)<span >;</span></pre>
978+
---
979+
<pre style="color: black; background-color: white;"><span style="font-weight:bold;">SELECT</span>
980+
<span style="color: green;">1</span> <span >::</span> <span style="color: #333;">text</span><span >;</span></pre>

tests/format.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -973,3 +973,6 @@
973973
ORDER BY
974974
hire_date
975975
);
976+
---
977+
SELECT
978+
1 :: text;

tests/highlight.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,3 +302,5 @@
302302
<span style="font-weight:bold;">MIN</span>(<span style="color: #333;">Revenue</span>) <span style="font-weight:bold;">OVER</span> (<span style="font-weight:bold;">PARTITION BY</span> <span style="color: #333;">DepartmentID</span> <span style="font-weight:bold;">ORDER BY</span> <span style="color: #333;">RevenueYear</span> <span style="font-weight:bold;">ROWS</span> <span style="font-weight:bold;">BETWEEN</span> <span style="font-weight:bold;">CURRENT ROW</span> <span style="font-weight:bold;">AND</span> <span style="font-weight:bold;">UNBOUNDED</span> <span style="font-weight:bold;">FOLLOWING</span>) <span style="font-weight:bold;">AS</span> <span style="color: #333;">MinRevenueBeyond</span>
303303
<span style="font-weight:bold;">FROM</span> <span style="color: #333;">t1</span>
304304
<span style="font-weight:bold;">WINDOW</span> <span style="color: #333;">w1</span> <span style="font-weight:bold;">AS</span> (<span style="font-weight:bold;">PARTITION BY</span> <span style="color: #333;">department</span><span >,</span> <span style="color: #333;">division</span>)<span >,</span> <span style="color: #333;">w2</span> <span style="font-weight:bold;">AS</span> (<span style="color: #333;">w1</span> <span style="font-weight:bold;">ORDER BY</span> <span style="color: #333;">hire_date</span>)<span >;</span></pre>
305+
---
306+
<pre style="color: black; background-color: white;"><span style="font-weight:bold;">SELECT</span> <span style="color: green;">1</span><span >::</span><span style="color: #333;">text</span><span >;</span></pre>

tests/sql.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,3 +302,5 @@ SELECT a,
302302
MIN(Revenue) OVER (PARTITION BY DepartmentID ORDER BY RevenueYear ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) AS MinRevenueBeyond
303303
FROM t1
304304
WINDOW w1 AS (PARTITION BY department, division), w2 AS (w1 ORDER BY hire_date);
305+
---
306+
SELECT 1::text;

0 commit comments

Comments
 (0)