upper/db
Data Access Layer (DAL) for PostgreSQL, CockroachDB, MySQL, SQLite and MongoDB with ORM-like features.
📋 What's Changed
- migrate mongodb driver by @xiam in https://github.com/upper/db/pull/724
- upgrade depencencies by @xiam in https://github.com/upper/db/pull/725
- Full Changelog: https://github.com/upper/db/compare/v4.9.0...v4.10.0
📋 What's Changed
- upgrade to pgx/v5 by @xiam in https://github.com/upper/db/pull/715
- Full Changelog: https://github.com/upper/db/compare/v4.8.0...v4.9.0
📋 What's Changed
- cockroachdb: fix tests with DELETE and LIMIT by @xiam in https://github.com/upper/db/pull/701
- test suite maintenance by @xiam in https://github.com/upper/db/pull/713
- Full Changelog: https://github.com/upper/db/compare/v4.7.0...v4.8.0
Maintenance release with dependency upgrades.
This release includes memory and speed optimizations.
This release includes memory and speed optimizations.
📦 Upgrading your codebase
- For instance, if your struct looks like this:
- ```go
- type Foo struct {
- ID uint64 `db:"id"`
- Names *[]string `db:"names"`
- }
- ```
- you'll have to convert it into:
- + 60 more
📋 What's Changed
- Replace lib/pq with pgx by @xiam in https://github.com/upper/db/pull/627
- Fix sqlite.New panic by @sdvcrx in https://github.com/upper/db/pull/635
- Fix condition that forced the statement cache to be skipped by @xiam in https://github.com/upper/db/pull/638
✨ New Contributors
- @sdvcrx made their first contribution in https://github.com/upper/db/pull/635
📦 Acknowledgements
- Special thanks to @pkieltyka and [Horizon Blockchain Games](https://horizon.io/) for their continuos support over the years! Thank you very much
- Full Changelog: https://github.com/upper/db/compare/v4.2.1...v4.5.0
Added `db.AnyOf` and `db.NotAnyOf`, which work like `db.In` and `db.NotIn`, except they accept a slice of any type.
The most relevant change for this release is the behaviour of `Save()`: it will attempt to update a record if and only if the record exists, otherwise it will attempt to create a record.
See: [What's new in v4](https://upper.io/blog/2020/08/29/whats-new-on-upper-v4)
📋 Changes
- Fixing some linter warnings
- Minor refactors
📋 Changes
- Updated the source of the QL driver to the new maintained location.
- Refactor test suite.
Fixes problems with MSSQL adapter and LastInsertId.
Fixes #474, an error in `fetchRows()` was ignored
Fixes a problem with `InsertReturning()` and tables with varchar/string primary keys.
minor release, fixes a deadlock
📦 Support for comparison operations
- Starting on 3.5.0 you'll be able to use comparison operators that are compatible across different database engines, see some examples:
- ```go
- // foo = "bar"
- db.Cond{
- "foo": db.Eq("bar")
- }
- // foo <= 15
- db.Cond{
- + 46 more
📦 Thanks
- Thank you for using upper-db!
📦 Allow escaping `?` marks inside queries
- You can now escape `?` marks inside queries by using `??`:
- ```go
- // ...WHERE someColumn ? "Some Value"
- col.Find().Where(`someColumn ?? ?`, "Some Value")
- ```
📦 PostgreSQL: jsonb tag and JSONB values
- Fields tagged with `jsonb` will still emit an error when used, no matter what their type is they all need to satisfy `sql.Scanner` and `driver.Valuer` (or `sqlbuilder.ScannerValuer`).
📦 Structs
- If your struct looks like:
- ```go
- type MyModel struct {
- ...
- MyField CustomStruct `db:"my_field,jsonb"`
- }
- type CustomStruct struct {
- Foo string `db:"foo"`
- + 20 more
📦 Maps
- If your struct looks like:
- ```go
- type MyModel struct {
- ...
- MyField map[string]interface{} `db:"my_field,jsonb"`
- }
- ```
- Change it into:
- + 9 more
📦 Interfaces
- If your struct looks like:
- ```go
- type MyModel struct {
- ...
- MyField interface{} `db:"my_field,jsonb"`
- }
- ```
- Change it into:
- + 10 more
📦 Arrays
- If your struct looks like:
- ```go
- type MyModel struct {
- ...
- MyField CustomStructArray `db:"my_field,jsonb"`
- }
- type CustomStructArray []CustomStruct
- ```
- + 18 more
📦 Other types
- Some types are going to be converted automatically to a proper type:
- | Go type | PostgreSQL type |
- | --- | --- |
- |`[]string`|`TEXT[]`|
- |`[]int64`|`INTEGER[]`|
- |`[]bool`|`BOOLEAN[]`|
- |`[]float64`|`DOUBLE PRECISION[]`|
- |`map[string]interface{}`|`JSONB`|
- + 17 more
📦 Thanks
- Thanks for using upper-db. Feel free to [open a ticket](https://github.com/upper/db/issues) if you need help.
📦 Pagination
- The new pagination API lets you split the results of a query into chunks containing a fixed number of items.
📦 Simple pagination for db.Result
- ```go
- res = sess.Collection("posts").Paginate(20) // 20 results per page
- err = res.All(&posts) // First 20 results of the query
- err = res.Page(2).All(&posts) // Results from page 2 (limit 20, offset 40)
- ```
📦 Simple pagination for SQL builder
- ```go
- q = sess.SelectFrom("posts").Paginate(20)
- err = res.All(&posts) // First 20 results of the query
- err = res.Page(2).All(&posts) // Results from page 2 (limit 20, offset 40)
- ```
📦 Cursor based pagination (both for db.Result and SQL Builder)
- ```go
- res = sess.Collection("posts").
- Paginate(20). // 20 results per page
- Cursor("id") // using id as cursor
- err = res.All(&posts) // First 20 results of the query
- // Get the next 20 results starting from the last item of the previous query.
- res = res.NextPage(posts[len(posts)-1].ID)
- err = res.All(&posts) // Results from page 1, limit 20, offset 20
- + 1 more
📦 Other commonly used pagination tools
- ```go
- res = res.Paginate(23)
- totalNumberOfEntries, err = res.TotalEntries()
- totalNumberOfPages, err = res.TotalPages()
- ```
📦 Support for binary and text mode (PostgreSQL)
- pgbouncer requires binary mode (`binary_parameters="yes"`) to be enabled, but all of the auto-fields that were working with text mode started failing with binary mode.
- Starting with v3.3.0 upper-db supports binary mode. This is how you can enable binary mode in your PostgreSQL session:
- ```go
- settings = postgresql.ConnectionURL {
- ...
- Options: map[string]string{
- "binary_parameters": "yes",
- },
- + 55 more
📋 Changes
- https://github.com/upper/db/issues/383
- https://github.com/upper/db/issues/381
- https://github.com/upper/db/issues/380
📋 Changes
- Multiple Where() calls append conditions instead of overwriting previous ones. See: https://github.com/upper/db/issues/357
- Support for UUID in `InsertReturning` and `UpdateReturning`. See: https://github.com/upper/db/issues/370
- Added `postgresql.JSONB`, `postgresql.StringArray` and `postgresql.Int64Array` custom types for PostgreSQL, which will deprecate optional tags `int64array`, `stringarray` and `jsonb` while providing full support for their Scanners and Valuers.
# Changelog The most important feature in this release is support for SQL Server via https://github.com/denisenkom/go-mssqldb.
