[fix] always use sorted map
Signed-off-by: Anton Nesterov <anton@demiurg.io>
This commit is contained in:
parent
d644ef077e
commit
fb13fcbece
|
@ -15,8 +15,10 @@ func covert_find(ctx Context, find Find, join string) string {
|
|||
if join == "" {
|
||||
join = " AND "
|
||||
}
|
||||
keys := AggregateSortedKeys([]Map{find})
|
||||
expressions := []string{}
|
||||
for key, value := range find {
|
||||
for _, key := range keys {
|
||||
value := find[key]
|
||||
if strings.Contains(key, "$and") {
|
||||
v := covert_find(ctx, value.(Find), "")
|
||||
expressions = append(expressions, fmt.Sprintf("(%s)", v))
|
||||
|
|
|
@ -11,7 +11,7 @@ type InsertData struct {
|
|||
}
|
||||
|
||||
func ConvertInsert(ctx Context, inserts []Map) (InsertData, error) {
|
||||
keys := AggregateKeys(inserts)
|
||||
keys := AggregateSortedKeys(inserts)
|
||||
placeholder := make([]string, 0)
|
||||
for range keys {
|
||||
placeholder = append(placeholder, "?")
|
||||
|
|
|
@ -2,7 +2,7 @@ package builder
|
|||
|
||||
import "sort"
|
||||
|
||||
func AggregateKeys(maps []Map) []string {
|
||||
func AggregateSortedKeys(maps []Map) []string {
|
||||
set := make(map[string]int)
|
||||
keys := make([]string, 0)
|
||||
for _, item := range maps {
|
||||
|
|
Loading…
Reference in a new issue