[anorm 2.4.0] Breaking change in SQL interpolation in 2.4

56 views
Skip to first unread message

Chris Toomey

unread,
Jul 22, 2016, 4:01:54 AM7/22/16
to play-framework
I just upgraded our app from Play 2.3 to 2.4 (hence anorm 2.4.0) and discovered that a breaking change was made to the SQL string interpolator: percent signs are now parsed apparently as variable placeholders.

2.3.x:
scala> SQL"DATE_FORMAT(NOW(),'%m-%d-%Y')"
res0: anorm.SimpleSql[anorm.Row] = SimpleSql(SqlQuery(DATE_FORMAT(NOW(),'%m-%d-%Y'),List(),None),Map(),<function1>)

2.4.x:
scala> SQL"DATE_FORMAT(NOW(),'%m-%d-%Y')"
java.lang.RuntimeException: No parameter value for placeholder: 1
  at scala.sys.package$.error(package.scala:27)
  at anorm.TokenizedStatement$.tokenize(TokenizedStatement.scala:73)
  at anorm.package$SqlStringInterpolation$.SQL$extension(package.scala:58)
  ... 42 elided

I didn't see this incompatible change mentioned in the Play 2.4 migration guide nor in the Anorm 2.4 highlights (nor the Anorm code or any Google results), and I haven't seen any documentation for what this syntax change enables that wasn't doable before.

Was this inadvertently changed somehow (should I file a bug?), or why was it changed in a backwards-incompatible way without warning or explanation of the benefits it provides?

This breaks a lot of SQL code for us and probably others.

thx,
Chris

Christian Schmitt

unread,
Jul 22, 2016, 4:25:45 AM7/22/16
to play-fr...@googlegroups.com
Actually in 2.4 Anorm got pulled out from Play-core

> Anorm has been pulled out of the core of Play into a separately managed project that can have its own lifecycle

Actually what you mentioned will be fixed in Anorm 2.5.2, which isn’t released

Beste Grüße / Best Regards
 
Christian Schmitt
Entwickler / Developer

--
You received this message because you are subscribed to the Google Groups "play-framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to play-framewor...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/play-framework/72735f1b-f6b9-4619-bbee-62173c3a82a0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages