~ubuntu-branches/ubuntu/saucy/juju-core/saucy-proposed

« back to all changes in this revision

Viewing changes to src/labix.org/v2/mgo/session.go

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2013-07-11 17:18:27 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20130711171827-vjqkg40r0dlf7ys2
Tags: 1.11.2-0ubuntu1
* New upstream release.
* Make juju-core the default juju (LP: #1190634):
  - d/control: Add virtual package juju -> juju-core.
  - d/juju-core.postinst.in: Bump priority of alternatives over that of
    python juju packages.
* Enable for all architectures (LP: #1172505):
  - d/control: Version BD on golang-go to >= 2:1.1.1 to ensure CGO
    support for non-x86 archs, make juju-core Arch: any.
  - d/README.source: Dropped - no longer required.
* d/watch: Updated for new upstream tarball naming.

Show diffs side-by-side

added added

removed removed

Lines of Context:
700
700
                                if c := strings.Index(field, ":"); c > 1 && c < len(field)-1 {
701
701
                                        kind = field[1:c]
702
702
                                        field = field[c+1:]
 
703
                                        name += field + "_" + kind
703
704
                                }
704
705
                        }
705
706
                        switch field[0] {
709
710
                        case '@':
710
711
                                order = "2d"
711
712
                                field = field[1:]
712
 
                                name += field + "_" // Why don't they put 2d here?
 
713
                                // The shell used to render this field as key_ instead of key_2d,
 
714
                                // and mgo followed suit. This has been fixed in recent server
 
715
                                // releases, and mgo followed as well.
 
716
                                name += field + "_2d"
713
717
                        case '-':
714
718
                                order = -1
715
719
                                field = field[1:]
723
727
                                        name += field + "_1"
724
728
                                } else {
725
729
                                        order = kind
726
 
                                        name += field + "_" // Seems wrong. What about the kind?
727
730
                                }
728
731
                        }
729
732
                }
943
946
func simpleIndexKey(realKey bson.D) (key []string) {
944
947
        for i := range realKey {
945
948
                field := realKey[i].Name
946
 
                i, _ := realKey[i].Value.(int)
947
 
                if i == 1 {
 
949
                vi, ok := realKey[i].Value.(int)
 
950
                if !ok {
 
951
                        vf, _ := realKey[i].Value.(float64)
 
952
                        vi = int(vf)
 
953
                }
 
954
                if vi == 1 {
948
955
                        key = append(key, field)
949
956
                        continue
950
957
                }
951
 
                if i == -1 {
 
958
                if vi == -1 {
952
959
                        key = append(key, "-"+field)
953
960
                        continue
954
961
                }
955
 
                if s, ok := realKey[i].Value.(string); ok {
956
 
                        key = append(key, "$"+s+":"+field)
 
962
                if vs, ok := realKey[i].Value.(string); ok {
 
963
                        key = append(key, "$"+vs+":"+field)
957
964
                        continue
958
965
                }
959
966
                panic("Got unknown index key type for field " + field)
3166
3173
// will also be returned as err.
3167
3174
func (c *Collection) writeQuery(op interface{}) (lerr *LastError, err error) {
3168
3175
        s := c.Database.Session
3169
 
        socket, err := s.acquireSocket(false)
 
3176
        dbname := c.Database.Name
 
3177
        socket, err := s.acquireSocket(dbname == "local")
3170
3178
        if err != nil {
3171
3179
                return nil, err
3172
3180
        }
3184
3192
                var replyErr error
3185
3193
                mutex.Lock()
3186
3194
                query := *safeOp // Copy the data.
3187
 
                query.collection = c.Database.Name + ".$cmd"
 
3195
                query.collection = dbname + ".$cmd"
3188
3196
                query.replyFunc = func(err error, reply *replyOp, docNum int, docData []byte) {
3189
3197
                        replyData = docData
3190
3198
                        replyErr = err