Skip to content

Commit 5d6b60b

Browse files
committed
Add AND and OR groups and conditional comment blocks to Select test cases
1 parent 3fe8524 commit 5d6b60b

File tree

2 files changed

+30
-19
lines changed

2 files changed

+30
-19
lines changed

src/test/testData/sql/formatter/FormattedSelect.sql

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,23 +24,29 @@ SELECT COUNT(DISTINCT (x))
2424
AND p.plate = s.plate
2525
/** Where */
2626
WHERE p.TYPE = DBO.FPHOTOTYPE('Star')
27-
AND (p.flags & DBO.FPHOTOFLAGS('EDGE')) = 0
28-
AND (p.psfmag_g - p.extinction_g) BETWEEN 15 AND 20
29-
AND u.propermotion > 2.
30-
/** And Group */
31-
AND (p.psfmag_g - p.extinction_g + 5 * LOG(u.propermotion / 100.) + 5 > 16.136 + 2.727 * (p.psfmag_g - p.extinction_g - (p.psfmag_i - p.extinction_i))
32-
OR p.psfmag_g - p.extinction_g - (p.psfmag_i - p.extinction_i) < 0.) ) AS o
27+
OR (p.flags & DBO.FPHOTOFLAGS('EDGE') = 0
28+
AND (p.psfmag_g - p.extinction_g) BETWEEN 15 AND 20)
29+
/*%if status == 2 */
30+
AND u.propermotion > 2.
31+
/** And Group */
32+
AND (p.psfmag_g - p.extinction_g + 5 * LOG(u.propermotion / 100.) + 5 > 16.136 + 2.727 * (p.psfmag_g - p.extinction_g - (p.psfmag_i - p.extinction_i))
33+
OR p.psfmag_g - p.extinction_g - (p.psfmag_i - p.extinction_i) < 0.)
34+
/*%end*/ ) AS o
3335
LEFT OUTER JOIN ( SELECT n.objid
3436
, MIN(n.distance) AS nearest
3537
FROM neighbors n
3638
JOIN phototag x
3739
ON n.neighborobjid = x.objid
40+
AND n.neighbormode = DBO.FPHOTOMODE('Primary')
41+
OR n.MODE = /*# "active" */'mode'
42+
AND n.status = 2
43+
AND n.flag = true
3844
WHERE n.TYPE = DBO.FPHOTOTYPE('Star')
3945
AND n.MODE = DBO.FPHOTOMODE('Primary')
40-
AND n.neighbormode = DBO.FPHOTOMODE('Primary')
41-
AND (x.TYPE = DBO.FPHOTOTYPE('Star')
42-
OR x.TYPE = DBO.FPHOTOTYPE('Galaxy'))
43-
AND x.modelmag_g BETWEEN 10 AND 21
46+
OR n.neighbormode = DBO.FPHOTOMODE('Primary')
47+
AND (x.TYPE = DBO.FPHOTOTYPE('Star')
48+
AND x.TYPE = DBO.FPHOTOTYPE('Galaxy'))
49+
OR x.modelmag_g BETWEEN 10 AND 21
4450
GROUP BY n.objid ) AS nbor
4551
ON o.objid = nbor.objid
46-
WHERE p.list IN /* params */(1, 2, 3)
52+
WHERE p.params IN /* params */(1, 2, 3)

src/test/testData/sql/formatter/Select.sql

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,33 +25,38 @@ SELECT COUNT( DISTINCT (x)),o.*
2525
ON p.objid = s.bestobjid AND p.plate = s.plate
2626
/** Where */
2727
WHERE p.TYPE = DBO.FPHOTOTYPE('Star')
28-
AND (p.flags & DBO.FPHOTOFLAGS('EDGE')) = 0
28+
29+
OR (p.flags & DBO.FPHOTOFLAGS('EDGE') = 0
2930

30-
AND (p.psfmag_g - p.extinction_g) BETWEEN 15 AND 20
31+
AND (p.psfmag_g - p.extinction_g) BETWEEN 15 AND 20)
32+
/*%if status == 2 */
3133
AND u.propermotion > 2.
3234
/** And Group */
3335
AND (p.psfmag_g - p.extinction_g + 5 * LOG(u.propermotion / 100.) + 5 > 16.136 + 2.727 * (p.psfmag_g - p.extinction_g - (p.psfmag_i - p.extinction_i))
3436

35-
OR p.psfmag_g - p.extinction_g - (p.psfmag_i - p.extinction_i) < 0.) ) AS o
37+
OR p.psfmag_g - p.extinction_g - (p.psfmag_i - p.extinction_i) < 0.)/*%end*/) AS o
3638

3739
LEFT OUTER JOIN ( SELECT n.objid
3840
, MIN(n.distance) AS nearest
3941

4042
FROM neighbors n
4143
JOIN phototag x
4244
ON n.neighborobjid = x.objid
43-
45+
AND n.neighbormode = DBO.FPHOTOMODE('Primary')
46+
OR n.MODE = /*# "active" */'mode'
47+
AND n.status =2
48+
AND n.flag = true
4449
WHERE n.TYPE = DBO.FPHOTOTYPE('Star')
4550

4651
AND n.MODE = DBO.FPHOTOMODE('Primary')
47-
AND n.neighbormode = DBO.FPHOTOMODE('Primary')
52+
OR n.neighbormode = DBO.FPHOTOMODE('Primary')
4853
AND (x.TYPE = DBO.FPHOTOTYPE('Star')
4954

50-
OR x.TYPE = DBO.FPHOTOTYPE('Galaxy'))
51-
AND x.modelmag_g BETWEEN 10 AND 21
55+
AND x.TYPE = DBO.FPHOTOTYPE('Galaxy'))
56+
OR x.modelmag_g BETWEEN 10 AND 21
5257

5358
GROUP BY n.objid ) AS nbor
5459
ON o.objid = nbor.objid
55-
WHERE p.list IN /* params */(1
60+
WHERE p.params IN /* params */(1
5661
,2
5762
,3)

0 commit comments

Comments
 (0)