Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Escape code generator default string
- Loading branch information
|
@@ -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] = |
|
|