@@ -1061,10 +1061,13 @@ def database_engine(self, p):
1061
1061
@_ ('select UNION select' ,
1062
1062
'union UNION select' ,
1063
1063
'select UNION ALL select' ,
1064
- 'union UNION ALL select' )
1064
+ 'union UNION ALL select' ,
1065
+ 'select UNION DISTINCT select' ,
1066
+ 'union UNION DISTINCT select' )
1065
1067
def union (self , p ):
1066
1068
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 )
1068
1071
1069
1072
@_ ('select INTERSECT select' ,
1070
1073
'union INTERSECT select' ,
@@ -1074,15 +1077,19 @@ def union(self, p):
1074
1077
'union INTERSECT DISTINCT select' )
1075
1078
def union (self , p ):
1076
1079
unique = not hasattr (p , 'ALL' )
1077
- return Intersect (left = p [0 ], right = p [- 1 ], unique = unique )
1080
+ distinct_key = hasattr (p , 'DISTINCT' )
1081
+ return Intersect (left = p [0 ], right = p [- 1 ], unique = unique , distinct_key = distinct_key )
1078
1082
1079
1083
@_ ('select EXCEPT select' ,
1080
1084
'union EXCEPT select' ,
1081
1085
'select EXCEPT ALL select' ,
1082
- 'union EXCEPT ALL select' )
1086
+ 'union EXCEPT ALL select' ,
1087
+ 'select EXCEPT DISTINCT select' ,
1088
+ 'union EXCEPT DISTINCT select' )
1083
1089
def union (self , p ):
1084
1090
unique = not hasattr (p , 'ALL' )
1085
- 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 )
1086
1093
1087
1094
# tableau
1088
1095
@_ ('LPAREN select RPAREN' )
0 commit comments