Skip to content
Permalink
Browse files

modified to use GlobalConfig.

It is possible to retrieve sqlIndent option through GlobalConfig. And, you can override this with -D option.
The field `sqlIndent` of `SqlBuilder` is `var` but not `val`.
Even if use SQL Indentation, there are some nested sql expressions in which it's is better to ignore this option.
  • Loading branch information
imcharsi committed Sep 16, 2014
1 parent 048b546 commit 7a1d119f78595af6b6aad8757beba4d20ba872d7
@@ -1,4 +1,5 @@
slick {
ansiDump = true
unicodeDump = true
sqlIndent = true
}
@@ -8,4 +8,7 @@ slick {

# Dump individual Select and Ref nodes instead of a single Path
dumpPaths = false

# Determine whether use SQL Indentation.
sqlIndent = false
}
@@ -28,8 +28,6 @@ trait JdbcStatementBuilderComponent { driver: JdbcDriver =>
def createColumnDDLBuilder(column: FieldSymbol, table: Table[_]): ColumnDDLBuilder = new ColumnDDLBuilder(column)
def createSequenceDDLBuilder(seq: Sequence[_]): SequenceDDLBuilder = new SequenceDDLBuilder(seq)

val sqlIndent: Boolean = true

class JdbcCompiledInsert(source: Node) {
class Artifacts(val compiled: Node, val converter: ResultConverter[JdbcResultConverterDomain, Any], val ibr: InsertBuilderResult) {
def table: TableNode = ibr.table
@@ -105,7 +103,8 @@ trait JdbcStatementBuilderComponent { driver: JdbcDriver =>
protected val pi = "3.1415926535897932384626433832795"

// Mutable state accessible to subclasses
protected val b = new SQLBuilder(sqlIndent)
private val currentSqlIndent = GlobalConfig.sqlIndent
protected val b = new SQLBuilder(currentSqlIndent)
protected var currentPart: StatementPart = OtherPart
protected val symbolName = new QuotingSymbolNamer(Some(state.symbolNamer))
protected val joins = new HashMap[Symbol, Join]
@@ -184,7 +183,7 @@ trait JdbcStatementBuilderComponent { driver: JdbcDriver =>
}

protected def sqlIndentPrefix: String = {
if (sqlIndent) {
if (currentSqlIndent) {
b.newLine()
""
}
@@ -19,6 +19,9 @@ object GlobalConfig {
/** Use Unixode box characters in table dumps */
val unicodeDump = config.getBoolean("slick.unicodeDump")

// Determine whether use SQL Indentation.
val sqlIndent = config.getBoolean("slick.sqlIndent")

/** Get a `Config` object for a Slick driver */
def driverConfig(name: String): Config = {
val path = "slick.driver." + name
@@ -3,7 +3,7 @@ package scala.slick.util
import java.sql.PreparedStatement
import scala.collection.mutable.ArrayBuffer

final class SQLBuilder(val sqlIndent: Boolean = false) extends SQLBuilder.Segment { self =>
final class SQLBuilder(var sqlIndent: Boolean = false) extends SQLBuilder.Segment { self =>
import SQLBuilder._

private val segments = new ArrayBuffer[Segment]

0 comments on commit 7a1d119

Please sign in to comment.
You can’t perform that action at this time.