Skip to content
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

(new) unit insertion deprecation seems unavoidable in standard slick code #8261

Closed
scabug opened this issue Feb 11, 2014 · 14 comments
Closed

Comments

@scabug
Copy link

scabug commented Feb 11, 2014

[info] [warn] /localhome/jenkinsdbuild/workspace/Community-2.11.x-retronym/dbuild-0.7.1-M1/target-0.7.1-M1/project-builds/slick-788001088e5bab3527becf36534f278987af54a8/slick-testkit/src/main/scala/com/typesafe/slick/testkit/tests/PlainSQLTest.scala:140: Adaptation of argument list by inserting () has been deprecated: this is unlikely to be what you want.
[info] [warn]         signature: SQLInterpolation.sql[P](param: P)(implicit pconv: scala.slick.jdbc.SetParameter[P]): scala.slick.jdbc.SQLInterpolationResult[P]
[info] [warn]   given arguments: <none>
[info] [warn]  after adaptation: SQLInterpolation.sql((): Unit)
[info] [warn]     val q = sql"select 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23"
[info] [warn]             ^
@scabug
Copy link
Author

scabug commented Feb 11, 2014

Imported From: https://issues.scala-lang.org/browse/SI-8261?orig=1
Reporter: @retronym
Affected Versions: 2.11.0-M8

@scabug
Copy link
Author

scabug commented Feb 11, 2014

@scabug
Copy link
Author

scabug commented Feb 11, 2014

@retronym said:
/cc Simon + Adriaan + Stefan.

Marking as blocker so we make a decision on this one. I haven't looked that the pattern of code in Slick that closely yet to know where the fix ought to be.

@scabug
Copy link
Author

scabug commented Feb 11, 2014

@szeiger said:
There is a related problem in Slick: SQL interpolation is limited to 22 variables. Both are caused by the use of auto-tupling in the .sql and .sqlu extension methods. The standard procedure there is to use varargs but we need an implicit SetParameter[_] for each element based on the element's type, so we reply on auto-tupling and provide SetParameter instances for all tuples. A possible fix for the second problem (which would also take care of the first) is to make these methods macros with varargs params. The macro could generate the correct SetParameter on the fly. Since the return type does not depend on the parameter types, it should be possible to write these methods as black-box macros.

@scabug
Copy link
Author

scabug commented Feb 12, 2014

@clhodapp said:
What about just doing something like [https://gist.github.com/clhodapp/e2e8726e063f8ddee503]?

@scabug
Copy link
Author

scabug commented Feb 12, 2014

@szeiger said:
@clhodapp That looks like a very nice solution

@scabug
Copy link
Author

scabug commented Feb 12, 2014

@clhodapp said (edited on Feb 12, 2014 11:43:31 AM UTC):
The only drawback is that you get an allocation for each argument, but I don't think that's avoidable while fixing the problem.

@scabug
Copy link
Author

scabug commented Feb 12, 2014

@szeiger said:
A macro-based implementation could avoid the extra allocation. It would turn a call like sql(i, s) into _sql_raw(i, s)(new SeqSetParameter(implicitly[SetParameter[i.type]], implicitly[SetParameter[s.type]]))

@scabug
Copy link
Author

scabug commented Feb 13, 2014

@adriaanm said (edited on Feb 13, 2014 2:13:06 AM UTC):
Cool, so, it sounds like we can leave ()-insertion deprecated.
Please reopen and assign to me if I misunderstood.

@scabug scabug closed this as completed Feb 13, 2014
@scabug
Copy link
Author

scabug commented Jul 23, 2014

Samuel Halliday (fommil) said:
I just got stung by this. I don't understand how Chris' example helps here. How is one supposed to write a sql or sqlu query now?

e.g. for https://typesafe.com/activator/template/slick-plainsql-2.1#code/src/main/scala/Interpolation.scala

@scabug
Copy link
Author

scabug commented Jul 23, 2014

@clhodapp said:
My example was a way for SLICK itself to migrate from autotupling to varargs. It shouldn't affect source compatibility if they move to use it, but I think they may be moving to macros.

@scabug
Copy link
Author

scabug commented Jul 24, 2014

@szeiger said:
In Slick 2.1 you'll have to live with the warnings (or disable them). Macro-based versions of the SQL interpolators are coming in 2.2: slick/slick#834. They don't need auto-tupling and they're not limited to 22 parameters anymore.

@scabug
Copy link
Author

scabug commented Aug 10, 2014

Samuel Halliday (fommil) said:
I would like to use Slick in raw SQL mode on 2.11, but our project uses fatal warnings. Is there any way to turn off this specific warning from the compiler? Is there a Slick ticket that I can follow to know when this issue has been addressed?

@scabug
Copy link
Author

scabug commented Aug 10, 2014

@som-snytt said:
I asked this recently on the ML, because I overlooked this ticket.

One might have expected -source:2.10 to turn off language-level deprecations in 2.11. That might be a bug in the particular deprecation.

Also, deprecation should fall under -Xlint:deprecation as in javac. Then, Xlint could delegate deprecation to a pluggable mechanism. (As a suggested feature.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant