Skip to content

Release 2.6.0

Compare
Choose a tag to compare
@mmatczuk mmatczuk released this 26 Nov 11:13
· 47 commits to master since this release

This release adds automatic support for gocql.UnsetValue.
This is a special value representing not set i.e. not resulting in any change to the existing value.
This is great for PATCHING entities, you can have a single prepared statement that can be reused to update any combination of the fields.

Example:

The following example upserts Operation not changing the Fee field.

	// Insert operation with empty fee.
	insertQuery = insertOperation.Query(session).
		WithBindTransformer(gocqlx.UnsetEmptyTransformer).
		BindStruct(Operation{
			ID:        "2",
			ClientID:  "42",
			Type:      "Input",
			PaymentID: "1",
			Fee:       nil,
		})
	if err := insertQuery.ExecRelease(); err != nil {
		t.Fatal("ExecRelease() failed:", err)
	}

Also, the bind transformer can be set globally for the whole application.

	// Set default transformer to avoid setting it for each query.
	gocqlx.DefaultBindTransformer = gocqlx.UnsetEmptyTransformer

What's Changed

  • qb: add named limit and per partition limit clauses by @N1cOs in #208
  • queryx: unset empty values by @N1cOs in #206

New Contributors

Full Changelog: v2.5.0...v2.6.0