From 6e39d2f5b45360c0e4e5b011434f505aa9894160 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Carlos=20Nieto?= <jose.carlos@menteslibres.net> Date: Fri, 16 Dec 2016 00:39:49 +0000 Subject: [PATCH] Add a note on query builder behaviour change --- README.md | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/README.md b/README.md index 3214b084..deeda9f1 100644 --- a/README.md +++ b/README.md @@ -86,6 +86,39 @@ go run _examples/booktown-books/main.go 2016/08/10 08:42:48 "Practical PostgreSQL" (ID: 41472) ``` +## Changeog + +Dec 15th, 2016: Before `2.0.0-rc8`, upper-db produced queries that mutated +themselves: + +``` +q := sess.SelectFrom("users") + +q.Where(...) // This method modified q's internal state. +``` + +Starting on `2.0.0-rc8` this is no longer valid, if you want to use values to +represent queries you'll have to reassign them, like this: + +``` +q := sess.SelectFrom("users") + +q = q.Where(...) + +q.And(...) // Nothing happens, the Where() method does not affect q. +``` + +This applies to all query builder methods, `db.Result`, `db.And` and `db.Or`. + +If you want to check your code for statatements that might rely on the old +behaviour and could cause you trouble use `dbcheck`: + +``` +go get -u github.com/upper/cmd/dbcheck + +dbcheck github.com/my/package/... +``` + ## License This project is licensed under the terms of the **MIT License**. -- GitLab