Skip to content

Commit

Permalink
kill joinFromExpr
Browse files Browse the repository at this point in the history
  • Loading branch information
lihaoyi committed Dec 11, 2023
1 parent ebeb340 commit d0f3836
Show file tree
Hide file tree
Showing 8 changed files with 6 additions and 28 deletions.
6 changes: 0 additions & 6 deletions scalasql/query/src/CompoundSelect.scala
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ class CompoundSelect[Q, R](
)(implicit qr: Queryable.Row[Q, R]) = newCompoundSelect(lhs, compoundOps, orderBy, limit, offset)
override protected def expr = Joinable.toFromExpr(lhs)._2

protected override def joinableToSelect = this

protected def selectToSimpleSelect() = this.subquery

Expand Down Expand Up @@ -93,11 +92,6 @@ class CompoundSelect[Q, R](
SubqueryRef.Wrapped.exprAliases(lhs, prevContext)
}

override def joinFromExpr = {
val otherSelect = joinableToSelect
val otherFrom = new SubqueryRef(otherSelect)
(otherFrom, WithSqlExpr.get(otherSelect))
}
}

object CompoundSelect {
Expand Down
2 changes: 1 addition & 1 deletion scalasql/query/src/JoinOps.scala
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ trait JoinOps[C[_, _], Q, R] extends WithSqlExpr[Q] {
on: Option[(Q, Q2) => Expr[Boolean]]
) = {

val (otherFrom, otherExpr) = other.joinFromExpr
val (otherFrom, otherExpr) = Joinable.toFromExpr(other)

val otherOn = on.map(_(expr, otherExpr))
val otherJoin = Join(joinPrefix, Seq(Join.From(otherFrom, otherOn)))
Expand Down
1 change: 0 additions & 1 deletion scalasql/query/src/Joinable.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ trait Joinable[Q, R] {

protected def joinableToFromExpr: (Context.From, Q)

def joinFromExpr: (Context.From, Q)
/**
* Version of `crossJoin` meant for usage in `for`-comprehensions
*/
Expand Down
3 changes: 1 addition & 2 deletions scalasql/query/src/Select.scala
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ trait Select[Q, R]
with SubqueryRef.Wrapped {

protected def dialect: DialectTypeMappers
protected def joinableToFromExpr = (new SubqueryRef(this), expr)
protected def joinableToFromExpr: (Context.From, Q) = (new SubqueryRef(this), expr)
protected def newCompoundSelect[Q, R](
lhs: SimpleSelect[Q, R],
compoundOps: Seq[CompoundSelect.Op[Q, R]],
Expand All @@ -66,7 +66,6 @@ trait Select[Q, R]
new SimpleSelect(expr, exprPrefix, preserveAll, from, joins, where, groupBy0)

def qr: Queryable.Row[Q, R]
protected def joinableToSelect = this

/**
* Causes this [[Select]] to ignore duplicate rows, translates into SQL `SELECT DISTINCT`
Expand Down
2 changes: 0 additions & 2 deletions scalasql/query/src/SimpleSelect.scala
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ class SimpleSelect[Q, R](
val groupBy0: Option[GroupBy]
)(implicit val qr: Queryable.Row[Q, R], protected val dialect: DialectTypeMappers)
extends Select[Q, R] {
protected override def joinableToSelect = this

protected def copy[Q, R](
expr: Q = this.expr,
Expand Down Expand Up @@ -233,7 +232,6 @@ class SimpleSelect[Q, R](
Seq(qr.construct(args))
}

override def joinFromExpr = (from.head, expr)
}

object SimpleSelect {
Expand Down
5 changes: 0 additions & 5 deletions scalasql/query/src/Values.scala
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,6 @@ class Values[Q, R](val ts: Seq[R])(
.toMap
}

override def joinFromExpr = {
val otherSelect = joinableToSelect
val otherFrom = new SubqueryRef(otherSelect)
(otherFrom, WithSqlExpr.get(otherSelect))
}
}

object Values {
Expand Down
10 changes: 4 additions & 6 deletions scalasql/query/src/WithCte.scala
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class WithCte[Q, R](
Query.construct(rhs, args)

def joinFromExpr = {
val otherSelect = joinableToSelect
val otherSelect = selectToSimpleSelect()
(new SubqueryRef(otherSelect), WithSqlExpr.get(otherSelect))
}
}
Expand All @@ -66,13 +66,11 @@ object WithCte {
protected val dialect: DialectTypeMappers
) extends Select.Proxy[Q, R] {

def joinFromExpr = {
val otherSelect = joinableToSelect
val otherFrom = otherSelect.asInstanceOf[SimpleSelect[_, _]].from.head
(otherFrom, WithSqlExpr.get(otherSelect))
override def joinableToFromExpr = {
val otherFrom = lhsSubQueryRef
(otherFrom, WithSqlExpr.get(lhs))
}

protected override def joinableToSelect = selectToSimpleSelect()
override protected def selectToSimpleSelect(): SimpleSelect[Q, R] = {
Select.newSimpleSelect[Q, R](
lhs,
Expand Down
5 changes: 0 additions & 5 deletions scalasql/src/dialects/TableOps.scala
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,4 @@ class TableOps[V[_[_]]](val t: Table[V])(implicit dialect: Dialect)
new Delete.Impl(expr, filter(Table.metadata(t).vExpr(ref, dialect)), ref)
}

override def joinFromExpr = {
val (ref, expr) = toFromExpr0

(ref, expr.asInstanceOf[V[Expr]])
}
}

0 comments on commit d0f3836

Please sign in to comment.