From 22b8cae73be75d009151222bc2788139374074d9 Mon Sep 17 00:00:00 2001 From: wangle <285273592@qq.com> Date: Wed, 29 Jul 2020 23:23:02 +0800 Subject: [PATCH] Add the operator(>,>=,<,<=,=,!=) of orm eg: qs.Filter("counts__>=","20") qs.Filter("counts__!=","20") --- orm/db.go | 6 ++++++ orm/db_mysql.go | 6 ++++++ orm/db_oracle.go | 5 +++++ orm/db_postgres.go | 6 ++++++ orm/db_sqlite.go | 6 ++++++ 5 files changed, 29 insertions(+) diff --git a/orm/db.go b/orm/db.go index 9a1827e8..5d175bf1 100644 --- a/orm/db.go +++ b/orm/db.go @@ -49,6 +49,12 @@ var ( "eq": true, "nq": true, "ne": true, + ">": true, + ">=": true, + "<": true, + "<=": true, + "=": true, + "!=": true, "startswith": true, "endswith": true, "istartswith": true, diff --git a/orm/db_mysql.go b/orm/db_mysql.go index 6e99058e..36f6f566 100644 --- a/orm/db_mysql.go +++ b/orm/db_mysql.go @@ -29,11 +29,17 @@ var mysqlOperators = map[string]string{ // "regex": "REGEXP BINARY ?", // "iregex": "REGEXP ?", "gt": "> ?", + ">": "> ?", "gte": ">= ?", + ">=": ">= ?", "lt": "< ?", + "<": "< ?", "lte": "<= ?", + "<=": "<= ?", "eq": "= ?", + "=": "= ?", "ne": "!= ?", + "!=": "!= ?", "startswith": "LIKE BINARY ?", "endswith": "LIKE BINARY ?", "istartswith": "LIKE ?", diff --git a/orm/db_oracle.go b/orm/db_oracle.go index 5d121f83..ed2ec74c 100644 --- a/orm/db_oracle.go +++ b/orm/db_oracle.go @@ -22,10 +22,15 @@ import ( // oracle operators. var oracleOperators = map[string]string{ "exact": "= ?", + "=": "= ?", "gt": "> ?", + ">": "> ?", "gte": ">= ?", + ">=": ">= ?", "lt": "< ?", + "<": "< ?", "lte": "<= ?", + "<=": "<= ?", "//iendswith": "LIKE ?", } diff --git a/orm/db_postgres.go b/orm/db_postgres.go index c488fb38..7eb88d7a 100644 --- a/orm/db_postgres.go +++ b/orm/db_postgres.go @@ -26,11 +26,17 @@ var postgresOperators = map[string]string{ "contains": "LIKE ?", "icontains": "LIKE UPPER(?)", "gt": "> ?", + ">": "> ?", "gte": ">= ?", + ">=": ">= ?", "lt": "< ?", + "<": "< ?", "lte": "<= ?", + "<=": "<= ?", "eq": "= ?", + "=": "= ?", "ne": "!= ?", + "!=": "!= ?", "startswith": "LIKE ?", "endswith": "LIKE ?", "istartswith": "LIKE UPPER(?)", diff --git a/orm/db_sqlite.go b/orm/db_sqlite.go index 1d62ee34..bd9f5d3b 100644 --- a/orm/db_sqlite.go +++ b/orm/db_sqlite.go @@ -28,11 +28,17 @@ var sqliteOperators = map[string]string{ "contains": "LIKE ? ESCAPE '\\'", "icontains": "LIKE ? ESCAPE '\\'", "gt": "> ?", + ">": "> ?", "gte": ">= ?", + ">=": ">= ?", "lt": "< ?", + "<": "< ?", "lte": "<= ?", + "<=": "<= ?", "eq": "= ?", + "=": "= ?", "ne": "!= ?", + "!=": "!= ?", "startswith": "LIKE ? ESCAPE '\\'", "endswith": "LIKE ? ESCAPE '\\'", "istartswith": "LIKE ? ESCAPE '\\'",