Skip to content

Commit a8a27b4

Browse files
committed
fix count and removed debug printing
1 parent 942d82d commit a8a27b4

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

ormlite.go

+14-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"context"
55
"database/sql"
66
"fmt"
7-
"github.com/davecgh/go-spew/spew"
87
"reflect"
98
"strings"
109
"time"
@@ -268,7 +267,6 @@ func queryWithOptions(ctx context.Context, db *sql.DB, table string, columns []s
268267
keys = append(keys, fmt.Sprintf("%s like ?", k))
269268
values = append(values, fmt.Sprintf("%%%s%%", v))
270269
default:
271-
spew.Dump(v)
272270
switch v.(type) {
273271
case Greater:
274272
keys = append(keys, fmt.Sprintf("%s > ?", k))
@@ -287,7 +285,6 @@ func queryWithOptions(ctx context.Context, db *sql.DB, table string, columns []s
287285
}
288286
} else {
289287
keys = append(keys, fmt.Sprintf("%s is null", k))
290-
//values = append(values, v)
291288
}
292289
}
293290
if len(keys) > 0 {
@@ -1024,7 +1021,20 @@ func Count(db *sql.DB, m Model, opts *Options) (count int64, err error) {
10241021
query.WriteString(f + " like ?" + divider)
10251022
args = append(args, fmt.Sprintf("%%%s%%", v))
10261023
default:
1027-
query.WriteString(f + " = ?" + divider)
1024+
switch v.(type) {
1025+
case Greater:
1026+
query.WriteString(f + " > ?" + divider)
1027+
case GreaterOrEqual:
1028+
query.WriteString(f + " >= ?" + divider)
1029+
case Less:
1030+
query.WriteString(f + " < ?" + divider)
1031+
case LessOrEqual:
1032+
query.WriteString(f + " <= ?" + divider)
1033+
case NotEqual:
1034+
query.WriteString(f + " != ?" + divider)
1035+
default:
1036+
query.WriteString(f + " = ?" + divider)
1037+
}
10281038
args = append(args, v)
10291039
}
10301040
} else {

0 commit comments

Comments
 (0)