mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-11 21:17:32 +00:00
fix: refactor system api (#3500)
* fix: refactor system api * fix: search domains on get instance * fix: search domains on get instance * fix: return instance detail * fix: implement user sorting column (#3469) * fix: implement user sorting column * fix: implement user sorting column * fix: string column * isOrderByLower Co-authored-by: Livio Amstutz <livio.a@gmail.com> * fix: user converter import * Update instance.go Co-authored-by: Livio Amstutz <livio.a@gmail.com>
This commit is contained in:
@@ -31,18 +31,16 @@ func (req *SearchRequest) toQuery(query sq.SelectBuilder) sq.SelectBuilder {
|
||||
}
|
||||
|
||||
if !req.SortingColumn.isZero() {
|
||||
clause := "LOWER(" + sqlPlaceholder + ")"
|
||||
clause := req.SortingColumn.orderBy()
|
||||
if !req.Asc {
|
||||
clause += " DESC"
|
||||
}
|
||||
query = query.OrderByClause(clause, req.SortingColumn.identifier())
|
||||
query = query.OrderByClause(clause)
|
||||
}
|
||||
|
||||
return query
|
||||
}
|
||||
|
||||
const sqlPlaceholder = "?"
|
||||
|
||||
type SearchQuery interface {
|
||||
toQuery(sq.SelectBuilder) sq.SelectBuilder
|
||||
comp() sq.Sqlizer
|
||||
@@ -367,8 +365,9 @@ func (t table) isZero() bool {
|
||||
}
|
||||
|
||||
type Column struct {
|
||||
name string
|
||||
table table
|
||||
name string
|
||||
table table
|
||||
isOrderByLower bool
|
||||
}
|
||||
|
||||
func (c Column) identifier() string {
|
||||
@@ -381,6 +380,13 @@ func (c Column) identifier() string {
|
||||
return c.name
|
||||
}
|
||||
|
||||
func (c Column) orderBy() string {
|
||||
if !c.isOrderByLower {
|
||||
return c.identifier()
|
||||
}
|
||||
return "LOWER(" + c.identifier() + ")"
|
||||
}
|
||||
|
||||
func (c Column) setTable(t table) Column {
|
||||
c.table = t
|
||||
return c
|
||||
|
Reference in New Issue
Block a user