Skip to content

Releases: takapi327/ldbc

v0.3.0-beta4

20 Jun 12:51
Compare
Choose a tag to compare

ldbc v0.3.0-beta4 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 plain query construction.

The determination of the type retrieved by the database connection method using a plain query used to specify the type to be retrieved and its format (List or Option) collectively.

This modification changed that and made the internal logic common by separating the type to be retrieved from the specification of its format. This makes the plain query syntax more similar to doobie, so users of doobie should be able to use it without confusion.

before

sql"SELECT id, name, age FROM user".toList[(Long, String, Int)].readOnly(connection)
sql"SELECT id, name, age FROM user WHERE id = ${1L}".headOption[User].readOnly(connection)

after

sql"SELECT id, name, age FROM user".query[(Long, String, Int)].to[List].readOnly(connection)
sql"SELECT id, name, age FROM user WHERE id = ${1L}".query[User].to[Option].readOnly(connection)

Dependency changes (Broken change)

Caution

This change is not compatible with previous versions. It constitutes a disruptive change.

Previously, ldbc-query-builder was included in ldbc-dsl. However, with this update, if you want to use the Query Builder, you need to set up an additional dependency on ldbc-query-builder.

libraryDependencies += "io.github.takapi327" %% "ldbc-query-builder" % "0.3.0-beta4"

What's Changed

🔧 Refactoring

⛓️ Dependency update

New Contributors

Full Changelog: v0.3.0-beta3...v0.3.0-beta4

v0.3.0-beta3

03 Jun 13:50
Compare
Choose a tag to compare

ldbc v0.3.0-beta3 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: support for connector switching

The Scala MySQL connector has added new support for switching connections between JDBC and ldbc.

The modification allows developers to flexibly select database connections using the JDBC or ldbc libraries, depending on the requirements of the project. This allows them to utilise the functionality of the different libraries and increases flexibility in setting up and operating the connection.

How to switch

First, set up common dependencies.

libraryDependencies += "io.github.takapi327" %% "ldbc-dsl" % "0.3.0-beta3"

For Cross-Platform projects (JVM, JS, and/or Native):

libraryDependencies += "io.github.takapi327" %%% "ldbc-dsl" % "0.3.0-beta3"

The dependency package used depends on whether the database connection is made via a connector using the Java API or a connector provided by ldbc.

Use jdbc connector

libraryDependencies += "io.github.takapi327" %% "jdbc-connector" % "0.3.0-beta3"

Use ldbc connector

libraryDependencies += "io.github.takapi327" %% "ldbc-connector" % "0.3.0-beta3"

For Cross-Platform projects (JVM, JS, and/or Native)

libraryDependencies += "io.github.takapi327" %%% "ldbc-connector" % "0.3.0-beta3"

Usage

The difference in usage is that there are differences in the way connections are built between jdbc and ldbc.

Caution

ldbc is currently under active development. Please note that current functionality may therefore be deprecated or changed in the future.

jdbc connector

val ds = new com.mysql.cj.jdbc.MysqlDataSource()
ds.setServerName("127.0.0.1")
ds.setPortNumber(13306)
ds.setDatabaseName("world")
ds.setUser("ldbc")
ds.setPassword("password")

val datasource = jdbc.connector.MysqlDataSource[IO](ds)

val connection: Resource[IO, Connection[IO]] =
  Resource.make(datasource.getConnection)(_.close())

ldbc connector

val connection: Resource[IO, Connection[IO]] =
  ldbc.connector.Connection[IO](
    host     = "127.0.0.1",
    port     = 3306,
    user     = "ldbc",
    password = Some("password"),
    database = Some("ldbc"),
    ssl      = SSL.Trusted
  )

The connection process to the database can be carried out using the connections established by each of these methods.

val result: IO[(List[Int], Option[Int], Int)] = connection.use { conn =>
  (for
    result1 <- sql"SELECT 1".toList[Int]
    result2 <- sql"SELECT 2".headOption[Int]
    result3 <- sql"SELECT 3".unsafe[Int]
  yield (result1, result2, result3)).readOnly(conn)
}

Using the query builder

ldbc provides not only plain queries but also type-safe database connections using the query builder.

The first step is to create a schema for use by the query builder.

ldbc maintains a one-to-one mapping between Scala models and database table definitions. The mapping between the properties held by the model and the columns held by the table is done in definition order. Table definitions are very similar to the structure of Create statements. This makes the construction of table definitions intuitive for the user.

case class User(
  id: Long,
  name: String,
  age: Option[Int],
)

val table = Table[User]("user")(                     // CREATE TABLE `user` (
  column("id", BIGINT, AUTO_INCREMENT, PRIMARY_KEY), //   `id` BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY,
  column("name", VARCHAR(255)),                      //   `name` VARCHAR(255) NOT NULL,
  column("age", INT.UNSIGNED.DEFAULT(None)),         //   `age` INT unsigned DEFAULT NULL
)              

The next step is to build a TableQuery using the schema you have created.

import ldbc.query.builder.TableQuery

val userQuery = TableQuery[IO, User](table)

Finally, you can use the query builder to create a query.

val result: IO[List[User]] = connection.use { conn =>
  userQuery.selectAll.toList[User].readOnly(conn)
  // "SELECT `id`, `name`, `age` FROM user"
}

Functional modification: extension of plain query construction.

A new feature has been added to the MySQL connector in Scala to treat static strings as query strings.

Our Scala-made MySQL connector has extended the plain query construction functionality to increase query flexibility. In particular, a new sc function has been introduced that allows static strings to be used in string completion. This allows static strings to be incorporated directly as part of the query.

Examples of use and details of functions

Introducing the sc function: sc stands for static context, which can be used in string completion to safely incorporate static strings, such as table names, into queries.

Assembling the query

val table = sc("table_name")
sql"SELECT * FROM $table WHERE id = ${1L}"

In the above code, table_name is incorporated into the query as a static string using sc and "SELECT * FROM table_name WHERE id = ?" The SQL is generated in the form "SELECT * FROM table_name WHERE id = ? In this way, the placeholder (?) corresponds to a dynamic parameter (in this case 1L).

This extension makes it easier to create more dynamic and secure queries. This new method is particularly useful when multiple table names or SQL fragments need to be combined dynamically from the programme.

Functional modification: provision of functions to support plain query construction.

The MySQL connector in Scala adds a new feature for building queries using dynamic values.

The enhancements allow developers to build SQL queries more flexibly and simplify the dynamic generation of SQL, especially when dealing with multiple values and conditions. Key new features include utility functions for efficiently building combinations of values, in, notIn, and, or and conditional expressions.

Main new functions

  • values function: allows multiple values to be incorporated into a VALUES expression, e.g. used for batch insertion.
  • in and notIn functions: generate IN and NOT IN clauses based on a specified list of values.
  • and and or functions: combine multiple conditions with AND or OR to form logical conditional expressions.
  • whereAnd and whereOr functions: incorporate multiple conditions into a WHERE clause to enhance query filtering.

examples showing the use (of a word)

val ids = List(1, 2, 3)  // Dynamically generated values
val query = sql"SELECT * FROM users WHERE" ++ in(sql"id", ids)
// SELECT * FROM users WHERE id IN (?, ?, ?)

With this retrofit, developers using the MySQL connector from Scala will be able to build programmatically complex queries easily and safely. This will improve the performance and maintainability of applications and allow for more diverse data manipulation.

What's Changed

🚀 Features

💪 Enhancement

🪲 Bug Fixes

🔧 Refactoring

📖 Documentation

⛓️ Dependency update

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

v0.3.0-beta2

22 May 23:27
Compare
Choose a tag to compare

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

v0.3.0-beta1

20 May 01:32
Compare
Choose a tag to compare

ldbc v0.3.0-beta1 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.

We have merged the JDBC-mimicking interface used by ldbc connector with the ldbc sql package.
This makes it ready to work with the other packages in ldbc.

What's Changed

🔧 Refactoring

  • Match the ldbc sql package to ldbc connector. by @takapi327 in #206
  • Refactor/2024 05 remove cora package dependency from sql package by @takapi327 in #208
  • Refactor/2024 05 Integration with sql package by @takapi327 in #209
  • Refactor/2024 05 integration savepoint by @takapi327 in #210

⛓️ Dependency update

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

v0.3.0-alpha9

12 May 14:24
Compare
Choose a tag to compare

ldbc v0.3.0-alpha9 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.

New: CallableStatement Support

A new CallableStatement feature for calling stored procedures and functions has been added to the MySQL connector in Scala.

Our Scala-made MySQL connector introduces new CallableStatement support for more advanced interaction with the database. This feature allows direct calls to stored procedures and database functions. This is especially useful for streamlining data processing and improving application performance by executing complex logic on the database server side.

Features:

  • Stored Procedure Execution: Stored procedures defined in the database can be executed, allowing complex data manipulation and business logic to be handled at the database level.
  • Database function calls: Database functions can be used to perform specific calculations as part of a query. This reduces the load on the application and improves overall response time.
  • Support for input and output parameters: Input parameters can be passed and output parameters can be received through CallableStatement. This allows for flexible and dynamic database interactions.

Take advantage of this update to the MySQL connector in Scala to take your application's database interactions to the next Take your application's database interaction to the next level with this update to the MySQL Connector in Scala.

What's Changed

🚀 Features

⛓️ Dependency update

Full Changelog: v0.3.0-alpha8...v0.3.0-alpha9

v0.3.0-alpha8

06 May 11:05
Compare
Choose a tag to compare

ldbc v0.3.0-alpha8 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.

What's Changed

🔧 Refactoring

⛓️ Dependency update

Full Changelog: v0.3.0-alpha7...v0.3.0-alpha8

v0.3.0-alpha7

03 May 06:18
Compare
Choose a tag to compare

ldbc v0.3.0-alpha7 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

Full support for java.sql.DatabaseMetaData has been added to the MySQL connector in Scala.

