How to avoid warning with string interpolation?

737 views
Skip to first unread message

David Barri

unread,
Jul 24, 2014, 8:48:20 AM7/24/14
to scala...@googlegroups.com
Hi, Just giving RC2 a try.

This code keeps producing deprecation a warning. Should I be doing something differently? What's the plan?

Code:
  val q = sql"select count(1) from msgq".as[Int]

Warning:
[warn] Adaptation of argument list by inserting () has been deprecated: this is unlikely to be what you want.
[warn]         signature: SQLInterpolation.sql[P](param: P)(implicit pconv: scala.slick.jdbc.SetParameter[P]): scala.slick.jdbc.SQLInterpolationResult[P]
[warn]   given arguments: <none>
[warn]  after adaptation: SQLInterpolation.sql((): Unit)
[warn]       val q = sql"select count(1) from msgq".as[Int]

Stefan Zeiger

unread,
Jul 24, 2014, 9:17:24 AM7/24/14
to scala...@googlegroups.com
You can ignore these warnings. Slick 2.2 will use a macro-based approach for the interpolators to fix this warning on Scala 2.11. The new implementation will also enable using more than 22 parameters with SQL interpolation. The API will stay the same.
--

---
You received this message because you are subscribed to the Google Groups "Slick / ScalaQuery" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scalaquery+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/scalaquery/0f039c2a-1b12-4473-aac9-ee489e37b6e0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
Stefan Zeiger
Slick Tech Lead
Typesafe - Build Reactive Apps!
Twitter: @StefanZeiger

David Barri

unread,
Jul 24, 2014, 9:29:51 AM7/24/14
to scala...@googlegroups.com
Ok cool, how long are we talking until that happens? I don't want to ignore warnings for long; I need to be able to sift through the sea of them to find the genuine ones (because often they actually are bugs).​

Christopher Vogt

unread,
Jul 24, 2014, 9:36:38 AM7/24/14
to scala...@googlegroups.com
2.2 is expected at the end of the year.
> --
>
> ---
> You received this message because you are subscribed to the Google
> Groups "Slick / ScalaQuery" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to scalaquery+...@googlegroups.com
> <mailto:scalaquery+...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/scalaquery/CANW_tjBK5w%3DtxP%2BEi%2BHu0BEDODtsLOpR7Frzp7DSSQnHJDjFcg%40mail.gmail.com
> <https://groups.google.com/d/msgid/scalaquery/CANW_tjBK5w%3DtxP%2BEi%2BHu0BEDODtsLOpR7Frzp7DSSQnHJDjFcg%40mail.gmail.com?utm_medium=email&utm_source=footer>.

David Barri

unread,
Jul 24, 2014, 9:13:42 PM7/24/14
to scala...@googlegroups.com
So I have to endure tens of warnings and lose the ability to see genuine problems like pattern matching non-exhaustiveness, etc, or hold my entire project back from upgrading to Scala 2.11? That's poor form.


You received this message because you are subscribed to a topic in the Google Groups "Slick / ScalaQuery" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/scalaquery/eN8YMGE-GSY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to scalaquery+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/scalaquery/53D10BE2.7090005%40gmail.com.

Christopher Vogt

unread,
Jul 25, 2014, 8:02:40 AM7/25/14
to scala...@googlegroups.com
Well, there was a trade-off to be made. We went with Slick 2.1 being
warning free for 2.10 and source compatible with 2.11 at the price of
warnings. If you manage to fix some in a binary compatible compatible
way and send a PR our way, we are more than happy to integrate it into
2.1.1, which will come much earlier than 2.2. Or you could to maintain a
fork that maintains a warning-free 2.11 version of Slick 2.1, I am sure
people would be happy about that. We opted not to assign resources to
this now and focus on advancing Slick.

Another way to look a the problem: Scalac and sbt do not provide a way
to filter warnings. Possibly grep may help you.

Chris


On 25.07.14 03:13, David Barri wrote:
> So I have to endure tens of warnings and lose the ability to see genuine
> problems like pattern matching non-exhaustiveness, etc, or hold my
> entire project back from upgrading to Scala 2.11? That's poor form.
>
>
> On 24 July 2014 23:36, Christopher Vogt <jan.christ...@gmail.com
> <mailto:jan.christ...@gmail.com>> wrote:
>
> 2.2 is expected at the end of the year.
>
> On 24.07.14 15:29, David Barri wrote:
> > Ok cool, how long are we talking until that happens? I don't want to
> > ignore warnings for long; I need to be able to sift through the sea of
> > them to find the genuine ones (because often they actually are bugs).​
> >
> > --
> >
> > ---
> > You received this message because you are subscribed to the Google
> > Groups "Slick / ScalaQuery" group.
> > To unsubscribe from this group and stop receiving emails from it, send
> > an email to scalaquery+...@googlegroups.com
> <mailto:scalaquery%2Bunsu...@googlegroups.com>
> > <mailto:scalaquery+...@googlegroups.com
> <mailto:scalaquery%2Bunsu...@googlegroups.com>>.
> > To view this discussion on the web visit
> > https://groups.google.com/d/msgid/scalaquery/CANW_tjBK5w%3DtxP%2BEi%2BHu0BEDODtsLOpR7Frzp7DSSQnHJDjFcg%40mail.gmail.com
> > <https://groups.google.com/d/msgid/scalaquery/CANW_tjBK5w%3DtxP%2BEi%2BHu0BEDODtsLOpR7Frzp7DSSQnHJDjFcg%40mail.gmail.com?utm_medium=email&utm_source=footer>.
> > For more options, visit https://groups.google.com/d/optout.
>
> --
>
> ---
> You received this message because you are subscribed to a topic in
> the Google Groups "Slick / ScalaQuery" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/scalaquery/eN8YMGE-GSY/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> scalaquery+...@googlegroups.com
> <mailto:scalaquery%2Bunsu...@googlegroups.com>.
> To view this discussion on the web visit
> --
>
> ---
> You received this message because you are subscribed to the Google
> Groups "Slick / ScalaQuery" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to scalaquery+...@googlegroups.com
> <mailto:scalaquery+...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/scalaquery/CANW_tjBXKSmS_yUip6SSG6U-wUXKX1TtueH%2BmPGKkthrwnfqeA%40mail.gmail.com
> <https://groups.google.com/d/msgid/scalaquery/CANW_tjBXKSmS_yUip6SSG6U-wUXKX1TtueH%2BmPGKkthrwnfqeA%40mail.gmail.com?utm_medium=email&utm_source=footer>.

