Permalink
Browse files

Package structure refactoring

The main goal is to clear up the confusion between “Slick driver” and
“JDBC driver” and to answer the question “Do I still need a JDBC driver
with this”?

The original goal of separating API and implementation into Profiles and
Drivers has pretty much failed. Most features were exposed through the
Profiles and, unless you abstracted over different Drivers with an
abstract Profile, you probably used a Driver object directly instead of
going through a Profile.

We use this to our advantage and get rid of Drivers. Now there are only
abstract profiles (like `slick.jdbc.JdbcProfile`) and concrete profiles
(like `slick.jdbc.H2Profile`). Abstract profile levels are completely
separated into packages (`slick.basic`, `slick.relational`, `slick.sql`,
`slick.jdbc`, `slick.memory`), including the matching backend types.

Fixes #1107.
  • Loading branch information...
1 parent d198ea7 commit e46a0a530a8bb5581bf10a0429bcff0e8d791c04 @szeiger szeiger committed Oct 6, 2015
Showing with 1,259 additions and 1,131 deletions.
  1. +5 −5 common-test-resources/application.conf
  2. +2 −2 common-test-resources/logback.xml
  3. +2 −2 osgi-tests/src/test/scala/slick/osgi/test/BasicTest.scala
  4. +2 −2 reactive-streams-tests/src/test/resources/logback-test.xml
  5. +3 −3 reactive-streams-tests/src/test/scala/slick/test/stream/HeapPublisherTest.scala
  6. +3 −3 reactive-streams-tests/src/test/scala/slick/test/stream/JdbcPublisherTest.scala
  7. +3 −3 reactive-streams-tests/src/test/scala/slick/test/stream/RelationalPublisherTest.scala
  8. +3 −2 slick-codegen/src/main/scala/slick/codegen/AbstractGenerator.scala
  9. +4 −3 slick-codegen/src/main/scala/slick/codegen/AbstractSourceCodeGenerator.scala
  10. +3 −3 slick-codegen/src/main/scala/slick/codegen/OutputHelpers.scala
  11. +19 −18 slick-codegen/src/main/scala/slick/codegen/SourceCodeGenerator.scala
  12. +4 −2 slick-testkit/src/codegen/scala/slick/test/codegen/CustomTyping.scala
  13. +6 −8 slick-testkit/src/codegen/scala/slick/test/codegen/GenerateMainSources.scala
  14. +8 −8 slick-testkit/src/codegen/scala/slick/test/codegen/GenerateRoundtripSources.scala
  15. +2 −2 slick-testkit/src/doctest/resources/logback.xml
  16. +4 −4 slick-testkit/src/main/scala/com/typesafe/slick/testkit/tests/AggregateTest.scala
  17. +1 −1 slick-testkit/src/main/scala/com/typesafe/slick/testkit/tests/JdbcMetaTest.scala
  18. +12 −10 slick-testkit/src/main/scala/com/typesafe/slick/testkit/tests/ModelBuilderTest.scala
  19. +2 −2 slick-testkit/src/main/scala/com/typesafe/slick/testkit/tests/NewQuerySemanticsTest.scala
  20. +1 −1 slick-testkit/src/main/scala/com/typesafe/slick/testkit/tests/PlainSQLTest.scala
  21. +23 −19 slick-testkit/src/main/scala/com/typesafe/slick/testkit/util/BuildCapabilitiesTable.scala
  22. +21 −22 slick-testkit/src/main/scala/com/typesafe/slick/testkit/util/StandardTestDBs.scala
  23. +4 −4 slick-testkit/src/main/scala/com/typesafe/slick/testkit/util/TestCodeGenerator.scala
  24. +23 −22 slick-testkit/src/main/scala/com/typesafe/slick/testkit/util/TestDB.scala
  25. +21 −20 slick-testkit/src/main/scala/com/typesafe/slick/testkit/util/Testkit.scala
  26. +1 −1 slick-testkit/src/test/scala/slick/benchmark/Benchmark.scala
  27. +3 −3 slick-testkit/src/test/scala/slick/benchmark/CompilerBenchmark.scala
  28. +2 −2 slick-testkit/src/test/scala/slick/benchmark/StreamsStressTest.scala
  29. +3 −3 slick-testkit/src/test/scala/slick/benchmark/UnboxedBenchmark.scala
  30. +1 −1 slick-testkit/src/test/scala/slick/test/codegen/CodeGenRoundTripTest.scala
  31. +2 −2 slick-testkit/src/test/scala/slick/test/codegen/CodeGeneratorAllTest.scala
  32. +3 −4 slick-testkit/src/test/scala/slick/test/codegen/GeneratedCodeTest.scala
  33. +1 −1 slick-testkit/src/test/scala/slick/test/compile/NestedShapesTest.scala
  34. +0 −13 slick-testkit/src/test/scala/slick/test/driver/DriverNameTest.scala
  35. +0 −40 slick-testkit/src/test/scala/slick/test/driver/DriverTest.scala
  36. +5 −6 slick-testkit/src/test/scala/slick/test/jdbc/DataSourceTest.scala
  37. +1 −1 slick-testkit/src/test/scala/slick/test/jdbc/ModelBuilderTest.scala
  38. +6 −6 slick-testkit/src/test/scala/slick/test/jdbc/TypedStaticQueryTest.scala
  39. +1 −1 slick-testkit/src/test/scala/slick/test/lifted/SchemaSupportTest.scala
  40. +1 −1 slick-testkit/src/test/scala/slick/test/lifted/TableConstraintsTest.scala
  41. +10 −10 slick-testkit/src/test/scala/slick/test/memory/DistributedQueryingTest.scala
  42. +13 −0 slick-testkit/src/test/scala/slick/test/profile/ProfileNameTest.scala
  43. +40 −0 slick-testkit/src/test/scala/slick/test/profile/ProfileTest.scala
  44. +1 −1 slick/src/main/resources/reference.conf
  45. +3 −4 slick/src/main/scala/slick/ast/Node.scala
  46. +2 −2 slick/src/main/scala/slick/ast/Type.scala
  47. +22 −0 slick/src/main/scala/slick/backend.scala
  48. +0 −6 slick/src/main/scala/slick/backend/RelationalBackend.scala
  49. +0 −3 slick/src/main/scala/slick/backend/package.scala
  50. +19 −19 slick/src/main/scala/slick/{backend/DatabaseComponent.scala → basic/BasicBackend.scala}
  51. +44 −40 slick/src/main/scala/slick/{profile → basic}/BasicProfile.scala
  52. +2 −2 slick/src/main/scala/slick/{profile → basic}/Capability.scala
  53. +57 −26 slick/src/main/scala/slick/{backend → basic}/DatabaseConfig.scala
  54. +2 −1 slick/src/main/scala/slick/{backend → basic}/DatabasePublisher.scala
  55. +4 −0 slick/src/main/scala/slick/basic/package.scala
  56. +1 −1 slick/src/main/scala/slick/compiler/AssignUniqueSymbols.scala
  57. +1 −1 slick/src/main/scala/slick/compiler/EmulateOuterJoins.scala
  58. +1 −1 slick/src/main/scala/slick/compiler/RewriteBooleans.scala
  59. +35 −35 slick/src/main/scala/slick/dbio/DBIOAction.scala
  60. +43 −0 slick/src/main/scala/slick/driver.scala
  61. +0 −3 slick/src/main/scala/slick/driver/package.scala
  62. +38 −36 slick/src/main/scala/slick/{driver/DerbyDriver.scala → jdbc/DerbyProfile.scala}
  63. +24 −22 slick/src/main/scala/slick/{driver/H2Driver.scala → jdbc/H2Profile.scala}
  64. +17 −16 slick/src/main/scala/slick/{driver/HsqldbDriver.scala → jdbc/HsqldbProfile.scala}
  65. +48 −49 slick/src/main/scala/slick/{driver → jdbc}/JdbcActionComponent.scala
  66. +4 −4 slick/src/main/scala/slick/jdbc/JdbcBackend.scala
  67. +38 −0 slick/src/main/scala/slick/jdbc/JdbcCapabilities.scala
  68. +3 −4 slick/src/main/scala/slick/{driver → jdbc}/JdbcInvokerComponent.scala
  69. +9 −9 slick/src/main/scala/slick/jdbc/JdbcMappingCompilerComponent.scala
  70. +5 −3 slick/src/main/scala/slick/jdbc/JdbcModelBuilder.scala
  71. +2 −3 slick/src/main/scala/slick/{driver → jdbc}/JdbcModelComponent.scala
  72. +12 −59 slick/src/main/scala/slick/{driver → jdbc}/JdbcProfile.scala
  73. +10 −11 slick/src/main/scala/slick/{driver → jdbc}/JdbcStatementBuilderComponent.scala
  74. +4 −6 slick/src/main/scala/slick/jdbc/JdbcType.scala
  75. +7 −6 slick/src/main/scala/slick/{driver → jdbc}/JdbcTypesComponent.scala
  76. +39 −25 slick/src/main/scala/slick/{driver/MySQLDriver.scala → jdbc/MySQLProfile.scala}
  77. +19 −18 slick/src/main/scala/slick/{driver/PostgresDriver.scala → jdbc/PostgresProfile.scala}
  78. +1 −1 slick/src/main/scala/slick/jdbc/ResultSetInvoker.scala
  79. +41 −37 slick/src/main/scala/slick/{driver/SQLiteDriver.scala → jdbc/SQLiteProfile.scala}
  80. +5 −7 slick/src/main/scala/slick/jdbc/StaticQuery.scala
  81. +1 −1 slick/src/main/scala/slick/jdbc/StreamingInvokerAction.scala
  82. +1 −2 slick/src/main/scala/slick/jdbc/meta/MAttribute.scala
  83. +1 −2 slick/src/main/scala/slick/jdbc/meta/MBestRowIdentifierColumn.scala
  84. +2 −2 slick/src/main/scala/slick/jdbc/meta/MColumn.scala
  85. +1 −2 slick/src/main/scala/slick/jdbc/meta/MFunctionColumn.scala
  86. +1 −1 slick/src/main/scala/slick/jdbc/meta/MPrimaryKey.scala
  87. +1 −2 slick/src/main/scala/slick/jdbc/meta/MProcedureColumn.scala
  88. +1 −1 slick/src/main/scala/slick/jdbc/meta/MTable.scala
  89. +1 −2 slick/src/main/scala/slick/jdbc/meta/MTypeInfo.scala
  90. +1 −2 slick/src/main/scala/slick/jdbc/meta/MUDT.scala
  91. +1 −2 slick/src/main/scala/slick/jdbc/meta/MVersionColumn.scala
  92. +2 −2 slick/src/main/scala/slick/jdbc/package.scala
  93. +1 −1 slick/src/main/scala/slick/lifted/AbstractTable.scala
  94. +3 −3 slick/src/main/scala/slick/lifted/CompilableFunctions.fm
  95. +26 −24 slick/src/main/scala/slick/lifted/Compiled.scala
  96. +1 −1 slick/src/main/scala/slick/lifted/SimpleFunction.scala
  97. +7 −6 slick/src/main/scala/slick/memory/DistributedBackend.scala
  98. +37 −35 slick/src/main/scala/slick/memory/DistributedProfile.scala
  99. +5 −3 slick/src/main/scala/slick/memory/HeapBackend.scala
  100. +12 −0 slick/src/main/scala/slick/memory/MemoryCapabilities.scala
  101. +19 −32 slick/src/main/scala/slick/memory/MemoryProfile.scala
  102. +5 −6 slick/src/main/scala/slick/memory/MemoryQueryingProfile.scala
  103. +1 −1 slick/src/main/scala/slick/memory/QueryInterpreter.scala
  104. +17 −2 slick/src/main/scala/slick/memory/package.scala
  105. +34 −0 slick/src/main/scala/slick/profile.scala
  106. +0 −3 slick/src/main/scala/slick/profile/package.scala
  107. +6 −0 slick/src/main/scala/slick/relational/RelationalBackend.scala
  108. +60 −0 slick/src/main/scala/slick/relational/RelationalCapabilities.scala
  109. +35 −92 slick/src/main/scala/slick/{profile → relational}/RelationalProfile.scala
  110. +1 −1 slick/src/main/scala/slick/relational/ResultConverter.scala
  111. +3 −0 slick/src/main/scala/slick/relational/package.scala
  112. +26 −0 slick/src/main/scala/slick/sql/SqlCapabilities.scala
  113. +15 −35 slick/src/main/scala/slick/{profile → sql}/SqlProfile.scala
  114. +3 −0 slick/src/main/scala/slick/sql/package.scala
  115. +9 −5 slick/src/main/scala/slick/util/GlobalConfig.scala
  116. +8 −8 slick/src/sphinx/code-generation.rst
  117. +7 −7 slick/src/sphinx/code/CodeGenerator.scala
  118. +2 −2 slick/src/sphinx/code/Connection.scala
  119. +2 −2 slick/src/sphinx/code/FirstExample.scala
  120. +3 −3 slick/src/sphinx/code/GettingStartedOverview.scala
  121. +1 −1 slick/src/sphinx/code/JoinsUnions.scala
  122. +1 −1 slick/src/sphinx/code/LiftedEmbedding.scala
  123. +1 −1 slick/src/sphinx/code/OrmToSlick.scala
  124. +4 −4 slick/src/sphinx/code/PlainSQL.scala
  125. +4 −4 slick/src/sphinx/code/SqlToSlick.scala
  126. +2 −2 slick/src/sphinx/database.rst
  127. +2 −2 slick/src/sphinx/dbio.rst
  128. +4 −4 slick/src/sphinx/extensions.rst
  129. +3 −3 slick/src/sphinx/gettingstarted.rst
  130. +3 −4 slick/src/sphinx/introduction.rst
  131. +3 −3 slick/src/sphinx/queries.rst
  132. +2 −2 slick/src/sphinx/resources/application.conf
  133. +2 −2 slick/src/sphinx/schemas.rst
  134. +6 −6 slick/src/sphinx/sql.rst
  135. +3 −3 slick/src/sphinx/supported-databases.rst
  136. +13 −13 slick/src/sphinx/testkit.rst
  137. +2 −52 slick/src/sphinx/upgrade.rst
  138. +4 −4 slick/src/sphinx/userdefined.rst
