@@ -57,21 +57,24 @@ trait Select[Q, R]
5757 protected def newSimpleSelect [Q , R ](
5858 expr : Q ,
5959 exprPrefix : Option [Context => SqlStr ],
60+ exprSuffix : Option [Context => SqlStr ],
6061 preserveAll : Boolean ,
6162 from : Seq [Context .From ],
6263 joins : Seq [Join ],
6364 where : Seq [Expr [? ]],
6465 groupBy0 : Option [GroupBy ]
6566 )(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)
6768
6869 def qr : Queryable .Row [Q , R ]
6970
7071 /**
7172 * Causes this [[Select ]] to ignore duplicate rows, translates into SQL `SELECT DISTINCT`
7273 */
7374 def distinct : Select [Q , R ] = selectWithExprPrefix(true , _ => sql " DISTINCT " )
75+
7476 protected def selectWithExprPrefix (preserveAll : Boolean , s : Context => SqlStr ): Select [Q , R ]
77+ protected def selectWithExprSuffix (preserveAll : Boolean , s : Context => SqlStr ): Select [Q , R ]
7578
7679 protected def subqueryRef (implicit qr : Queryable .Row [Q , R ]) = new SubqueryRef (this )
7780
@@ -227,7 +230,7 @@ trait Select[Q, R]
227230 * in this [[Select ]]
228231 */
229232 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)
231234 }
232235
233236 /**
@@ -278,19 +281,23 @@ object Select {
278281 lhs : Select [Q , R ],
279282 expr : Q ,
280283 exprPrefix : Option [Context => SqlStr ],
284+ exprSuffix : Option [Context => SqlStr ],
281285 preserveAll : Boolean ,
282286 from : Seq [Context .From ],
283287 joins : Seq [Join ],
284288 where : Seq [Expr [? ]],
285289 groupBy0 : Option [GroupBy ]
286290 )(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)
288292
289293 def toSimpleFrom [Q , R ](s : Select [Q , R ]) = s.selectToSimpleSelect()
290294
291295 def withExprPrefix [Q , R ](s : Select [Q , R ], preserveAll : Boolean , str : Context => SqlStr ) =
292296 s.selectWithExprPrefix(preserveAll, str)
293297
298+ def withExprSuffix [Q , R ](s : Select [Q , R ], preserveAll : Boolean , str : Context => SqlStr ) =
299+ s.selectWithExprSuffix(preserveAll, str)
300+
294301 implicit class ExprSelectOps [T ](s : Select [Expr [T ], T ]) {
295302 def sorted (implicit tm : TypeMapper [T ]): Select [Expr [T ], T ] = s.sortBy(identity)
296303 }
@@ -303,6 +310,12 @@ object Select {
303310 ): Select [Q , R ] =
304311 selectToSimpleSelect().selectWithExprPrefix(preserveAll, s)
305312
313+ override protected def selectWithExprSuffix (
314+ preserveAll : Boolean ,
315+ s : Context => SqlStr
316+ ): Select [Q , R ] =
317+ selectToSimpleSelect().selectWithExprSuffix(preserveAll, s)
318+
306319 override def map [Q2 , R2 ](f : Q => Q2 )(implicit qr : Queryable .Row [Q2 , R2 ]): Select [Q2 , R2 ] =
307320 selectToSimpleSelect().map(f)
308321
0 commit comments