Matthew Pocock

unread,
Jul 25, 2014, 9:30:09 AM7/25/14
to scala...@googlegroups.com
Is there a way to selectively enable/dissable these warnings e.g. a @suppresswarnings("slick.sqlInterpolation") annotation or something? Just asking - no idea if this or something like it already exists for warning suppression in general.

Matthew


To unsubscribe from this group and stop receiving emails from it, send an email to scalaquery+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/scalaquery/53D2475A.4020105%40gmail.com.

For more options, visit https://groups.google.com/d/optout.



--
Dr Matthew Pocock
Turing ate my hamster LTD

Integrative Bioinformatics Group, School of Computing Science, Newcastle University

skype: matthew.pocock
tel: (0191) 2566550

Christopher Vogt

unread,
Jul 25, 2014, 10:21:14 AM7/25/14
to scala...@googlegroups.com
> Is there a way to selectively enable/dissable these warnings e.g. a
> @suppresswarnings("slick.sqlInterpolation") annotation or something?
> Just asking - no idea if this or something like it already exists for
> warning suppression in general.

Not that I know of unfortunately. There is @unchecked for a small group
of warnings.

Chris

Naftoli Gugenheim

unread,
Jul 28, 2014, 6:00:30 PM7/28/14
to scala...@googlegroups.com

Can you elaborate on the tradeoff?
Also couldn't it be fixed with an overload?

To unsubscribe from this group and stop receiving emails from it, send an email to scalaquery+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/scalaquery/53D2475A.4020105%40gmail.com.

oliver.ki...@googlemail.com

unread,
Jan 29, 2015, 11:31:08 AM1/29/15
to scala...@googlegroups.com
Any further information about the slick 2.2 release?

Christopher Vogt

unread,
Jan 29, 2015, 10:52:12 PM1/29/15
to scala...@googlegroups.com
Coming very soon as Slick 3.

Chris

On 29.01.15 11:31, oliver.ki...@googlemail.com wrote:
> Any further information about the slick 2.2 release?
>
> --
>
> ---
> You received this message because you are subscribed to the Google
> Groups "Slick / ScalaQuery" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to scalaquery+...@googlegroups.com
> <mailto:scalaquery+...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/scalaquery/19199010-0e55-4571-b06e-5f3eb6ba35ef%40googlegroups.com
> <https://groups.google.com/d/msgid/scalaquery/19199010-0e55-4571-b06e-5f3eb6ba35ef%40googlegroups.com?utm_medium=email&utm_source=footer>.

ja...@roundtown.com

unread,
Feb 17, 2015, 2:48:13 PM2/17/15
to scala...@googlegroups.com
Here's my workaround:

/**
 ** A fix for warnings when using Slick's SQL interpolation with no $vals in the string
 ** to use,
 **   import myutils.SQI.interpolation
 ** rather then
 **   import scala.slick.jdbc.StaticQuery.interpolation
 **/

package myutils

class
SQLInterpolation_WarningsFixed(val s: StringContext) extends AnyVal {
    import scala.slick.jdbc._
   
def sql[P](param: P)(implicit pconv: SetParameter[P]) =
       
new SQLInterpolationResult[P](s.parts, param, pconv)
   
def sqlu[P](param: P)(implicit pconv: SetParameter[P]) = sql(param).asUpdate
   
// The warning occurs because when there are no $vars in the string interpolation, param is Unit
   
// and Scala now warns if we're not explicit about it. The methods below satisfy that need:
   
def sql[P]()(implicit pconv: SetParameter[Unit]) =
       
new SQLInterpolationResult[Unit](s.parts, (), pconv)
   
def sqlu[P]()(implicit pconv: SetParameter[Unit]) = sql(()).asUpdate
}

object SQI {
   
import scala.language.implicitConversions
   
@inline implicit def interpolation(s: StringContext) = new SQLInterpolation_WarningsFixed(s)
}


Alternatively, those two methods could be inserted directly into Slick's SQLInterpolation class directly.

-James
Reply all
Reply to author
Forward
0 new messages