Permalink
Browse files

Escape code generator default string

  • Loading branch information...
1 parent 219d397 commit d80eb8500d41236f0928415cc334e0c4e9ac6551 @trevorsibanda trevorsibanda committed Oct 23, 2016
@@ -170,7 +170,7 @@ class $name(_tableTag: Tag) extends profile.api.Table[$elementType](_tableTag, $
}
def defaultCode = {
case Some(v) => s"Some(${defaultCode(v)})"
- case s:String => "\""+s+"\""
+ case s:String => "\""+s.replaceAll("\"", """\\"""")+"\""
case None => s"None"
case v:Byte => s"$v"
case v:Int => s"$v"
@@ -126,6 +126,25 @@ val SimpleA = CustomTyping.SimpleA
| DBIO.seq( schema.create )
""".stripMargin
},
+ new Config("MySQL1", StandardTestDBs.MySQL, "MySQL", Nil) {
+ import tdb.profile.api._
+ class A(tag: Tag) extends Table[(String)](tag, "a") {
+ def quote = column[String]("x", O.Default("\"\"")) // column name with double quote
+ def * = quote
+ }
+ override def generator =
+ TableQuery[A].schema.create >>
+ tdb.profile.createModel(ignoreInvalidDefaults=false).map(new MyGen(_))
+ override def testCode =
+ """
+ | val a1 = ARow("e")
+ | DBIO.seq(
+ | schema.create,
+ | A += a1,
+ | A.result.map { case Seq(ARow(quote)) => assertEquals("e", quote) }
+ | ).transactionally
+ """.stripMargin
+ },
new UUIDConfig("Postgres2", StandardTestDBs.Postgres, "Postgres", Seq("/dbs/uuid-postgres.sql")),
new Config("MySQL", StandardTestDBs.MySQL, "MySQL", Seq("/dbs/mysql.sql") ){
override def generator: DBIO[SourceCodeGenerator] =

0 comments on commit d80eb85

Please sign in to comment.