From 8e767e3e0238b9af54bf8e0c4210d4af683aa79f Mon Sep 17 00:00:00 2001 From: Matt Dziuban Date: Wed, 22 May 2024 12:36:40 -0400 Subject: [PATCH] Mark `renderSql` as `private[scalasql]` instead of `protected`. 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] ``` --- scalasql/core/src/Expr.scala | 2 +- scalasql/core/src/SqlStr.scala | 4 ++-- scalasql/query/src/Aggregate.scala | 2 +- scalasql/query/src/Delete.scala | 2 +- scalasql/query/src/GetGeneratedKeys.scala | 2 +- scalasql/query/src/InsertColumns.scala | 2 +- scalasql/query/src/InsertSelect.scala | 2 +- scalasql/query/src/InsertValues.scala | 2 +- scalasql/query/src/OnConflict.scala | 4 ++-- scalasql/query/src/Query.scala | 2 +- scalasql/query/src/Returning.scala | 2 +- scalasql/query/src/Select.scala | 2 +- scalasql/query/src/Update.scala | 2 +- scalasql/query/src/WithCte.scala | 2 +- scalasql/src/dialects/MySqlDialect.scala | 4 ++-- 15 files changed, 18 insertions(+), 18 deletions(-) diff --git a/scalasql/core/src/Expr.scala b/scalasql/core/src/Expr.scala index a35f5e31..973f099b 100644 --- a/scalasql/core/src/Expr.scala +++ b/scalasql/core/src/Expr.scala @@ -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)) } diff --git a/scalasql/core/src/SqlStr.scala b/scalasql/core/src/SqlStr.scala index 1f1ea7ef..e90809f8 100644 --- a/scalasql/core/src/SqlStr.scala +++ b/scalasql/core/src/SqlStr.scala @@ -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 { @@ -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 { diff --git a/scalasql/query/src/Aggregate.scala b/scalasql/query/src/Aggregate.scala index a04a2eb1..f8369be6 100644 --- a/scalasql/query/src/Aggregate.scala +++ b/scalasql/query/src/Aggregate.scala @@ -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) } diff --git a/scalasql/query/src/Delete.scala b/scalasql/query/src/Delete.scala index 111f3131..447bb09f 100644 --- a/scalasql/query/src/Delete.scala +++ b/scalasql/query/src/Delete.scala @@ -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) } diff --git a/scalasql/query/src/GetGeneratedKeys.scala b/scalasql/query/src/GetGeneratedKeys.scala index 13f9ef4c..bdba05af 100644 --- a/scalasql/query/src/GetGeneratedKeys.scala +++ b/scalasql/query/src/GetGeneratedKeys.scala @@ -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) } diff --git a/scalasql/query/src/InsertColumns.scala b/scalasql/query/src/InsertColumns.scala index d5969a6c..c58b9f20 100644 --- a/scalasql/query/src/InsertColumns.scala +++ b/scalasql/query/src/InsertColumns.scala @@ -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 = diff --git a/scalasql/query/src/InsertSelect.scala b/scalasql/query/src/InsertSelect.scala index 99794ba2..aaefc7cf 100644 --- a/scalasql/query/src/InsertSelect.scala +++ b/scalasql/query/src/InsertSelect.scala @@ -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() diff --git a/scalasql/query/src/InsertValues.scala b/scalasql/query/src/InsertValues.scala index 8b350deb..ec96bf99 100644 --- a/scalasql/query/src/InsertValues.scala +++ b/scalasql/query/src/InsertValues.scala @@ -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), diff --git a/scalasql/query/src/OnConflict.scala b/scalasql/query/src/OnConflict.scala index fdef2fa1..c414d952 100644 --- a/scalasql/query/src/OnConflict.scala +++ b/scalasql/query/src/OnConflict.scala @@ -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" } @@ -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) diff --git a/scalasql/query/src/Query.scala b/scalasql/query/src/Query.scala index 43d2ea7d..cfff7b16 100644 --- a/scalasql/query/src/Query.scala +++ b/scalasql/query/src/Query.scala @@ -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] } diff --git a/scalasql/query/src/Returning.scala b/scalasql/query/src/Returning.scala index 0f0a1d44..35651ad3 100644 --- a/scalasql/query/src/Returning.scala +++ b/scalasql/query/src/Returning.scala @@ -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) diff --git a/scalasql/query/src/Select.scala b/scalasql/query/src/Select.scala index 3cac5702..ca8331be 100644 --- a/scalasql/query/src/Select.scala +++ b/scalasql/query/src/Select.scala @@ -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) diff --git a/scalasql/query/src/Update.scala b/scalasql/query/src/Update.scala index c5eff72e..d21ee915 100644 --- a/scalasql/query/src/Update.scala +++ b/scalasql/query/src/Update.scala @@ -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 = { diff --git a/scalasql/query/src/WithCte.scala b/scalasql/query/src/WithCte.scala index 994d4859..777df2d6 100644 --- a/scalasql/query/src/WithCte.scala +++ b/scalasql/query/src/WithCte.scala @@ -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)) } } diff --git a/scalasql/src/dialects/MySqlDialect.scala b/scalasql/src/dialects/MySqlDialect.scala index 1e771f9a..e41dc854 100644 --- a/scalasql/src/dialects/MySqlDialect.scala +++ b/scalasql/src/dialects/MySqlDialect.scala @@ -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() } @@ -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)