Source File
select.go
Belonging Package
gorm.io/gorm/clause
package clause
// Select select attrs when querying, updating, creating
type Select struct {
Distinct bool
Columns []Column
Expression Expression
}
func ( Select) () string {
return "SELECT"
}
func ( Select) ( Builder) {
if len(.Columns) > 0 {
if .Distinct {
.WriteString("DISTINCT ")
}
for , := range .Columns {
if > 0 {
.WriteByte(',')
}
.WriteQuoted()
}
} else {
.WriteByte('*')
}
}
func ( Select) ( *Clause) {
if .Expression != nil {
if .Distinct {
if , := .Expression.(Expr); {
.SQL = "DISTINCT " + .SQL
.Expression =
return
}
}
.Expression = .Expression
} else {
.Expression =
}
}
// CommaExpression represents a group of expressions separated by commas.
type CommaExpression struct {
Exprs []Expression
}
func ( CommaExpression) ( Builder) {
for , := range .Exprs {
if > 0 {
_, _ = .WriteString(", ")
}
.Build()
}
}
![]() |
The pages are generated with Golds v0.6.7. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |