Skip to content

Releases: kaizen-solutions/virgil

Added more DSL features

09 Apr 17:13
Compare
Choose a tag to compare

From my experience as a user of this library, there are a lot of times where I wanted to have to select all columns or select a non empty chunk of columns when using the Select Builder, so I've gone ahead and added this:

SelectBuilder
    .from(tableName)
    .allColumns // also columns(nonEmptyChunkStr)
    .where(rel1).and(rel2)
    .build[DesiredType]

I've also gone ahead and implemented usingTimestamp and usingTTL as we have a couple of use cases for expiring rows (even though this should be done very cautiously with special attention paid to cleaning up and maintaining the SSTables frequently)

val insert = InsertBuilderSpecPerson
  .insert(person)
  .usingTTL(1.second) // this is a zio.Duration
  .usingTimestamp(13370000L)
  .build
  .executeMutation

That's all for now, thanks for using Virgil 😺

Add values to InsertBuilder

23 Mar 12:40
Compare
Choose a tag to compare

New additions

We added .values to InsertBuilder to help inserting a lot of columns without having to repeatedly type value

final case class Person(id: Int, name: Option[String], age: Option[Int])
object Person {
  val tableName = "person"
  val Id = "id"
  val Name = "name"
  val Age = "age"
  val AllColumns: NonEmptyChunk[String] = NonEmptyChunk(Id, Name, Age)

  def insert(in: Person): CQL[MutationResult] =
    InsertBuilder(tableName)
      .values(
        Id   -> in.id,
        Name -> in.name,
        Age  -> in.age
      )
      .ifNotExists
      .build
}

What's Changed

Full Changelog: 0.5.4...0.5.5

Improve performance & add executeMutation

20 Mar 15:11
Compare
Choose a tag to compare
  • Special thanks to @narma (see #38 and #39) for his contribution to decreasing the latency when selecting data from Cassandra in the case where the retrieved results are too big to fit in a single request as well as improving the pagination logic
  • Add executeMutation which returns a Task[MutationResult]

Improve null handling behavior

18 Mar 21:26
Compare
Choose a tag to compare

In prior releases, if you read out null data - you would get back default value (this is the driver behavior - so if you read a null int column, you'll get back 0). We have changed this confusing behavior to a DecoderException to indicate that something went wrong and you aren't getting back a proper value

Delete dsl

17 Mar 18:41
Compare
Choose a tag to compare
DeleteBuilder(tableName).entireRow.where(Id === person.id).build

DeleteBuilder(tableName).entireRow
  .where(Id === person.id)
  .ifCondition(Age > person.age)
//.andIfCondition(...)
  .build

Support IF EXISTS and IF <condition> AND <another_condition>

11 Mar 22:33
Compare
Choose a tag to compare

UpdateBuilder now supports lightweight transactions:

final case class UpdateBuilderSpecPerson(id: Int, name: String, age: Int)
object UpdateBuilderSpecPerson {
  val tableName: String = "updatebuilderspec_person"
  val Id                = "id"
  val Name              = "name"
  val Age               = "age"

  def find(id: Int) =
    SelectBuilder
      .from(tableName)
      .columns(Id, Name, Age)
      .where(Id === id)
      .build[UpdateBuilderSpecPerson]

  def insert(in: UpdateBuilderSpecPerson): CQL[MutationResult] =
    InsertBuilder(tableName)
      .value("id", in.id)
      .value("name", in.name)
      .value("age", in.age)
      .build
}

val updatedAge = person.age + 2

UpdateBuilder(tableName)
  .set(Age := updatedAge)
  .where(Id === person.id)
  .ifExists
  .build

UpdateBuilder(tableName)
  .set(Age := updatedAge)
  .where(Id === person.id)
  .ifCondition(Age <= person.age)
  .andIfCondition(Name === person.name)
  .build

cql interpolater fixes and enriched debugging

10 Mar 18:25
Compare
Choose a tag to compare
  • Fix critical issues with the cql interpolator that could not handle composing multiple cql strings that contained bind markers
  • Provide a debug method on CQL that allows you to introspect a query/mutation/batch

Improved codecs

07 Mar 21:27
Compare
Choose a tag to compare

We have drastically improved codecs by making them more composable, adding more information when errors occur as well as fixing bugs with the builders. In addition, we also reworked the Cursor abstraction so your case classes do not need to match your Cassandra table schema but you'll have to do extra work to map the Cassandra representation to your data.

Initial Release (BETA)

17 Feb 20:01
Compare
Choose a tag to compare

I thought that this would be a good time to get an initial release out the door. There are plenty of improvements (and significant internal changes) to be made but I think we're at a good point where the library is useful and can be put to good work.