Skip to content

Releases: kaizen-solutions/virgil

Release for ZIO 2.0.0

24 Jun 19:42
Compare
Choose a tag to compare

Virgil now supports ZIO 2.0

  • Underlying Cassandra metrics have been exposed (Thanks to @narma)

Expose metrics [zio1]

26 Jun 16:24
Compare
Choose a tag to compare

Thanks to @narma for exposing metrics

Add stripMargin to CqlInterpolatedString

19 Jun 20:38
Compare
Choose a tag to compare

We've added stripMargin which only works on the string portions of the cql query

 val query =
            cql"""SELECT id, name, persons
                 |FROM persons
                 |WHERE id = ${1} AND name = ${"cal"}""".stripMargin
// SELECT id, name, persons 
// FROM persons 
// WHERE id = :param0 AND name = :param1

Add stripMargin to CqlInterpolatedString

19 Jun 20:38
Compare
Choose a tag to compare

We've added stripMargin which only works on the string portions of the cql query

 val query =
            cql"""SELECT id, name, persons
                 |FROM persons
                 |WHERE id = ${1} AND name = ${"cal"}""".stripMargin
// SELECT id, name, persons 
// FROM persons 
// WHERE id = :param0 AND name = :param1

Bugfix for ZIO 2

10 Jun 17:51
Compare
Choose a tag to compare

Fixes the counter syntax and a CQL rendering bug pertaining to counter columns.

Here's some example usage

UpdateBuilder(tableName).set(Likes += in.likes).where(Id === in.id).build

Bugfix for ZIO 1

10 Jun 17:51
Compare
Choose a tag to compare

Fixes the counter syntax and a CQL rendering bug pertaining to counter columns.

Here's some example usage

UpdateBuilder(tableName).set(Likes += in.likes).where(Id === in.id).build

ZIO 2.0.0-RC6 support

03 May 19:49
Compare
Choose a tag to compare
ZIO 2.0.0-RC6 support Pre-release
Pre-release
  • select has been rewritten atop ZChannels to reduce allocations and improve performance
  • users of the API get better error information thanks to making use of Trace
  • Upgrade to ZIO 2.0.0-RC6

Scala 3

22 Apr 21:31
Compare
Choose a tag to compare

Virgil now has support for Scala 3. Codecs only have semi-automatic derivation but we'll get there 😸

final case class CursorExampleRow(
    id: Long,
    name: String,
    age: Short,
    @CqlColumn("may_be_empty") mayBeEmpty: Option[String],
    @CqlColumn("addresses") pastAddresses: Chunk[CursorUdtAddress]
  )

  object CursorExampleRow {
    given cqlRowDecoderForCursorExampleRow: CqlRowDecoder.Object[CursorExampleRow] =
      CqlRowDecoder.derive[CursorExampleRow]

    val tableName = "cursorspec_cursorexampletable"

    def truncate: CQL[MutationResult] = CQL.truncate(tableName)

    def insert(row: CursorExampleRow): CQL[MutationResult] =
      InsertBuilder(tableName)
        .values(
          "id"           -> row.id,
          "name"         -> row.name,
          "age"          -> row.age,
          "addresses"    -> row.pastAddresses,
          "may_be_empty" -> row.mayBeEmpty
        )
        .build

    def select(id: Long): CQL[Row] = {
      val cql = cql"SELECT * FROM " ++ tableName.asCql ++ cql" WHERE id = $id"
      cql.query
    }
  }

  final case class CursorUdtAddress(street: String, city: String, state: String, zip: String, note: CursorUdtNote)
  object CursorUdtAddress {
    given cqlUdtValueDecoderForCursorUdtAddress: CqlUdtValueDecoder.Object[CursorUdtAddress] =
      CqlUdtValueDecoder.derive[CursorUdtAddress]

    given cqlUdtValueEncoderForCursorUdtAddress: CqlUdtValueEncoder.Object[CursorUdtAddress] =
      CqlUdtValueEncoder.derive[CursorUdtAddress]
  }

  final case class CursorUdtNote(data: String, ip: InetAddress)
  object CursorUdtNote {
    given cqlUdtValueDecoderForCursorUdtNote: CqlUdtValueDecoder.Object[CursorUdtNote] =
      CqlUdtValueDecoder.derive[CursorUdtNote]

    given cqlUdtValueEncoderForCursorUdtNote: CqlUdtValueEncoder.Object[CursorUdtNote] =
      CqlUdtValueEncoder.derive[CursorUdtNote]
  }

ZIO 2.0 RC5 support

30 Apr 22:23
Compare
Choose a tag to compare
ZIO 2.0 RC5 support Pre-release
Pre-release

This release supports the latesrt version of ZIO 2.0 which is RC5 at the time. ZManaged and Has are deleted and we exclusively rely on Scopes to manage resources (like CqlSession and CQLExecutor).

Critical codec bugfix for Cassandra collections

15 Apr 13:19
Compare
Choose a tag to compare

Fixed a critical bug in codecs which treated empty Cassandra collections as an error since there is aggressive null checking. However, Cassandra does not actually have the concept of nullable collections like they do with their other datatypes. They store empty collections using null which is a bit confusing. So we changed the behavior of the codecs to account for this fact. So now you can do this:

Given a Cassandra table

CREATE TABLE example (
 id INT PRIMARY KEY,
 data set<ascii>
);
final case class Example(
  @CqlColumn("id") id: Int,
  @CqlColumn("data") data: Set[String]
)
val insert =
  InsertBuilder("example")
    .values(
      "id"   -> 2,
      "data" -> Set.empty[String]
    )
    .build
    .executeMutation

val select =  
  SelectBuilder
    .from("example")
    .allColumns
    .build[Example]
    .execute
    .runCollect

This will correctly return empty Set values. The same is true when using the Cursor API.

🔴 Please keep in mind if you wrap Cassandra collections in Option, you'll get the equivalent of having Option[NonEmptyCollection] behavior in that you will either have a None if you persist an empty collection or a populated collection would appear as Some(List(1)) as an example.