@@ -1061,25 +1061,35 @@ def database_engine(self, p):
10611061 @_ ('select UNION select' ,
10621062 'union UNION select' ,
10631063 'select UNION ALL select' ,
1064- 'union UNION ALL select' )
1064+ 'union UNION ALL select' ,
1065+ 'select UNION DISTINCT select' ,
1066+ 'union UNION DISTINCT select' )
10651067 def union (self , p ):
10661068 unique = not hasattr (p , 'ALL' )
1067- return Union (left = p [0 ], right = p [2 ] if unique else p [3 ], unique = unique )
1069+ distinct_key = hasattr (p , 'DISTINCT' )
1070+ return Union (left = p [0 ], right = p [- 1 ], unique = unique , distinct_key = distinct_key )
10681071
10691072 @_ ('select INTERSECT select' ,
10701073 'union INTERSECT select' ,
10711074 'select INTERSECT ALL select' ,
1072- 'union INTERSECT ALL select' )
1075+ 'union INTERSECT ALL select' ,
1076+ 'select INTERSECT DISTINCT select' ,
1077+ 'union INTERSECT DISTINCT select' )
10731078 def union (self , p ):
10741079 unique = not hasattr (p , 'ALL' )
1075- return Intersect (left = p [0 ], right = p [2 ] if unique else p [3 ], unique = unique )
1080+ distinct_key = hasattr (p , 'DISTINCT' )
1081+ return Intersect (left = p [0 ], right = p [- 1 ], unique = unique , distinct_key = distinct_key )
1082+
10761083 @_ ('select EXCEPT select' ,
10771084 'union EXCEPT select' ,
10781085 'select EXCEPT ALL select' ,
1079- 'union EXCEPT ALL select' )
1086+ 'union EXCEPT ALL select' ,
1087+ 'select EXCEPT DISTINCT select' ,
1088+ 'union EXCEPT DISTINCT select' )
10801089 def union (self , p ):
10811090 unique = not hasattr (p , 'ALL' )
1082- return Except (left = p [0 ], right = p [2 ] if unique else p [3 ], unique = unique )
1091+ distinct_key = hasattr (p , 'DISTINCT' )
1092+ return Except (left = p [0 ], right = p [- 1 ], unique = unique , distinct_key = distinct_key )
10831093
10841094 # tableau
10851095 @_ ('LPAREN select RPAREN' )
0 commit comments