aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStewart Stewart <stewinsalot@gmail.com>2017-02-21 17:04:34 -0500
committerStewart Stewart <stewinsalot@gmail.com>2017-02-21 17:52:45 -0500
commit49653139b80f9bad87e51aa0c8181fb48b64b15d (patch)
tree19fcb42200fa12ae46365754a982a05c987207ae
parent931e401a54fc851d2394b6c231a9d5394d23a8cf (diff)
downloadslick-codegen-plugin-49653139b80f9bad87e51aa0c8181fb48b64b15d.tar.gz
slick-codegen-plugin-49653139b80f9bad87e51aa0c8181fb48b64b15d.tar.bz2
slick-codegen-plugin-49653139b80f9bad87e51aa0c8181fb48b64b15d.zip
use separate trait
-rw-r--r--src/main/scala/NamespacedCodegen.scala16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/main/scala/NamespacedCodegen.scala b/src/main/scala/NamespacedCodegen.scala
index 5caa98d..095eefb 100644
--- a/src/main/scala/NamespacedCodegen.scala
+++ b/src/main/scala/NamespacedCodegen.scala
@@ -111,14 +111,22 @@ class Generator(pkg: String,
pkg: String,
container: String,
parentType: Option[String]): String = {
+ val traitName = container.capitalize + "SchemaDef"
s"""|package $pkg
|$allImports
- |object ${container} extends {
+ |// AUTO-GENERATED Slick data model
+ |
+ |/** Stand-alone Slick data model for immediate use */
+ |object $container extends {
| val profile = $profile
- |} with ${parentType.getOrElse("AnyRef")} {
+ |} with $traitName
+ |
+ |/** Slick data model trait for extension, choice of backend or usage in the cake pattern. (Make sure to initialize this late.) */
+ |trait $traitName${parentType.fold("")(" extends " + _)} {
| import profile.api._
- | ${filteredCode}
- |}""".stripMargin
+ | ${indent(filteredCode)}
+ |}""".stripMargin.trim()
+ // TODO: default to upstream packageCode after filteredCode is fixed
}
override def Table = new Table(_) { table =>