[ANN] mgo r2011.12.18

25 views
Skip to first unread message

Gustavo Niemeyer

unread,
Dec 18, 2011, 1:11:56 PM12/18/11
to golang-nuts, mongod...@googlegroups.com, mgo-...@googlegroups.com
A maintenance release of the mgo MongoDB driver for Go has just been
pushed and tagged. This release is compatible with the Go r60 release
series, but it will be made available for the current weekly release as well
in a moment.

Project details are available at: http://labix.org/mgo

The following changes were made in this release:

- The Query.Count method will now take Limit and Skip usage in consideration,
This was the original intention for the method according to its documentation.
Thanks to Paddy Foran for pointing out the misbehavior.

http://goneat.org/lp/mgo/#Query.Count

- Structures and maps are now zeroed out during unmarshalling. This was
done after much consideration, and the idea was revived after a recent
conversation in the list with Mathieu Lonjaret (thanks!).

Even if a very small penalty is paid in some cases, this behavior is
significantly less error prone in general, and enables loops to be
built correctly in the simpler form:

var v MyType
for iter.Next(&v) {
...
}

Previously, due to the lack of zeroing and the schema-less nature of
the database, such a nice loop might incorrectly allow fields from a
previous iteration of the loop to remain set on follow up iterations,
creating strange and hard-to-debug behavior.

This also affects less obvious cases such as Query.All, which may
actually be considered a bug fix in the implementation given the
unpredictable behavior when reusing slice capacity.

--
Gustavo Niemeyer
http://niemeyer.net
http://niemeyer.net/plus
http://niemeyer.net/twitter
http://niemeyer.net/blog

-- I'm not absolutely sure of anything.

Gustavo Niemeyer

unread,
Dec 18, 2011, 2:35:14 PM12/18/11
to golang-nuts, mongod...@googlegroups.com, mgo-...@googlegroups.com
> A maintenance release of the mgo MongoDB driver for Go has just been
> pushed and tagged. This release is compatible with the Go r60 release
> series, but it will be made available for the current weekly release as well
> in a moment.
>
> Project details are available at: http://labix.org/mgo

And this is now available for the current weekly release (2011-12-14) as well.
The interface between the stable and the weekly release is exactly the same,
except for the changes relative to changes in the language itself. This makes
this release a good one to port code forward, if desired. Soon, a new release
will be made exploring the language features introduced recently.

That said, there is one exception to that. The following fix that explores
features from weekly was already made:

- The new Bytes and SetBytes methods in reflect.Value allow efficiently
marshaling and unmarshaling named types based on []byte as BSON
binary values. Thanks to Brandon Peters for requesting it.

That's another fantastic side-effect of the port to the weekly series. Given the
improvements in the reflect package, allowed by the recent language changes,
there's a very noticeable speed difference when marshaling and unmarshaling
values.

Gustavo Niemeyer

unread,
Dec 18, 2011, 4:48:36 PM12/18/11
to golang-nuts, mongod...@googlegroups.com, mgo-...@googlegroups.com
> And this is now available for the current weekly release (2011-12-14) as well.
> The interface between the stable and the weekly release is exactly the same,

Sorry, this is poorly worded. What I meant is that the interfaces for both the
weekly and the stable releases are the same except for the required language
changes.

Reply all
Reply to author
Forward
0 new messages