Skip to content

Commit

Permalink
tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
lihaoyi committed Dec 10, 2023
1 parent b64854f commit d167ad7
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
9 changes: 7 additions & 2 deletions docs/developer.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@

# Developer Docs

* Running all unit tests: `./mill -i -w "__.test"`
* Running all unit tests on one database: `./mill -i -w "__.test scalasql.sqlite"`
* Running all unit tests: `./mill -i -w "__.test"`.

* Running all unit tests on one database: `./mill -i -w "__.test scalasql.sqlite"`. This
is much faster than running all tests, and useful for quick iteration for changes that
are not database specific.

* Re-generating docs: `./mill -i "__.test" + generateTutorial + generateReference`
* Note that ScalaSql's reference docs are extracted from the test suite, and thus we need
to make sure to run the test suite before re-generating them.

* Fix all auto-generating and auto-formatting issues at once via
```
./mill -i -w mill.scalalib.scalafmt.ScalafmtModule/reformatAll __.sources + "scalasql[2.13.12].test" + generateTutorial + generateReference
Expand Down
6 changes: 3 additions & 3 deletions scalasql/core/src/Context.scala
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ object Context {
def fromRefPrefix(prevContext: Context): String

/**
* A mapping of the [[Expr]] expressions that this [[From]] produces along
* A mapping of any aliased [[Expr]] that this [[From]] produces along
* with their rendered [[SqlStr]]s
*/
def fromColumnExprs(prevContext: Context): Map[Expr.Identity, SqlStr]
def fromExprAliases(prevContext: Context): Map[Expr.Identity, SqlStr]

/**
* How this [[From]] can be rendered into a [[SqlStr]] for embedding into
Expand Down Expand Up @@ -88,7 +88,7 @@ object Context {
.iterator
.flatMap { t =>
t
.fromColumnExprs(prevContext)
.fromExprAliases(prevContext)
.map { case (e, s) => (e, sql"${SqlStr.raw(newFromNaming(t), Array(e))}.$s") }
}

Expand Down
6 changes: 3 additions & 3 deletions scalasql/query/src/From.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class TableRef(val value: Table.Base) extends From {
override def toString = s"TableRef(${Table.name(value)})"

def fromRefPrefix(prevContext: Context) = prevContext.config.tableNameMapper(Table.name(value))
def fromColumnExprs(prevContext: Context) = Map()
def fromExprAliases(prevContext: Context) = Map()

def renderSql(name: SqlStr, prevContext: Context, liveExprs: LiveSqlExprs) = {
SqlStr.raw(prevContext.config.tableNameMapper(Table.name(value))) + sql" " + name
Expand All @@ -20,7 +20,7 @@ class TableRef(val value: Table.Base) extends From {
class SubqueryRef(val value: SelectBase, val qr: Queryable[_, _]) extends From {
def fromRefPrefix(prevContext: Context): String = "subquery"

def fromColumnExprs(prevContext: Context) = SelectBase.lhsMap(value, prevContext)
def fromExprAliases(prevContext: Context) = SelectBase.lhsMap(value, prevContext)

def renderSql(name: SqlStr, prevContext: Context, liveExprs: LiveSqlExprs) = {
val renderSql = SelectBase.renderer(value, prevContext)
Expand All @@ -30,7 +30,7 @@ class SubqueryRef(val value: SelectBase, val qr: Queryable[_, _]) extends From {
class WithCteRef() extends From {
def fromRefPrefix(prevContext: Context) = "cte"

def fromColumnExprs(prevContext: Context) = Map()
def fromExprAliases(prevContext: Context) = Map()

def renderSql(name: SqlStr, prevContext: Context, liveExprs: LiveSqlExprs) = {
name
Expand Down

0 comments on commit d167ad7

Please sign in to comment.