-
Notifications
You must be signed in to change notification settings - Fork 180
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ecaping array elements is too eager #504
Comments
@nafg I didn't reproduce the |
I just tried with 0.19.6 and it's still broken. It's not hard to reproduce. There's nothing complicated here. In fact, if you can show a working example that includes saving and reloading a That said, I will try to share more code. It would be hard to start making a minimal executable self-contained program, but here is the relevant code, that should give you a clearer picture of what I have. def arrayAsText[A: ClassTag](fromString: String => Option[A])(toString: A => String): JdbcType[Seq[A]] =
new SimpleArrayJdbcType[String]("text")
.mapTo(s => fromString(s).getOrElse(sys.error(s"Could not convert '$s' to a ${classTag[A]}")), toString) abstract class CustomFieldKind(val id: String, val name: String) {
def subfieldDefs: List[SubfieldDefBase]
def allowInNature(@unused nature: Nature): Boolean = true
override def toString = s"CustomFieldKind($id, $name) { subfieldDefs = $subfieldDefs }"
}
object CustomFieldKind {
class Simple(id: String, title: String)(defs: SubfieldDefBase*) extends CustomFieldKind(id, title) {
override def subfieldDefs = defs.toList
}
private val ClientAddressFieldKind = new Simple("clientAddress", "Client's address")(
SubfieldDef(SubfieldKind.ClientAddress, "clientAddress", "Client's address")
) def forName(string: String): Option[CustomFieldKind] = all.find(_.name == string) private implicit val fieldKindListMapping: JdbcType[Seq[CustomFieldKind]] =
SlickColumnMappings.arrayAsText(CustomFieldKind.forName)(_.name) def allowedKinds = column[Seq[CustomFieldKind]]("allowed_kinds") If I then save an array containing a
Is it clearer now? |
I should mention that querying the database directly shows that indeed, it saved it as |
Hi, was there any update on this? |
does not work if
toString
of anA
includes an apostrophe, because it gets saved with a double apostrophe.I assume that without the
mapTo
line as well, nothing would crash but your strings would get their apostrophes doubled.Similarly, this broke recently:
Changing
SimpleArrayUtils.mkString
toSimpleArrayUtils.mkStringUnsafe
works.The text was updated successfully, but these errors were encountered: