Skip to content

v0.3.0-beta11

Latest
Compare
Choose a tag to compare
@takapi327 takapi327 released this 21 Feb 12:14
· 12 commits to master since this release

ldbc v0.3.0-beta11 is released.
This release includes new feature additions, enhancements to existing features, disruptive changes and much more.

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.

What's Changed

Adding DataType Column

If a column was to be given a data type or other setting, it had to be passed as an argument.
With this correction, it is now possible to define columns with data type characteristics.

In this method of definition, the column name can be used as the variable name, so it is no longer necessary to pass the column name as an argument.

class EntityTable extends Table[Entity]("entity"):
-  def c1: Column[Long] = column[Long]("ci", BIGINT, AUTO_INCREMENT)
+  def c1: Column[Long] = bigint().autoIncrement

Column names can change their format by implicitly passing Naming.
The default is CamelCase, but to change this to PascalCase, do the following

class EntityTable extends Table[Entity]("entity"):
  given Naming = Naming.PASCAL

  def c1: Column[Long] = bigint().autoIncrement

If you want to change the format of a particular column, you can still define it by passing the column name as an argument.

class EntityTable extends Table[Entity]("entity"):
  given Naming = Naming.PASCAL

  def c1: Column[Long] = bigint().autoIncrement
  def c2: Column[Long] = bigint("c_2")

Adding DDL Schema

Add schema function to perform DDL.

class UserTable extends Table[User]("user"):
  def id:   Column[Long]        = bigint().autoIncrement.primaryKey
  def name: Column[String]      = varchar(255)
  def age:  Column[Option[Int]] = int()

  override def * : Column[User] = (id *: name *: age).to[User]

val userTable = TableQuery[UserTable]

connection
  .use { conn =>
    DBIO
      .sequence(
        userTable.schema.create,
        userTable.schema.createIfNotExists,
        userTable.schema.dropIfExists,
        userTable.schema.create
      )
      .commit(conn)
  }

Schema can also be composed with other Schemas.

userTable.schema ++ userProfileTable.schema

SQL executable statements can be checked with the statements method.

userTable.schema.create.statements.foreach(println)
userTable.schema.createIfNotExists.statements.foreach(println)
userTable.schema.drop.statements.foreach(println)
userTable.schema.dropIfExists.statements.foreach(println)
userTable.schema.truncate.statements.foreach(println)

Performance Improvement

The change was made because the method of splitting using splitAt was faster than using the helper functions provided by scodec.

Before

Select

After

Select

💪 Enhancement

🪲 Bug Fixes

  • Comparison operator compile error due to use of Opaque Type Alias by @takapi327 in #357
  • Empty VALUES in INSERT statement causes error statement to be issued by @takapi327 in #362
  • Passing an empty value in the IN clause of a WHERE statement throws an error by @takapi327 in #364
  • Fixed a bug that caused incorrect statements to be issued when keys w… by @takapi327 in #392

🔧 Refactoring

⛓️ Dependency update

New Contributors

New @i10416 contributor. Thanks!

Full Changelog: v0.3.0-beta10...v0.3.0-beta11