Slick 3.1.0

October 09 2015
by Stefan Zeiger

We are happy to announce the release of Slick 3.1.0. These are the major new features compared to Slick 3.0.0:

  • New query compiler back-end. The main goal is to avoid subqueries wherever possible. For example, this query from Slick’s test suite

      ((xs joinLeft ys on (_.b === _.b)) joinLeft ys on (_._1.b === _.b)).to[Set]
    

used to get compiled to deeply nested code which could prevent proper optimization by some database engines (in particular MySQL) with Slick 3.0:

    select x2.x3, x2.x4, x2.x5, x2.x6, x2.x7, x2.x8, x2.x9, x2.x10
    from (
      select x11.x12 as x3, x11.x13 as x4, x11.x14 as x5, x11.x15 as x6, x11.x16 as x7, x17.x18 as x8, x17.x19 as x9, x17.x20 as x10
      from (
        select x21.x22 as x12, x21.x23 as x13, x24.x25 as x14, x24.x26 as x15, x24.x27 as x16
        from (
          select x28."a" as x22, x28."b" as x23
          from "xs_jo" x28
        ) x21
        left outer join (
          select 1 as x25, x29."a" as x26, x29."b" as x27
          from "ys_jo" x29
        ) x24
        on x21.x23 = x24.x27
      ) x11
      left outer join (
        select 1 as x18, x30."a" as x19, x30."b" as x20
        from "ys_jo" x30
      ) x17
      on x11.x13 = x17.x20
    ) x2

Slick 3.1 produces the following code instead:

    select x2."b", x3."b", x3."a", x4."b", x2."a", x4."a"
    from "xs_jo" x2
    left outer join "ys_jo" x3
    on x2."b" = x3."b"
    left outer join "ys_jo" x4
    on x2."b" = x4."b"
  • Improved support for monadic joins in the query compiler. In particular, whenever a monadic join cannot be translated into an applicative join (as required for SQL), the query compiler will fail with a useful error message instead of producing invalid code.

  • Improved configuration of database connections via Typesafe Config: You can now configure arbitrary DataSource classes with Java Bean semantics when running without a connection pool (similar to what was already supported by HikariCP). For example:

      db {
        connectionPool = disabled
        dataSourceClass = "slick.jdbc.DriverDataSource"
        properties = {
          driver = "org.h2.Driver"
          url = "jdbc:h2:mem:test_ds1"
          properties = {
            LOCK_MODE = 1
          }
        }
      }
    
  • Database connections can be configured through a DATABASE_URL syntax as used on PaaS platforms like Heroku:

      db {
        dataSourceClass = "slick.jdbc.DatabaseUrlDataSource"
        properties = {
          driver = "org.postgresql.Driver"
          url = "postgres://user:pass@host/dbname"
        }
      }
    
  • Configurable class loading when resolving Slick drivers: In containers which separate parts of an application into different ClassLoaders (e.g. Play, OSGi), the previous approach of using Class.forName did not work in all cases. You can now provide a custom ClassLoader, and Slick will fall back to the context ClassLoader in other cases.

  • Support for HikariCP is now in a separate module which makes it easier to depend on the correct, binary compatible version of HikariCP.

  • New query operators “distinct” and “distinctOn” which compile to proper DISTINCT queries in SQL.

  • Performance improvements in the query compiler. Query compilation is now more than 2.5 times as fast as it was in 3.0. This is particularly useful if you frequently have to run queries that cannot be pre-compiled (using Slick’s Compiled feature)

You can find the source code for the new release here: https://github.com/slick/slick/tree/3.1.0. Builds for Scala 2.10 and 2.11 are available from Maven Central, as usual. The commercial Slick Extensions package with closed-source drivers for Oracle, DB/2 and SQL Server has been published to the Typesafe repository. See the manual for details on adding it to your build.

