GoooQo v0.2.3
HomeGitHubDemo
English
English
  • Introduction
  • Quickstart
  • API
    • Connection
    • Transaction
    • CRUD
    • Association Service
  • Entity Mapping
    • Entity Object
    • Related Entities
  • Query Mapping
    • Query Object
      • Predicate-Suffix Field
      • Logic-Suffix Field
      • Subquery Field
      • E-R Query Field
      • Custom Condition Field
    • Page Query
  • Aggregate Query
    • View Object
    • Having
    • Natural Join
    • Outer Join
    • Nested View
  • Advanced
    • Dialect
    • Locking
  • Related Resources
    • Articles
      • From ORM to OQM: An Object-Only SQL Construction Solution
      • Introduction to GoooQo
      • How to express `select * from user where id = ? or name = ? and age = ?` in GoooQo
Powered by GitBook
On this page
  • Mapping
  • Examples
  • Predicate Suffix Table

Was this helpful?

Edit on GitHub
  1. Query Mapping
  2. Query Object

Predicate-Suffix Field

PreviousQuery ObjectNextLogic-Suffix Field

Last updated 8 months ago

Was this helpful?

Mapping

GoooQo uses a predicate suffix mapping method to map fields in query objects to basic query conditions. Each basic query condition consists of a column name, a comparison operator, and a value. The format of the field name in the query object is a column name plus one of the comparison operator alias. All assigned fields in a query instance will be mapped to the corresponding query conditions and spliced ​​into a query clause.

Examples

Here are two examples of the predicate-suffix field mapping:

userQuery := UserQuery{Deleted: P(true)}
users, err := userDataAccess.Query(ctx, userQuery)
// SQL="SELECT id, name, score, memo, deleted FROM t_user WHERE deleted = ?" args="[true]"

userQuery := UserQuery{IdIn: &[]int64{1, 4, 12}, Deleted: P(true)}
users, err := userDataAccess.Query(ctx, userQuery)
// SQL="SELECT id, name, score, memo, deleted FROM t_user WHERE id IN (?, ?, ?) AND deleted = ?" args="[1 4 12 true]"

Check the for all supported suffixes by GoooQo.

Predicate Suffix Table

Suffix
Field Name
Value
SQL Condition

(EMPTY)

id

5

id = 5

Eq

idEq

5

id = 5

Not

idNot

5

id != 5

Ne

idNe

5

id <> 5

Gt

idGt

5

id > 5

Ge

idGe

5

id >= 5

Lt

idLt

5

id < 5

Le

idLe

5

id <= 5

NotIn

idNotIn

[1,2,3]

id NOT IN (1,2,3)

In

idIn

[1,2,3]

id IN (1,2,3)

Null

memoNull

false

memo IS NOT NULL

Null

memoNull

true

memo IS NULL

NotLike

nameNotLike

"arg"

name NOT LIKE '%arg%'

Like

nameLike

"arg"

name LIKE '%arg%'

NotStart

nameNotStart

"arg"

name NOT LIKE 'arg%'

Start

nameStart

"arg"

name LIKE 'arg%'

NotEnd

nameNotEnd

"arg"

name NOT LIKE '%arg'

End

nameEnd

"arg"

name LIKE '%arg'

NotContain

nameNotContain

"arg"

name NOT LIKE '%arg%’

Contain

nameContain

"arg"

name LIKE '%arg%’

Rx

nameRx

"arg\d"

name REGEXP 'arg\d’

predicate suffix table