Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update clause.go #6725

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 16 additions & 13 deletions clause/clause.go
Original file line number Diff line number Diff line change
@@ -1,39 +1,40 @@
package clause

// Interface clause interface
// Interface is a clause interface.
type Interface interface {
Name() string
Build(Builder)
MergeClause(*Clause)
}

// ClauseBuilder clause builder, allows to customize how to build clause
// ClauseBuilder is a clause builder that allows customization of how to build a clause.
type ClauseBuilder func(Clause, Builder)

// Writer is an interface for writing operations.
type Writer interface {
WriteByte(byte) error
WriteString(string) (int, error)
}

// Builder builder interface
// Builder is a builder interface.
type Builder interface {
Writer
WriteQuoted(field interface{})
AddVar(Writer, ...interface{})
AddError(error) error
}

// Clause
// Clause represents a query clause.
type Clause struct {
Name string // WHERE
Name string
BeforeExpression Expression
AfterNameExpression Expression
AfterExpression Expression
Expression Expression
Builder ClauseBuilder
}

// Build build clause
// Build builds the clause.
func (c Clause) Build(builder Builder) {
if c.Builder != nil {
c.Builder(c, builder)
Expand Down Expand Up @@ -62,26 +63,28 @@
}
}

// Constants for special names.
const (
PrimaryKey string = "~~~py~~~" // primary key
CurrentTable string = "~~~ct~~~" // current table
Associations string = "~~~as~~~" // associations
PrimaryKey = "~~~py~~~" // Primary key
CurrentTable = "~~~ct~~~" // Current table
Associations = "~~~as~~~" // Associations
)

// Predefined instances.
var (
currentTable = Table{Name: CurrentTable}
PrimaryColumn = Column{Table: CurrentTable, Name: PrimaryKey}
CurrentTableInstance = Table{Name: CurrentTable}
PrimaryColumn = Column{Table: CurrentTable, Name: PrimaryKey}

Check failure on line 76 in clause/clause.go

View workflow job for this annotation

GitHub Actions / runner / golangci-lint

[gofumpt] reported by reviewdog 🐶 Raw Output: clause/clause.go:76:- PrimaryColumn = Column{Table: CurrentTable, Name: PrimaryKey} clause/clause.go:76:+ PrimaryColumn = Column{Table: CurrentTable, Name: PrimaryKey}
)

// Column quote with name
// Column represents a column with optional table and alias.
type Column struct {
Table string
Name string
Alias string
Raw bool
}

// Table quote with name
// Table represents a table with optional alias.
type Table struct {
Name string
Alias string
Expand Down
Loading