@@ -7,7 +7,7 @@ slick {
}
tsql {
- driver = "slick.driver.H2Driver$"
+ profile = "slick.jdbc.H2Profile$"
db {
connectionPool = disabled
driver = "org.h2.Driver"
@@ -18,7 +18,7 @@ tsql {
// Explicit DriverDataSource using nested properties
ds1 {
- driver = "slick.driver.H2Driver$"
+ profile = "slick.jdbc.H2Profile$"
db {
connectionPool = disabled
dataSourceClass = "slick.jdbc.DriverDataSource"
@@ -34,7 +34,7 @@ ds1 {
// Implicitly created DriverDataSource for compatibility with 3.0 syntax
ds2 {
- driver = "slick.driver.H2Driver$"
+ profile = "slick.jdbc.H2Profile$"
db {
connectionPool = disabled
driver = "org.h2.Driver"
@@ -58,7 +58,7 @@ databaseUrl {
}
distrib1 {
- driver = "slick.driver.H2Driver$"
+ profile = "slick.jdbc.H2Profile$"
db {
connectionPool = disabled
driver = "org.h2.Driver"
@@ -68,7 +68,7 @@ distrib1 {
}
distrib2 {
- driver = "slick.driver.HsqldbDriver$"
+ profile = "slick.jdbc.HsqldbProfile$"
db {
connectionPool = disabled
driver = "org.hsqldb.jdbcDriver"
@@ -7,8 +7,8 @@
<root level="${log.root:-info}">
<appender-ref ref="STDOUT" />
</root>
- <logger name="slick.backend.DatabaseComponent.action" level="${log.action:-info}" />
- <logger name="slick.backend.DatabaseComponent.stream" level="${log.stream:-info}" />
+ <logger name="slick.basic.BasicBackend.action" level="${log.action:-info}" />
+ <logger name="slick.basic.BasicBackend.stream" level="${log.stream:-info}" />
<logger name="slick.compiler" level="${log.qcomp:-info}" />
<logger name="slick.compiler.QueryCompiler" level="${log.qcomp.phases:-inherited}" />
<logger name="slick.compiler.QueryCompilerBenchmark" level="${log.qcomp.bench:-inherited}" />
@@ -21,14 +21,14 @@ class BasicTest extends SlickOsgiHelper {
@Test
def testPlainSQL: Unit = wrap {
- import slick.driver.H2Driver.api._
+ import slick.jdbc.H2Profile.api._
val a = sql"select {fn database()}".as[String].head.map(res => assertEquals("TEST-OSGI", res))
val db = Database.forURL("jdbc:h2:mem:test-osgi")
try Await.result(db.run(a), Duration.Inf) finally db.close
}
@Test
def testConfig: Unit = wrap {
- assertFalse(GlobalConfig.driverConfig("MySQL").isEmpty)
+ assertFalse(GlobalConfig.profileConfig("slick.jdbc.MySQLProfile").isEmpty)
}
}
@@ -7,6 +7,6 @@
<root level="${log.root:-info}">
<appender-ref ref="STDOUT" />
</root>
- <logger name="slick.backend.DatabaseComponent.action" level="${log.action:-info}" />
- <logger name="slick.backend.DatabaseComponent.stream" level="${log.stream:-info}" />
+ <logger name="slick.basic.BasicBackend.action" level="${log.action:-info}" />
+ <logger name="slick.basic.BasicBackend.stream" level="${log.stream:-info}" />
</configuration>
@@ -3,10 +3,10 @@ package slick.test.stream
import org.testng.annotations.{AfterClass, BeforeClass}
import scala.concurrent.ExecutionContext
-import slick.memory.MemoryDriver
+import slick.memory.MemoryProfile
-class HeapPublisherTest extends RelationalPublisherTest[MemoryDriver](MemoryDriver, 300L) {
- import driver.api._
+class HeapPublisherTest extends RelationalPublisherTest[MemoryProfile](MemoryProfile, 300L) {
+ import profile.api._
def createDB = Database(ExecutionContext.global)
}
@@ -2,13 +2,13 @@ package slick.test.stream
import org.testng.annotations.{AfterClass, BeforeClass}
-import slick.driver.{H2Driver, JdbcProfile}
+import slick.jdbc.{JdbcProfile, H2Profile}
import scala.concurrent.Await
import scala.concurrent.duration.Duration
import scala.util.control.NonFatal
-class JdbcPublisherTest extends RelationalPublisherTest[JdbcProfile](H2Driver, 1000L) {
- import driver.api._
+class JdbcPublisherTest extends RelationalPublisherTest[JdbcProfile](H2Profile, 1000L) {
+ import profile.api._
def createDB = {
val db = Database.forURL("jdbc:h2:mem:DatabasePublisherTest", driver = "org.h2.Driver", keepAliveConnection = true)
@@ -7,14 +7,14 @@ import org.reactivestreams.tck._
import org.testng.annotations.{AfterClass, BeforeClass}
import org.scalatest.testng.TestNGSuiteLike
-import slick.profile.RelationalProfile
+import slick.relational.RelationalProfile
import scala.concurrent.Await
import scala.concurrent.duration.Duration
import scala.util.control.NonFatal
-abstract class RelationalPublisherTest[P <: RelationalProfile](val driver: P, timeout: Long) extends PublisherVerification[Int](new TestEnvironment(timeout), 1000L) with TestNGSuiteLike {
- import driver.api._
+abstract class RelationalPublisherTest[P <: RelationalProfile](val profile: P, timeout: Long) extends PublisherVerification[Int](new TestEnvironment(timeout), 1000L) with TestNGSuiteLike {
+ import profile.api._
override def maxElementsFromPublisher = 73L
override def boundedDepthOfOnNextAndRequestRecursion = 1
@@ -1,9 +1,10 @@
package slick.codegen
+import slick.ast.ColumnOption
import slick.{model => m}
import slick.model.ForeignKeyAction
-import slick.profile.{RelationalProfile, SqlProfile}
-import slick.ast.ColumnOption
+import slick.sql.SqlProfile
+import slick.relational.RelationalProfile
/**
* Slick code generator providing the base structure and facilities.
@@ -1,10 +1,11 @@
package slick.codegen
-import slick.profile.{SqlProfile, RelationalProfile}
+import slick.SlickException
+import slick.ast.ColumnOption
import slick.{model => m}
import slick.model.ForeignKeyAction
-import slick.ast.ColumnOption
-import slick.SlickException
+import slick.relational.RelationalProfile
+import slick.sql.SqlProfile
/** Base implementation for a Source code String generator */
abstract class AbstractSourceCodeGenerator(model: m.Model)
@@ -40,7 +40,7 @@ trait OutputHelpers{
* and places the new file inside or overrides the existing one.
* @group Output
* @param folder target folder, in which the package structure folders are placed
- * @param profile Slick profile that is imported in the generated package (e.g. slick.driver.H2Driver)
+ * @param profile Slick profile that is imported in the generated package (e.g. slick.jdbc.H2Profile)
* @param pkg Scala package the generated code is placed in (a subfolder structure will be created within srcFolder)
* @param container The name of a trait and an object the generated code will be placed in within the specified package.
* @param fileName Name of the output file, to which the code will be written
@@ -52,7 +52,7 @@ trait OutputHelpers{
/**
* Generates code providing the data model as trait and object in a Scala package
* @group Basic customization overrides
- * @param profile Slick profile that is imported in the generated package (e.g. slick.driver.H2Driver)
+ * @param profile Slick profile that is imported in the generated package (e.g. slick.jdbc.H2Profile)
* @param pkg Scala package the generated code is placed in
* @param container The name of a trait and an object the generated code will be placed in within the specified package.
*/
@@ -67,7 +67,7 @@ object ${container} extends {
/** Slick data model trait for extension, choice of backend or usage in the cake pattern. (Make sure to initialize this late.) */
trait ${container}${parentType.map(t => s" extends $t").getOrElse("")} {
- val profile: slick.driver.JdbcProfile
+ val profile: slick.jdbc.JdbcProfile
import profile.api._
${indent(code)}
}
@@ -4,9 +4,10 @@ import java.net.URI
import scala.concurrent.{ExecutionContext, Await}
import scala.concurrent.duration.Duration
-import slick.backend.DatabaseConfig
+
+import slick.basic.DatabaseConfig
import slick.{model => m}
-import slick.driver.JdbcProfile
+import slick.jdbc.JdbcProfile
import slick.util.ConfigExtensionMethods.configExtensionMethods
/**
@@ -59,26 +60,26 @@ class SourceCodeGenerator(model: m.Model)
/** A runnable class to execute the code generator without further setup */
object SourceCodeGenerator {
- def run(slickDriver: String, jdbcDriver: String, url: String, outputDir: String, pkg: String, user: Option[String], password: Option[String]): Unit = {
- val driver: JdbcProfile =
- Class.forName(slickDriver + "$").getField("MODULE$").get(null).asInstanceOf[JdbcProfile]
- val dbFactory = driver.api.Database
+ def run(profile: String, jdbcDriver: String, url: String, outputDir: String, pkg: String, user: Option[String], password: Option[String]): Unit = {
+ val profileInstance: JdbcProfile =
+ Class.forName(profile + "$").getField("MODULE$").get(null).asInstanceOf[JdbcProfile]
+ val dbFactory = profileInstance.api.Database
val db = dbFactory.forURL(url, driver = jdbcDriver,
user = user.getOrElse(null), password = password.getOrElse(null), keepAliveConnection = true)
try {
- val m = Await.result(db.run(driver.createModel(None, false)(ExecutionContext.global).withPinnedSession), Duration.Inf)
- new SourceCodeGenerator(m).writeToFile(slickDriver,outputDir,pkg)
+ val m = Await.result(db.run(profileInstance.createModel(None, false)(ExecutionContext.global).withPinnedSession), Duration.Inf)
+ new SourceCodeGenerator(m).writeToFile(profile,outputDir,pkg)
} finally db.close
}
def run(uri: URI, outputDir: Option[String]): Unit = {
val dc = DatabaseConfig.forURI[JdbcProfile](uri)
val pkg = dc.config.getString("codegen.package")
val out = outputDir.getOrElse(dc.config.getStringOr("codegen.outputDir", "."))
- val slickDriver = if(dc.driverIsObject) dc.driverName else "new " + dc.driverName
+ val profile = if(dc.profileIsObject) dc.profileName else "new " + dc.profileName
try {
- val m = Await.result(dc.db.run(dc.driver.createModel(None, false)(ExecutionContext.global).withPinnedSession), Duration.Inf)
- new SourceCodeGenerator(m).writeToFile(slickDriver, out, pkg)
+ val m = Await.result(dc.db.run(dc.profile.createModel(None, false)(ExecutionContext.global).withPinnedSession), Duration.Inf)
+ new SourceCodeGenerator(m).writeToFile(profile, out, pkg)
} finally dc.db.close
}
@@ -88,21 +89,21 @@ object SourceCodeGenerator {
run(new URI(uri), None)
case uri :: outputDir :: Nil =>
run(new URI(uri), Some(outputDir))
- case slickDriver :: jdbcDriver :: url :: outputDir :: pkg :: Nil =>
- run(slickDriver, jdbcDriver, url, outputDir, pkg, None, None)
- case slickDriver :: jdbcDriver :: url :: outputDir :: pkg :: user :: password :: Nil =>
- run(slickDriver, jdbcDriver, url, outputDir, pkg, Some(user), Some(password))
+ case profile :: jdbcDriver :: url :: outputDir :: pkg :: Nil =>
+ run(profile, jdbcDriver, url, outputDir, pkg, None, None)
+ case profile :: jdbcDriver :: url :: outputDir :: pkg :: user :: password :: Nil =>
+ run(profile, jdbcDriver, url, outputDir, pkg, Some(user), Some(password))
case _ => {
println("""
|Usage:
| SourceCodeGenerator configURI [outputDir]
- | SourceCodeGenerator slickDriver jdbcDriver url outputDir pkg [user password]
+ | SourceCodeGenerator profile jdbcDriver url outputDir pkg [user password]
|
|Options:
| configURI: A URL pointing to a standard database config file (a fragment is
| resolved as a path in the config), or just a fragment used as a path in
| application.conf on the class path
- | slickDriver: Fully qualified name of Slick driver class, e.g. "slick.driver.H2Driver"
+ | profile: Fully qualified name of Slick profile class, e.g. "slick.jdbc.H2Profile"
| jdbcDriver: Fully qualified name of jdbc driver class, e.g. "org.h2.Driver"
| url: JDBC URL, e.g. "jdbc:postgresql://localhost/test"
| outputDir: Place where the package folder structure should be put
@@ -111,7 +112,7 @@ object SourceCodeGenerator {
| password: database connection password
|
|When using a config file, in addition to the standard config parameters from
- |slick.backend.DatabaseConfig you can set "codegen.package" and
+ |slick.basic.DatabaseConfig you can set "codegen.package" and
|"codegen.outputDir". The latter can be overridden on the command line.
""".stripMargin.trim)
System.exit(1)
@@ -1,7 +1,9 @@
package slick.test.codegen
-import slick.driver.H2Driver
+
+import slick.jdbc.H2Profile
+
object CustomTyping {
- import H2Driver.api._
+ import H2Profile.api._
sealed trait Bool {
def isTrue: Boolean
}
@@ -11,9 +11,7 @@ import scala.concurrent.ExecutionContext.Implicits.global
import scala.io.{Codec, Source}
import slick.dbio.DBIO
import slick.codegen.{OutputHelpers, SourceCodeGenerator}
-import slick.driver._
import slick.jdbc.JdbcBackend
-import slick.driver.JdbcDriver
import slick.jdbc.meta.MTable
import slick.model.Model
@@ -27,7 +25,7 @@ object GenerateMainSources extends TestCodeGenerator {
new Config("CG2", StandardTestDBs.HsqldbMem, "HsqldbMem", Seq("/dbs/hsqldb.sql")),
new Config("CG3", StandardTestDBs.SQLiteMem, "SQLiteMem", Seq("/dbs/sqlite.sql")),
new Config("CG7", StandardTestDBs.H2Mem, "H2Mem", Seq("/dbs/h2.sql")) {
- override def generator = tdb.driver.createModel(ignoreInvalidDefaults=false).map(new MyGen(_) {
+ override def generator = tdb.profile.createModel(ignoreInvalidDefaults=false).map(new MyGen(_) {
override def entityName = {
case "COFFEES" => "Coff"
case other => super.entityName(other)
@@ -49,7 +47,7 @@ object GenerateMainSources extends TestCodeGenerator {
})
},
new Config("CG8", StandardTestDBs.H2Mem, "H2Mem", Seq("/dbs/h2-simple.sql")) {
- override def generator = tdb.driver.createModel(ignoreInvalidDefaults=false).map(new MyGen(_) {
+ override def generator = tdb.profile.createModel(ignoreInvalidDefaults=false).map(new MyGen(_) {
override def Table = new Table(_){
override def EntityType = new EntityType{
override def enabled = false
@@ -75,15 +73,15 @@ val SimpleA = CustomTyping.SimpleA
})
},
new Config("CG9", StandardTestDBs.H2Mem, "H2Mem", Seq("/dbs/h2.sql")) {
- override def generator = tdb.driver.createModel(ignoreInvalidDefaults=false).map(new MyGen(_) {
+ override def generator = tdb.profile.createModel(ignoreInvalidDefaults=false).map(new MyGen(_) {
override def Table = new Table(_){
override def autoIncLastAsOption = true
}
})
},
new UUIDConfig("CG10", StandardTestDBs.H2Mem, "H2Mem", Seq("/dbs/uuid.sql")),
new Config("Postgres1", StandardTestDBs.Postgres, "Postgres", Nil) {
- import tdb.driver.api._
+ import tdb.profile.api._
class A(tag: Tag) extends Table[(Int, Array[Byte], Blob)](tag, "a") {
def id = column[Int]("id")
def ba = column[Array[Byte]]("ba")
@@ -92,7 +90,7 @@ val SimpleA = CustomTyping.SimpleA
}
override def generator =
TableQuery[A].schema.create >>
- tdb.driver.createModel(ignoreInvalidDefaults=false).map(new MyGen(_))
+ tdb.profile.createModel(ignoreInvalidDefaults=false).map(new MyGen(_))
override def testCode =
"""
| import java.sql.Blob
@@ -112,7 +110,7 @@ val SimpleA = CustomTyping.SimpleA
//Unified UUID config
class UUIDConfig(objectName: String, tdb: JdbcTestDB, tdbName: String, initScripts: Seq[String])
extends Config(objectName, tdb, tdbName, initScripts) {
- override def generator =tdb.driver.createModel(ignoreInvalidDefaults=false).map(new MyGen(_) {
+ override def generator = tdb.profile.createModel(ignoreInvalidDefaults=false).map(new MyGen(_) {
override def Table = new Table(_) {
override def Column = new Column(_){
override def defaultCode: (Any) => String = {
@@ -4,39 +4,39 @@ import scala.concurrent.Await
import scala.concurrent.duration.Duration
import scala.concurrent.ExecutionContext.Implicits.global
import slick.codegen.SourceCodeGenerator
-import slick.driver._
+import slick.jdbc.JdbcProfile
/** Generates code for CodeGenRoundTripTest.
*
* This is generated using Derby currently because Derby strips column size of some columns, which
* works with all backends. If the code was generated using model data where the size is included
- * it would fail in derby and hsqldb. The code is tested using all enabled drivers. We should also
+ * it would fail in derby and hsqldb. The code is tested using all enabled profiles. We should also
* diversify generation as well at some point. */
object GenerateRoundtripSources {
def main(args: Array[String]) {
- val driver = slick.driver.H2Driver
+ val profile = slick.jdbc.H2Profile
val url = "jdbc:h2:mem:test4"
val jdbcDriver = "org.h2.Driver"
- object Tables extends Tables(driver)
+ object Tables extends Tables(profile)
import Tables._
import Tables.profile.api._
val ddl = posts.schema ++ categories.schema ++ typeTest.schema ++ large.schema ++ `null`.schema ++ X.schema ++ SingleNonOptionColumn.schema ++ SelfRef.schema
- val a1 = driver.createModel(ignoreInvalidDefaults=false).map(m => new SourceCodeGenerator(m) {
+ val a1 = profile.createModel(ignoreInvalidDefaults=false).map(m => new SourceCodeGenerator(m) {
override def tableName = {
case n if n.toLowerCase == "null" => "null" // testing null as table name
case n => super.tableName(n)
}
})
- val a2 = driver.createModel(ignoreInvalidDefaults=false).map(m => new SourceCodeGenerator(m) {
+ val a2 = profile.createModel(ignoreInvalidDefaults=false).map(m => new SourceCodeGenerator(m) {
override def Table = new Table(_){
override def autoIncLastAsOption = true
}
})
val db = Database.forURL(url=url, driver=jdbcDriver, keepAliveConnection=true)
val (gen,gen2) = try Await.result(db.run(ddl.create >> (a1 zip a2)), Duration.Inf) finally db.close
val pkg = "slick.test.codegen.roundtrip"
- gen.writeToFile( "slick.driver.H2Driver", args(0), pkg )
- gen2.writeToFile( "slick.driver.H2Driver", args(0), pkg+"2" )
+ gen.writeToFile( "slick.jdbc.H2Profile", args(0), pkg )
+ gen2.writeToFile( "slick.jdbc.H2Profile", args(0), pkg+"2" )
}
}
Oops, something went wrong.

0 comments on commit e46a0a5

Please sign in to comment.