MySQL linter errors.
This commit is contained in:
parent
5e76355275
commit
46a3dc7dfb
31 changed files with 254 additions and 136 deletions
|
|
@ -150,7 +150,7 @@ func (o *ClauseOffset) Serialize(statementType StatementType, out *SqlBuilder) {
|
|||
}
|
||||
|
||||
type ClauseFor struct {
|
||||
Lock SelectLock
|
||||
Lock RowLock
|
||||
}
|
||||
|
||||
func (f *ClauseFor) Serialize(statementType StatementType, out *SqlBuilder) {
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
package jet
|
||||
|
||||
// Column is common column interface for all types of columns.
|
||||
type Column interface {
|
||||
Name() string
|
||||
TableName() string
|
||||
|
|
@ -11,7 +12,6 @@ type Column interface {
|
|||
defaultAlias() string
|
||||
}
|
||||
|
||||
// Column is common column interface for all types of columns.
|
||||
type ColumnExpression interface {
|
||||
Column
|
||||
Expression
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package jet
|
||||
|
||||
// Projection is interface for all projection types. Types that can be part of, for instance SELECT clause.
|
||||
type Projection interface {
|
||||
serializeForProjection(statement StatementType, out *SqlBuilder)
|
||||
fromImpl(subQuery SelectTable) Projection
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
package jet
|
||||
|
||||
// SelectLock is interface for SELECT statement locks
|
||||
type SelectLock interface {
|
||||
// RowLock is interface for SELECT statement row lock types
|
||||
type RowLock interface {
|
||||
Serializer
|
||||
|
||||
NOWAIT() SelectLock
|
||||
SKIP_LOCKED() SelectLock
|
||||
NOWAIT() RowLock
|
||||
SKIP_LOCKED() RowLock
|
||||
}
|
||||
|
||||
type selectLockImpl struct {
|
||||
|
|
@ -13,22 +13,22 @@ type selectLockImpl struct {
|
|||
noWait, skipLocked bool
|
||||
}
|
||||
|
||||
func NewSelectLock(name string) func() SelectLock {
|
||||
return func() SelectLock {
|
||||
func NewSelectLock(name string) func() RowLock {
|
||||
return func() RowLock {
|
||||
return newSelectLock(name)
|
||||
}
|
||||
}
|
||||
|
||||
func newSelectLock(lockStrength string) SelectLock {
|
||||
func newSelectLock(lockStrength string) RowLock {
|
||||
return &selectLockImpl{lockStrength: lockStrength}
|
||||
}
|
||||
|
||||
func (s *selectLockImpl) NOWAIT() SelectLock {
|
||||
func (s *selectLockImpl) NOWAIT() RowLock {
|
||||
s.noWait = true
|
||||
return s
|
||||
}
|
||||
|
||||
func (s *selectLockImpl) SKIP_LOCKED() SelectLock {
|
||||
func (s *selectLockImpl) SKIP_LOCKED() RowLock {
|
||||
s.skipLocked = true
|
||||
return s
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,10 +6,10 @@ import (
|
|||
|
||||
type SerializerTable interface {
|
||||
Serializer
|
||||
TableInterface
|
||||
Table
|
||||
}
|
||||
|
||||
type TableInterface interface {
|
||||
type Table interface {
|
||||
columns() []Column
|
||||
SchemaName() string
|
||||
TableName() string
|
||||
|
|
@ -111,7 +111,7 @@ func NewJoinTableImpl(lhs Serializer, rhs Serializer, joinType JoinType, onCondi
|
|||
}
|
||||
|
||||
func (t *JoinTableImpl) SchemaName() string {
|
||||
if table, ok := t.lhs.(TableInterface); ok {
|
||||
if table, ok := t.lhs.(Table); ok {
|
||||
return table.SchemaName()
|
||||
}
|
||||
return ""
|
||||
|
|
@ -124,10 +124,10 @@ func (t *JoinTableImpl) TableName() string {
|
|||
func (t *JoinTableImpl) Columns() []Column {
|
||||
var ret []Column
|
||||
|
||||
if lhsTable, ok := t.lhs.(TableInterface); ok {
|
||||
if lhsTable, ok := t.lhs.(Table); ok {
|
||||
ret = append(ret, lhsTable.columns()...)
|
||||
}
|
||||
if rhsTable, ok := t.rhs.(TableInterface); ok {
|
||||
if rhsTable, ok := t.rhs.(Table); ok {
|
||||
ret = append(ret, rhsTable.columns()...)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -80,6 +80,7 @@ func CleanUpGeneratedFiles(dir string) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// DBClose closes non nil db connection
|
||||
func DBClose(db *sql.DB) {
|
||||
if db == nil {
|
||||
return
|
||||
|
|
@ -141,31 +142,35 @@ func FormatTimestamp(t time.Time) []byte {
|
|||
return b
|
||||
}
|
||||
|
||||
// IsNill check if v is nil
|
||||
func IsNil(v interface{}) bool {
|
||||
return v == nil || (reflect.ValueOf(v).Kind() == reflect.Ptr && reflect.ValueOf(v).IsNil())
|
||||
}
|
||||
|
||||
// MustBe panics with errorStr error, if v interface is not of reflect kind
|
||||
func MustBe(v interface{}, kind reflect.Kind, errorStr string) {
|
||||
if reflect.TypeOf(v).Kind() != kind {
|
||||
panic(errorStr)
|
||||
}
|
||||
}
|
||||
|
||||
// ValueMustBe panics with errorStr error, if v value is not of reflect kind
|
||||
func ValueMustBe(v reflect.Value, kind reflect.Kind, errorStr string) {
|
||||
if v.Kind() != kind {
|
||||
panic(errorStr)
|
||||
}
|
||||
}
|
||||
|
||||
// TypeMustBe panics with errorStr error, if v type is not of reflect kind
|
||||
func TypeMustBe(v reflect.Type, kind reflect.Kind, errorStr string) {
|
||||
if v.Kind() != kind {
|
||||
panic(errorStr)
|
||||
}
|
||||
}
|
||||
|
||||
// MustBeInitializedPtr panics with errorStr if val interface is nil
|
||||
func MustBeInitializedPtr(val interface{}, errorStr string) {
|
||||
if IsNil(val) {
|
||||
panic(errorStr)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue