Skip to content

Commit

Permalink
Merge Development (#57)
Browse files Browse the repository at this point in the history
* add DropAllIndexes() method (#25)

Create a new method to drop all the indexes of a collection
in a single call

* readme: credit @feliixx for #25 (#26)

* send metadata during handshake (#28)

fix [#484](https://github.com/go-mgo/mgo/issues/484)

Annotate connections with metadata provided by the
connecting client.

informations send:

{
 "aplication": {         // optional
   "name": "myAppName"
 }
 "driver": {
    "name": "mgo",
    "version": "v2"
  },
  "os": {
    "type": runtime.GOOS,
    "architecture": runtime.GOARCH
  }
}

to set "application.name", add `appname` param in options
of string connection URI,
for example : "mongodb://localhost:27017?appname=myAppName"

* Update README to add appName (#32)

* docs: elaborate on what appName does

* readme: add appName to changes

* add method CreateView() (#33)

Fix #30.

Thanks to @feliixx for the time and effort.

* readme: credit @feliixx in the README (#36)

* Don't panic on indexed int64 fields (#23)

* Stop all db instances after tests (go-mgo#462)

If all tests pass, the builds for mongo earlier than 2.6 are still failing.
Running a clean up fixes the issue.

* fixing int64 type failing when getting indexes and trying to type them

* requested changes relating to case statement and panic

* Update README.md to credit @mapete94.

* tests: ensure indexed int64 fields do not cause a panic in Indexes()

See:
* #23
* https://github.com/go-mgo/mgo/issues/475
* go-mgo#476

* Add collation option to collection.Create() (#37)

- Allow specifying the default collation for the collection when creating it.
- Add some documentation to query.Collation() method.

fix #29

* Test against MongoDB 3.4.x (#35)

* test against MongoDB 3.4.x

* tests: use listIndexes to assert index state for 3.4+

* make test pass against v3.4.x

  - skip `TestViewWithCollation` because of SERVER-31049,
    cf: https://jira.mongodb.org/browse/SERVER-31049

  - add versionAtLeast() method in init.js script to better
    detect server version

fixes #31

* Introduce constants for BSON element types (#41)

* bson.Unmarshal returns time in UTC (#42)

* readme: add missing features / credit

* Adds missing collation feature description (by @feliixx).
* Adds missing 3.4 tests description (by @feliixx).
* Adds BSON constants description (by @bozaro).
* Adds UTC time.Time unmarshalling (by @gazoon).

* fix golint, go vet and gofmt warnings (#44)

Fixes #43

* readme: credit @feliixx (#46)

* Fix GetBSON() method usage (#40)

* Fix GetBSON() method usage

Original issue
---

You can't use type with custom GetBSON() method mixed with structure field type and structure field reference type.

For example, you can't create custom GetBSON() for Bar type:

```
struct Foo {
	a  Bar
	b *Bar
}
```

Type implementation (`func (t Bar) GetBSON()` ) would crash on `Foo.b = nil` value encoding.

Reference implementation (`func (t *Bar) GetBSON()` ) would not call on `Foo.a` value encoding.

After this change
---

For type implementation  `func (t Bar) GetBSON()` would not call on `Foo.b = nil` value encoding.
In this case `nil` value would be seariazied as `nil` BSON value.

For reference implementation `func (t *Bar) GetBSON()` would call even on `Foo.a` value encoding.

* Minor refactoring

* readme: credit @bozaro (#47)

* Improve cursorData struct unmarshaling speed (#49)

This change remove full BSON decoding on:

 - parsing to `bson.Raw` and `bson.DocElem` fields;
 - skipping unused BSON fields.

* readme: credit @bozaro and @idy (#53)

* readme: credit @bozaro and @idy

* readme: add @idy to contributor list

* do not lock while writing to a socket (#52) (#54)

fix #51
  • Loading branch information
domodwyer authored Nov 6, 2017
1 parent 8d9e210 commit 5be15cc
Show file tree
Hide file tree
Showing 5 changed files with 297 additions and 200 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ Further PR's (with tests) are welcome, but please maintain backwards compatibili
* Consistently unmarshal time.Time values as UTC ([details](https://github.com/globalsign/mgo/pull/42))
* Enforces best practise coding guidelines ([details](https://github.com/globalsign/mgo/pull/44))
* GetBSON correctly handles structs with both fields and pointers ([details](https://github.com/globalsign/mgo/pull/40))
* Improved bson.Raw unmarshalling performance ([details](https://github.com/globalsign/mgo/pull/49))
* Minimise socket connection timeouts due to excessive locking ([details](https://github.com/globalsign/mgo/pull/52))

---

Expand All @@ -42,6 +44,7 @@ Further PR's (with tests) are welcome, but please maintain backwards compatibili
* @eaglerayp
* @feliixx
* @fmpwizard
* @idy
* @jameinel
* @gazoon
* @mapete94
Expand Down
13 changes: 13 additions & 0 deletions bson/bson_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,19 @@ func testUnmarshal(c *C, data string, obj interface{}) {
err := bson.Unmarshal([]byte(data), zero)
c.Assert(err, IsNil)
c.Assert(zero, DeepEquals, obj)

testUnmarshalRawElements(c, []byte(data))
}

func testUnmarshalRawElements(c *C, data []byte) {
elems := []bson.RawDocElem{}
err := bson.Unmarshal(data, &elems)
c.Assert(err, IsNil)
for _, elem := range elems {
if elem.Value.Kind == bson.ElementDocument || elem.Value.Kind == bson.ElementArray {
testUnmarshalRawElements(c, elem.Value.Data)
}
}
}

type testItemType struct {
Expand Down
Loading

0 comments on commit 5be15cc

Please sign in to comment.