In order to use Slick in a Play application we provide the Play Slick plugin. Version 1.1.0, which integrates Slick 3.1.0 into Play 2.4, is now available.

If you are new to Slick check out the Hello Slick template in Typesafe Activator to get started. You can see how Slick is used in a Play application in the Play Scala Intro template.

Here is the complete list of changes from Slick 3.0.0 to 3.1.0:
  • 73a0166 Release 3.1.0
  • 85f3eba Release 3.1.0-RC3
  • 11650b8 add documentation for insertOrUpdate
  • d7ea32d Fix 3VL handling in a scalar optimization
  • cb64121 Release 3.1.0-RC2
  • 5b5ff92 Allow insert operations with no columns to insert.
  • aff4896 Fix typing bug in rewriteJoins:
  • afd6f9b Allow illegal length CHAR defaults to be ignored in JdbcModelBuilder
  • b739255 Some bug fixes concerning Option types:
  • 84cc95a Add Query#subquery as a precaution for implementing workarounds.
  • 8f8ae8b Prevent repetition of bind variables used in GROUP BY:
  • 7199b51 Add countDefined operator:
  • 35b698d Fix source links for Slick core scaladocs
  • 0cfff09 Remove transaction handling from JdbcBackend#Session:
  • 29271b1 Add test cases for Options of primitive types.
  • 007e287 Trampolining for chained DBIOActions
  • 9c0d371 Release 3.1.0-RC1
  • d2e50d4 Remove dependent types for .delete and .findby extension methods.
  • 5cbabf6 Add documentation for default string type changes
  • ebfb344 Ensure non-empty “select” clauses in mergeToComprehensions:
  • f82a8fe Better integration of expandConditionals into expandSums
  • 07cd37a Allow selective translation for Take or Drop in removeTakeDrop:
  • dc1c551 Correctly propagate a Driver object to DriverDataSource
  • 6cb62b8 Integrate expandConditionals into expandSums
  • d286c17 Selectively skip compiler phases:
  • 9d8bbee Add Query.distinct and Query.distinctOn operators
  • 04ca00d codegen: schema: Handle case of no tables
  • 53cb788 codegen: Test case of no tables (schema has invalid syntax)
  • bc90afe A simpler and faster implementation of assignUniqueSymbols
  • 969ec5f Use correct discriminator checks under three-valued logic
  • e6acabf Some type-related fixes and improvements from tmp/globaltypes2
  • bcdeeaa Prevent retry of lazy Connection acquisition attempt in BaseSession:
  • 1634965 More intelligent handling of String types on MySQL
  • da7aaa9 Create correct syntax for casts on MySQL
  • c9bdcb1 More micro-optimizations and streamlining of ConstArray use
  • 2adb7c3 Use a custom collection implementation in the AST:
  • b48115a Profiling settings plus small performance improvements
  • 8ac4298 Only set Hikari dataSourceClassName or driverClassName but not both
  • 8dac76f Add two more expr customization for pg current_date and current_time
  • 1c9469f Scalar optimization & better discriminator column picking:
  • b01e539 More query compiler performance improvements:
  • b87c994 Eliminate explicit outer join discriminator columns where possible
  • 34bf73f Set Slick Extensions version in the manual independent of Slick version
  • 3bd24cc Some small query compiler performance optimizations:
  • a71aff4 Add detectRebuild option to mark rebuilt leaf nodes after each phase:
  • ed2af9b Add a benchmark for the query compiler.
  • 7333bd9 More consistent Query.length (“COUNT(*)”) semantics:
  • 16be008 Fix docs and simplify (no binary compatibility constraints for 3.1)
  • c197fdb Move HikariCPJdbcDataSource into a separate module
  • b651a62 Clean up the build file
  • 764b405 Avoid subqueries around zipWithIndex operations
  • 7514666 Database.forConfig uses provided config params numThreads and queueSize
  • 5ca0e5c Add tests for the removeTakeDrop phase:
  • a30d5df Fixed a mistake in the docs markup
  • e957544 Fix the implicit conversions for Compiled queries.
  • ea15636 Workaround SI-7139 caused by eponymous type alias and object
  • c762b55 Improve code generation
  • aaf2a22 Early hoisting of client-side operations:
  • 99c2737 add one more parameter typeName to jdbcTypeToScala
  • ffee22c Improve subquery fusion for Union operations
  • fbd2289 Add the correct scala-sbt repo for resolving sbt-testng.plugin
  • 31672a2 Remove deprecated APIs
  • 2ae5320 Added documentation for DatabaseUrlDataSource
  • 7fcd722 Add a test for DatabaseUrlDataSource
  • f637d52 Revised DatabaseUrlDataSource to have a no-arg cstr.
  • 9cfd03e Added a DatabaseUrlDataSource for use with DATABASE_URL
  • 79d2e67 Support Typesafe Config-based configuration of DataSource beans
  • 4565f09 Clean up the ClassLoader support from #1152:
  • 95dad0a Set hikariCP validationTimeout from config or 1000ms
  • 9b58a50 Pin HikariCP at version 2.3.7 to match play-slick
  • 5ef94f8 Remove AccessDriver
  • cce3b95 Remove the Direct Embedding (deprecated in 3.0)
  • 4b7262e Add test for resolving reference.conf in OSGi context
  • a9dd9a8 Fix OSGi tests (did not run due to duplicate slf4j on classpath)
  • ff264c9 Bump version numbers
  • b9861f1 Remove obsolete code
  • 36d5552 Improve Take, Drop and zip join translation
  • f170783 Fix type bugs and enforce correct types in the query compiler:
  • 85df538 Codegen: Suppress output of schema.create if ddlEnabled is false
  • 4fd654f Add Gitter badge
  • e26a7d0 Remove TypedNode:
  • 1c2d5db AST simplifications
  • 3470fa0 Compiler improvements:
  • 8baa079 New Query Compiler Back-End
  • 2b14139 Early transformation of monadic joins into applicative joins.
  • f53f06e Move createResultSetMapping down after forceOuterBinds
  • 1d55c69 Fix view source for scaladoc and edit this file on github for docs
  • 325f200 Improve tree logging
  • ae7e4d8 Improve logging:
  • 1abf753 Allow classloader to be specified for classloading
  • 0cab15e Add docs about DBIO composition.

