1
0
mirror of https://github.com/astaxie/beego.git synced 2024-11-22 02:00:55 +00:00

Merge pull request #4230 from jianzhiyao/frt/movement_for_4198

movement for 4198
This commit is contained in:
Ming Deng 2020-09-19 23:24:57 +08:00 committed by GitHub
commit a31dce6216
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 8 deletions

View File

@ -38,10 +38,11 @@ var (
var ( var (
operators = map[string]bool{ operators = map[string]bool{
"exact": true, "exact": true,
"iexact": true, "iexact": true,
"contains": true, "strictexact": true,
"icontains": true, "contains": true,
"icontains": true,
// "regex": true, // "regex": true,
// "iregex": true, // "iregex": true,
"gt": true, "gt": true,

View File

@ -22,10 +22,11 @@ import (
// mysql operators. // mysql operators.
var mysqlOperators = map[string]string{ var mysqlOperators = map[string]string{
"exact": "= ?", "exact": "= ?",
"iexact": "LIKE ?", "iexact": "LIKE ?",
"contains": "LIKE BINARY ?", "strictexact": "= BINARY ?",
"icontains": "LIKE ?", "contains": "LIKE BINARY ?",
"icontains": "LIKE ?",
// "regex": "REGEXP BINARY ?", // "regex": "REGEXP BINARY ?",
// "iregex": "REGEXP ?", // "iregex": "REGEXP ?",
"gt": "> ?", "gt": "> ?",

View File

@ -877,6 +877,17 @@ func TestOperators(t *testing.T) {
throwFail(t, err) throwFail(t, err)
throwFail(t, AssertIs(num, 1)) throwFail(t, AssertIs(num, 1))
if IsMysql {
// Now only mysql support `strictexact`
num, err = qs.Filter("user_name__strictexact", "Slene").Count()
throwFail(t, err)
throwFail(t, AssertIs(num, 0))
num, err = qs.Filter("user_name__strictexact", "slene").Count()
throwFail(t, err)
throwFail(t, AssertIs(num, 1))
}
num, err = qs.Filter("user_name__contains", "e").Count() num, err = qs.Filter("user_name__contains", "e").Count()
throwFail(t, err) throwFail(t, err)
throwFail(t, AssertIs(num, 2)) throwFail(t, AssertIs(num, 2))