d28f005552
Fix limit for databases other than sqlite go mod tidy && go mod vendor Remove unneeded break statements Make everything work with the new xorm version Fix xorm logging Fix lint Fix redis init Fix using id field Fix database init for testing Change default database log level Add xorm logger Use const for postgres go mod tidy Merge branch 'master' into update/xorm # Conflicts: # go.mod # go.sum # vendor/modules.txt go mod vendor Fix loading fixtures for postgres Go mod vendor1 Update xorm to version 1 Co-authored-by: kolaente <k@knt.li> Reviewed-on: https://kolaente.dev/vikunja/api/pulls/323
51 lines
1.1 KiB
Go
51 lines
1.1 KiB
Go
// Copyright (c) 2012, Suryandaru Triandana <syndtr@gmail.com>
|
|
// All rights reserved.
|
|
//
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
package comparer
|
|
|
|
import "bytes"
|
|
|
|
type bytesComparer struct{}
|
|
|
|
func (bytesComparer) Compare(a, b []byte) int {
|
|
return bytes.Compare(a, b)
|
|
}
|
|
|
|
func (bytesComparer) Name() string {
|
|
return "leveldb.BytewiseComparator"
|
|
}
|
|
|
|
func (bytesComparer) Separator(dst, a, b []byte) []byte {
|
|
i, n := 0, len(a)
|
|
if n > len(b) {
|
|
n = len(b)
|
|
}
|
|
for ; i < n && a[i] == b[i]; i++ {
|
|
}
|
|
if i >= n {
|
|
// Do not shorten if one string is a prefix of the other
|
|
} else if c := a[i]; c < 0xff && c+1 < b[i] {
|
|
dst = append(dst, a[:i+1]...)
|
|
dst[len(dst)-1]++
|
|
return dst
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (bytesComparer) Successor(dst, b []byte) []byte {
|
|
for i, c := range b {
|
|
if c != 0xff {
|
|
dst = append(dst, b[:i+1]...)
|
|
dst[len(dst)-1]++
|
|
return dst
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// DefaultComparer are default implementation of the Comparer interface.
|
|
// It uses the natural ordering, consistent with bytes.Compare.
|
|
var DefaultComparer = bytesComparer{}
|