Past News Items

Aug 16 2022
If you use Slick, please try 3.4.0-RC3 by changing the version in your build. After a week, if no regressions have been reported we will G-d willing release 3.4.0 (final)....
Apr 23 2021
Slick is community-maintained. Planning for future releases, including for Scala 3, is in progress. Please help if you can! For details, visit [this ticket](https://github.com/slick/slick/issues/2198).
Sep 09 2020
We have just released Slick 3.3.3 You can find the source code here: . Builds for Scala 2.11, 2.12 and 2.13 are available from Maven Central, as usual. ## Highlights...
Jan 30 2019
We have just released Slick 3.3.0 You can find the source code here: . Builds for Scala 2.11 and 2.12 are available from Maven Central, as usual. ## These are...
Mar 23 2018
We have just released Slick 3.2.3. You can find the source code here: . Builds for Scala 2.11 and 2.12 are available from Maven Central, as usual. From 3.2.0 on,...
Mar 06 2018
We have just released Slick 3.2.2. You can find the source code here: . Builds for Scala 2.11 and 2.12 are available from Maven Central, as usual. From 3.2.0 on,...
Jul 20 2017
We have just released Slick 3.2.1. You can find the source code here: . Builds for Scala 2.11 and 2.12 are available from Maven Central, as usual. From 3.2.0 on,...
Feb 24 2017
We have just released Slick 3.2.0. You can find the source code here: . Builds for Scala 2.11 and 2.12 are available from Maven Central, as usual. From this release...