mirror of
https://github.com/muety/wakapi.git
synced 2023-08-10 21:12:56 +03:00
feat: leaderboard generation and querying
This commit is contained in:
@ -1,8 +1,10 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/emvi/logbuch"
|
||||
"gorm.io/gorm"
|
||||
"reflect"
|
||||
)
|
||||
|
||||
func IsCleanDB(db *gorm.DB) bool {
|
||||
@ -30,3 +32,10 @@ func HasConstraints(db *gorm.DB) bool {
|
||||
logbuch.Warn("HasForeignKeyConstraints is not yet implemented for dialect '%s'", db.Dialector.Name())
|
||||
return false
|
||||
}
|
||||
|
||||
func WhereNullable(query *gorm.DB, col string, val any) *gorm.DB {
|
||||
if val == nil || reflect.ValueOf(val).IsNil() {
|
||||
return query.Where(fmt.Sprintf("%s is null", col))
|
||||
}
|
||||
return query.Where(fmt.Sprintf("%s = ?", col), val)
|
||||
}
|
||||
|
Reference in New Issue
Block a user