Skip to content

v0.3.0-beta2

Compare
Choose a tag to compare
@takapi327 takapi327 released this 22 May 23:27
· 997 commits to master since this release

ldbc v0.3.0-beta2 is released.
This release adds enhancements to existing features.

Note

ldbc is pre-1.0 software and is still undergoing active development. New versions are not binary compatible with prior versions, although in most cases user code will be source compatible.
The major version will be the stable version.

Functional modification: extension of Connection and integration with the ldbc package.

The Scala-made MySQL connector now integrates with the ldbc package, allowing more intuitive and flexible database operations.

Our Scala-made MySQL connector has a new integration with the ldbc package to make the interaction with the database more sophisticated. This modification enables intuitive and flexible database queries that utilise Scala's functional programming patterns. Users can now interact with the database using plain queries as follows.

connection.use { conn =>
  (for
    result1 <- sql"SELECT `p1`, `p2` FROM `table1`".toList[(Int, Int)]
    result2 <- sql"SELECT `p1`, `p2` FROM `table1` WHERE `p1` = ${ 1 }".headOption[(Int, Int)]
    result3 <- sql"SELECT `p1`, `p2` FROM `table1`".unsafe[(Int, Int)]
  yield (result1, result2, result3)).run(conn)
}

Main modifications:

  • Support for functional queries: through the ldbc library, it is possible to build queries that take advantage of Scala's functional properties. This improves code readability and maintainability.
  • Code simplification: combining multiple queries can now be done directly within a single context, greatly increasing the efficiency of database operations.
  • Increased security and flexibility: methods such as .toList, .headOption and .unsafe allow for fine-grained control over how data is retrieved, enhancing security and flexibility.

The enhancements allow developers working with MySQL databases using Scala to achieve more advanced and intuitive database access. The integrated ldbc package significantly improves the performance and usability of the programme and makes it easier to perform complex database tasks.

Important change

Caution

A naming change has been made with regard to the API for update systems.

The API updateReturningAutoGeneratedKey, which converts values generated by AUTO INCREMENT columns in the update API, has been renamed to returning.

This is a characteristic of MySQL, which returns the value generated by AUTO INCREMENT when inserting data, whereas other RDBs have different behaviour and can return values other than those generated by AUTO INCREMENT.
The API name was changed early on to make the limited API name more extensible in view of future extensions.

before

sql"INSERT INTO `table`(`id`, `c1`) VALUES ($None, ${ "column 1" })".updateReturningAutoGeneratedKey[Long]

after

sql"INSERT INTO `table`(`id`, `c1`) VALUES ($None, ${ "column 1" })".returning[Long]

What's Changed

🚀 Features

Full Changelog: v0.3.0-beta1...v0.3.0-beta2