@@ -57,21 +57,24 @@ trait Select[Q, R]
57
57
protected def newSimpleSelect [Q , R ](
58
58
expr : Q ,
59
59
exprPrefix : Option [Context => SqlStr ],
60
+ exprSuffix : Option [Context => SqlStr ],
60
61
preserveAll : Boolean ,
61
62
from : Seq [Context .From ],
62
63
joins : Seq [Join ],
63
64
where : Seq [Expr [? ]],
64
65
groupBy0 : Option [GroupBy ]
65
66
)(implicit qr : Queryable .Row [Q , R ], dialect : DialectTypeMappers ): SimpleSelect [Q , R ] =
66
- new SimpleSelect (expr, exprPrefix, preserveAll, from, joins, where, groupBy0)
67
+ new SimpleSelect (expr, exprPrefix, exprSuffix, preserveAll, from, joins, where, groupBy0)
67
68
68
69
def qr : Queryable .Row [Q , R ]
69
70
70
71
/**
71
72
* Causes this [[Select ]] to ignore duplicate rows, translates into SQL `SELECT DISTINCT`
72
73
*/
73
74
def distinct : Select [Q , R ] = selectWithExprPrefix(true , _ => sql " DISTINCT " )
75
+
74
76
protected def selectWithExprPrefix (preserveAll : Boolean , s : Context => SqlStr ): Select [Q , R ]
77
+ protected def selectWithExprSuffix (preserveAll : Boolean , s : Context => SqlStr ): Select [Q , R ]
75
78
76
79
protected def subqueryRef (implicit qr : Queryable .Row [Q , R ]) = new SubqueryRef (this )
77
80
@@ -227,7 +230,7 @@ trait Select[Q, R]
227
230
* in this [[Select ]]
228
231
*/
229
232
def subquery : SimpleSelect [Q , R ] = {
230
- newSimpleSelect(expr, None , false , Seq (subqueryRef(qr)), Nil , Nil , None )(qr, dialect)
233
+ newSimpleSelect(expr, None , None , false , Seq (subqueryRef(qr)), Nil , Nil , None )(qr, dialect)
231
234
}
232
235
233
236
/**
@@ -278,19 +281,23 @@ object Select {
278
281
lhs : Select [Q , R ],
279
282
expr : Q ,
280
283
exprPrefix : Option [Context => SqlStr ],
284
+ exprSuffix : Option [Context => SqlStr ],
281
285
preserveAll : Boolean ,
282
286
from : Seq [Context .From ],
283
287
joins : Seq [Join ],
284
288
where : Seq [Expr [? ]],
285
289
groupBy0 : Option [GroupBy ]
286
290
)(implicit qr : Queryable .Row [Q , R ], dialect : DialectTypeMappers ): SimpleSelect [Q , R ] =
287
- lhs.newSimpleSelect(expr, exprPrefix, preserveAll, from, joins, where, groupBy0)
291
+ lhs.newSimpleSelect(expr, exprPrefix, exprSuffix, preserveAll, from, joins, where, groupBy0)
288
292
289
293
def toSimpleFrom [Q , R ](s : Select [Q , R ]) = s.selectToSimpleSelect()
290
294
291
295
def withExprPrefix [Q , R ](s : Select [Q , R ], preserveAll : Boolean , str : Context => SqlStr ) =
292
296
s.selectWithExprPrefix(preserveAll, str)
293
297
298
+ def withExprSuffix [Q , R ](s : Select [Q , R ], preserveAll : Boolean , str : Context => SqlStr ) =
299
+ s.selectWithExprSuffix(preserveAll, str)
300
+
294
301
implicit class ExprSelectOps [T ](s : Select [Expr [T ], T ]) {
295
302
def sorted (implicit tm : TypeMapper [T ]): Select [Expr [T ], T ] = s.sortBy(identity)
296
303
}
@@ -303,6 +310,12 @@ object Select {
303
310
): Select [Q , R ] =
304
311
selectToSimpleSelect().selectWithExprPrefix(preserveAll, s)
305
312
313
+ override protected def selectWithExprSuffix (
314
+ preserveAll : Boolean ,
315
+ s : Context => SqlStr
316
+ ): Select [Q , R ] =
317
+ selectToSimpleSelect().selectWithExprSuffix(preserveAll, s)
318
+
306
319
override def map [Q2 , R2 ](f : Q => Q2 )(implicit qr : Queryable .Row [Q2 , R2 ]): Select [Q2 , R2 ] =
307
320
selectToSimpleSelect().map(f)
308
321
0 commit comments