Our Scala-made MySQL connector has added new support for java.sql.DatabaseMetaData to further enhance its database connection capabilities. This extension allows developers to directly retrieve comprehensive information about database metadata. This includes database version, supported SQL keywords, data types, stored procedure information, and more.

Major modifications:

  • Full support for DatabaseMetaData: All methods of the DatabaseMetaData interface are supported, making it easy to obtain detailed information about database structure and functionality.
  • Enhanced tools for developers: Database metadata can be used to efficiently perform more advanced database management tasks such as analyzing database schemas, optimizing queries, and checking application compatibility.
  • Dynamic database interactions: Querying database metadata directly from the program allows for the development of dynamic database applications, greatly increasing development flexibility.

With this retrofit, developers using Scala's MySQL connector will be able to better understand and take full advantage of the database's capabilities. Connecting to the database will be more informative and efficient, improving application quality and performance.

What's Changed

🔧 Refactoring

Full Changelog: v0.3.0-alpha6...v0.3.0-alpha7

v0.3.0-alpha6

26 Apr 13:21
Compare
Choose a tag to compare

ldbc v0.3.0-alpha6 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 ResultSet

Scala-made MySQL connector is now even more powerful! Full support for java.sql.ResultSet and ResultSetMetaData (except Insert/Update/Delete) has been added.

Our Scala-made MySQL connector has greatly enhanced the functionality of ResultSet to further enrich interaction with the database. With this upgrade, many features of java.sql.ResultSet are now supported, but the Insert, Update, and Delete operations are currently not supported. In addition, a new ResultSetMetaData feature has been added. This will greatly improve data retrieval and analysis from the database.

Major modifications:

  • Partial support for ResultSet: Many methods and functions of java.sql.ResultSet have been integrated to allow more flexible processing of data from SQL queries. However, Insert/Update/Delete operations are not supported, so consider other means for these operations.
  • Support for ResultSetMetaData: Allows metadata access to query results, making it easier to retrieve important information such as number of columns, column names, and column types. This allows for a high degree of control over dynamic query processing and data mapping.

This modification will allow developers to process information from the database in a more detailed and efficient manner. In particular, this new feature will be of great help when handling complex query results from the database or when dynamic use of the resulting data is required within a program. Enhance your application's database layer for more sophisticated data manipulation!

What's Changed

🔧 Refactoring

📖 Documentation

⛓️ Dependency update

Full Changelog: v0.3.0-alpha5...v0.3.0-alpha6

v0.3.0-alpha5

15 Apr 09:12
Compare
Choose a tag to compare

ldbc v0.3.0-alpha5 is released.
This release adds new feature support.

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.

New: Batch Commands Support

A powerful tool for efficient data processing, the MySQL Connector from Scala has new features!

Our Scala MySQL connector introduces support for the Batch Commands feature to further streamline database interaction. This feature allows multiple database commands to be processed at once, providing significant time savings in situations where large amounts of data manipulation or repetitive queries are required.

Features:
Automated batch processing: Groups multiple SQL statements as a batch and executes them at once, reducing the overhead of repeatedly sending individual commands.
Performance optimization: Batch processing minimizes network latency and CPU utilization, improving overall performance.

This new feature improves the efficiency of database operations and allows developers to perform more complex database operations easily and quickly. This is especially useful when performing many operations on large data sets or for routine data maintenance tasks. We invite you to try out the new batch command feature!

What's Changed

🚀 Features

⛓️ Dependency update

Full Changelog: v0.3.0-alpha4...v0.3.0-alpha5

v0.3.0-alpha4

05 Apr 16:11
Compare
Choose a tag to compare

ldbc v0.3.0-alpha4 is released.
This release adds new feature support.

Note that 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.

New: Utility Commands Support

Our Scala-made MySQL connector now supports the new Utility Commands feature for database management and debugging. These commands are designed to simplify day-to-day interaction with the database and allow developers to work more efficiently. The following new features are available

New command summary:

  • COM_INIT_DB: Initializes the database and starts a new database session.
  • COM_STATISTICS: Obtains database statistics and provides valuable insight for performance monitoring and optimization.
  • COM_PING: Verifies that the connection to the database server is live and maintains the health of the connection.
  • COM_CHANGE_USER: Switch users on the current connection and reevaluate access rights.
  • COM_RESET_CONNECTION: Reset the connection, clearing the session state and starting fresh.
  • COM_SET_OPTION: Set connection options and customize session behavior.

These features allow developers to manage, monitor, and debug databases in a more intuitive manner, greatly improving their daily work efficiency. In addition, these commands open up new possibilities for optimizing application performance and improving the user experience.

What's Changed

🚀 Features

  • Feature/2024 03 add com statistics utility commands by @takapi327 in #180
  • Feature/2024 04 add com ping utility commands by @takapi327 in #181
  • Feature/2024 04 add com reset connection utility commands by @takapi327 in #182
  • Feature/2024 04 add com set option utility commands by @takapi327 in #183
  • Feature/2024 04 add com change user utility commands by @takapi327 in #184

🔧 Refactoring

📖 Documentation

⛓️ Dependency update

Full Changelog: v0.3.0-alpha3...v0.3.0-alpha4