Skip to content

Commit

Permalink
Mark renderSql as private[scalasql] instead of protected.
Browse files Browse the repository at this point in the history
The Scala 3 compiler reported an error:

```scala
-- [E173] Reference Error: /Users/matt/scalasql/scalasql/query/src/Query.scala:74:50
74 |    def renderSql(q: Q, ctx: Context): SqlStr = q.renderSql(ctx)
   |                                                ^^^^^^^^^^^
   |method renderSql in trait Renderable cannot be accessed as a member of (q : Q) from class QueryQueryable.
   | Access to protected method renderSql not permitted because enclosing class QueryQueryable in object Query
   | is not a subclass of trait Renderable in object SqlStr where target is defined
   |
   |where:    Q is a type in class QueryQueryable with bounds <: scalasql.query.Query[R]
```
  • Loading branch information
mrdziuban committed May 23, 2024
1 parent afed97f commit 8e767e3
Show file tree
Hide file tree
Showing 15 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion scalasql/core/src/Expr.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import scalasql.core.SqlStr.SqlStringSyntax
* a Scala value of a particular type [[T]]
*/
trait Expr[T] extends SqlStr.Renderable {
protected final def renderSql(ctx: Context): SqlStr = {
private[scalasql] final def renderSql(ctx: Context): SqlStr = {
ctx.exprNaming.get(this.exprIdentity).getOrElse(renderToSql0(ctx))
}

Expand Down
4 changes: 2 additions & 2 deletions scalasql/core/src/SqlStr.scala
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class SqlStr(
def withCompleteQuery(v: Boolean) = new SqlStr(queryParts, interps, v, referencedExprs)
override def toString = SqlStr.flatten(this).renderSql(false)

override protected def renderSql(ctx: Context): SqlStr = this
override private[scalasql] def renderSql(ctx: Context): SqlStr = this
}

object SqlStr {
Expand Down Expand Up @@ -211,7 +211,7 @@ object SqlStr {
new SqlStr(Array(s), emptyInterpArray, false, referencedExprs)

trait Renderable {
protected def renderSql(ctx: Context): SqlStr
private[scalasql] def renderSql(ctx: Context): SqlStr
}

object Renderable {
Expand Down
2 changes: 1 addition & 1 deletion scalasql/query/src/Aggregate.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Aggregate[Q, R](
) extends Query.DelegateQueryable[Q, R] {

protected override def queryIsSingleRow: Boolean = true
protected def renderSql(ctx: Context) = toSqlStr0(ctx)
private[scalasql] def renderSql(ctx: Context) = toSqlStr0(ctx)

override protected def queryConstruct(args: Queryable.ResultSetIterator): R = construct0(args)
}
2 changes: 1 addition & 1 deletion scalasql/query/src/Delete.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ object Delete {
) extends Delete[Q] {
import dialect._

protected def renderSql(ctx: Context) = new Renderer(table, filter, ctx).render()
private[scalasql] def renderSql(ctx: Context) = new Renderer(table, filter, ctx).render()

protected def queryConstruct(args: Queryable.ResultSetIterator): Int = args.get(IntType)
}
Expand Down
2 changes: 1 addition & 1 deletion scalasql/query/src/GetGeneratedKeys.scala
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ object GetGeneratedKeys {
protected override def queryIsSingleRow = false
protected override def queryIsExecuteUpdate = true

override protected def renderSql(ctx: Context): SqlStr = Renderable.renderSql(base)(ctx)
override private[scalasql] def renderSql(ctx: Context): SqlStr = Renderable.renderSql(base)(ctx)

override protected def queryGetGeneratedKeys: Option[Queryable.Row[_, _]] = Some(qr)
}
Expand Down
2 changes: 1 addition & 1 deletion scalasql/query/src/InsertColumns.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ object InsertColumns {
def table = insert.table
protected def expr: V[Column] = WithSqlExpr.get(insert)

protected override def renderSql(ctx: Context) =
private[scalasql] override def renderSql(ctx: Context) =
new Renderer(columns, ctx, valuesLists, Table.name(table.value)).render()

override protected def queryConstruct(args: Queryable.ResultSetIterator): Int =
Expand Down
2 changes: 1 addition & 1 deletion scalasql/query/src/InsertSelect.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ object InsertSelect {

def table = insert.table

protected override def renderSql(ctx: Context) =
private[scalasql] override def renderSql(ctx: Context) =
new Renderer(select, select.qr.walkExprs(columns), ctx, Table.name(table.value))
.render()

Expand Down
2 changes: 1 addition & 1 deletion scalasql/query/src/InsertValues.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ object InsertValues {
override protected def queryConstruct(args: Queryable.ResultSetIterator): Int =
args.get(dialect.IntType)

override protected def renderSql(ctx: Context): SqlStr = {
override private[scalasql] def renderSql(ctx: Context): SqlStr = {
new Renderer(
Table.name(insert.table.value),
Table.labels(insert.table.value),
Expand Down
4 changes: 2 additions & 2 deletions scalasql/query/src/OnConflict.scala
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ object OnConflict {
) extends Query.DelegateQuery[R]
with Returning.InsertBase[Q] {
protected def expr = WithSqlExpr.get(query)
protected def renderSql(ctx: Context) = {
private[scalasql] def renderSql(ctx: Context) = {
val str = Renderable.renderSql(query)(ctx)
str + sql" ON CONFLICT (${SqlStr.join(columns.map(c => SqlStr.raw(c.name)), SqlStr.commaSep)}) DO NOTHING"
}
Expand All @@ -40,7 +40,7 @@ object OnConflict {
) extends Query.DelegateQuery[R]
with Returning.InsertBase[Q] {
protected def expr = WithSqlExpr.get(query)
protected def renderSql(ctx: Context) = {
private[scalasql] def renderSql(ctx: Context) = {
implicit val implicitCtx = Context.compute(ctx, Nil, Some(table))
val str = Renderable.renderSql(query)
val columnsStr = SqlStr.join(columns.map(c => SqlStr.raw(c.name)), SqlStr.commaSep)
Expand Down
2 changes: 1 addition & 1 deletion scalasql/query/src/Query.scala
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ object Query {
class Single[R](protected val query: Query[Seq[R]]) extends Query.DelegateQuery[R] {
protected override def queryIsSingleRow: Boolean = true

protected def renderSql(ctx: Context): SqlStr = Renderable.renderSql(query)(ctx)
private[scalasql] def renderSql(ctx: Context): SqlStr = Renderable.renderSql(query)(ctx)
protected override def queryConstruct(args: Queryable.ResultSetIterator): R =
query.queryConstruct(args).asInstanceOf[R]
}
Expand Down
2 changes: 1 addition & 1 deletion scalasql/query/src/Returning.scala
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ object Returning {

override def queryIsSingleRow = false

protected override def renderSql(ctx0: Context) = {
private[scalasql] override def renderSql(ctx0: Context) = {
implicit val implicitCtx = Context.compute(ctx0, Nil, Some(returnable.table))

val prefix = Renderable.renderSql(returnable)
Expand Down
2 changes: 1 addition & 1 deletion scalasql/query/src/Select.scala
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ trait Select[Q, R]
*/
def take(n: Int): Select[Q, R]

protected def renderSql(ctx: Context): SqlStr = {
private[scalasql] def renderSql(ctx: Context): SqlStr = {
val renderer = selectRenderer(ctx)

renderer.render(LiveExprs.none).withCompleteQuery(true)
Expand Down
2 changes: 1 addition & 1 deletion scalasql/query/src/Update.scala
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ object Update {
)
}

protected override def renderSql(ctx: Context): SqlStr =
private[scalasql] override def renderSql(ctx: Context): SqlStr =
new Renderer(joins, table, set0, where, ctx).render()

override protected def queryConstruct(args: Queryable.ResultSetIterator): Int = {
Expand Down
2 changes: 1 addition & 1 deletion scalasql/query/src/WithCte.scala
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ object WithCte {
}
}

override protected def renderSql(ctx: Context): SqlStr = {
override private[scalasql] def renderSql(ctx: Context): SqlStr = {
SqlStr.raw(ctx.fromNaming(lhsSubQueryRef))
}
}
Expand Down
4 changes: 2 additions & 2 deletions scalasql/src/dialects/MySqlDialect.scala
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ object MySqlDialect extends MySqlDialect {
)(implicit qr: Queryable.Row[Q, R], dialect: scalasql.core.DialectTypeMappers) =
new Update(expr, table, set0, joins, where)

protected override def renderSql(ctx: Context) = {
private[scalasql] override def renderSql(ctx: Context) = {
new UpdateRenderer(this.joins, this.table, this.set0, this.where, ctx).render()
}

Expand Down Expand Up @@ -271,7 +271,7 @@ object MySqlDialect extends MySqlDialect {
protected def query = insert.query
override def queryIsExecuteUpdate = true

protected def renderSql(ctx: Context) = {
private[scalasql] def renderSql(ctx: Context) = {
implicit val implicitCtx = Context.compute(ctx, Nil, Some(table))
val str = Renderable.renderSql(insert.query)

Expand Down

0 comments on commit 8e767e3

Please sign in to comment.