Break utils package into subpackages.
This commit is contained in:
parent
06ecd73f67
commit
d7a5adb239
25 changed files with 276 additions and 318 deletions
|
|
@ -1,8 +1,6 @@
|
|||
package jet
|
||||
|
||||
import (
|
||||
"github.com/go-jet/jet/v2/internal/utils"
|
||||
)
|
||||
import "github.com/go-jet/jet/v2/internal/utils/is"
|
||||
|
||||
// Clause interface
|
||||
type Clause interface {
|
||||
|
|
@ -322,7 +320,7 @@ func (u *ClauseUpdate) Serialize(statementType StatementType, out *SQLBuilder, o
|
|||
out.WriteString("UPDATE")
|
||||
u.OptimizerHints.Serialize(statementType, out, options...)
|
||||
|
||||
if utils.IsNil(u.Table) {
|
||||
if is.Nil(u.Table) {
|
||||
panic("jet: table to update is nil")
|
||||
}
|
||||
|
||||
|
|
@ -387,7 +385,7 @@ func (i *ClauseInsert) GetColumns() []Column {
|
|||
|
||||
// Serialize serializes clause into SQLBuilder
|
||||
func (i *ClauseInsert) Serialize(statementType StatementType, out *SQLBuilder, options ...SerializeOption) {
|
||||
if utils.IsNil(i.Table) {
|
||||
if is.Nil(i.Table) {
|
||||
panic("jet: table is nil for INSERT clause")
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import (
|
|||
"database/sql/driver"
|
||||
"fmt"
|
||||
"github.com/go-jet/jet/v2/internal/3rdparty/pq"
|
||||
"github.com/go-jet/jet/v2/internal/utils"
|
||||
"github.com/go-jet/jet/v2/internal/utils/is"
|
||||
"github.com/google/uuid"
|
||||
"reflect"
|
||||
"sort"
|
||||
|
|
@ -206,7 +206,7 @@ func (s *SQLBuilder) insertRawQuery(raw string, namedArg map[string]interface{})
|
|||
}
|
||||
|
||||
func argToString(value interface{}) string {
|
||||
if utils.IsNil(value) {
|
||||
if is.Nil(value) {
|
||||
return "NULL"
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
package jet
|
||||
|
||||
import (
|
||||
"github.com/go-jet/jet/v2/internal/utils"
|
||||
)
|
||||
import "github.com/go-jet/jet/v2/internal/utils/is"
|
||||
|
||||
// SerializerTable interface
|
||||
type SerializerTable interface {
|
||||
|
|
@ -158,7 +156,7 @@ func (t *joinTableImpl) serialize(statement StatementType, out *SQLBuilder, opti
|
|||
panic("jet: Join table is nil. ")
|
||||
}
|
||||
|
||||
if utils.IsNil(t.lhs) {
|
||||
if is.Nil(t.lhs) {
|
||||
panic("jet: left hand side of join operation is nil table")
|
||||
}
|
||||
|
||||
|
|
@ -179,7 +177,7 @@ func (t *joinTableImpl) serialize(statement StatementType, out *SQLBuilder, opti
|
|||
out.WriteString("CROSS JOIN")
|
||||
}
|
||||
|
||||
if utils.IsNil(t.rhs) {
|
||||
if is.Nil(t.rhs) {
|
||||
panic("jet: right hand side of join operation is nil table")
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
package jet
|
||||
|
||||
import (
|
||||
"github.com/go-jet/jet/v2/internal/utils"
|
||||
"github.com/go-jet/jet/v2/internal/utils/dbidentifier"
|
||||
"github.com/go-jet/jet/v2/internal/utils/must"
|
||||
"reflect"
|
||||
"strings"
|
||||
)
|
||||
|
|
@ -150,11 +151,11 @@ func UnwindRowFromModel(columns []Column, data interface{}) []Serializer {
|
|||
|
||||
row := []Serializer{}
|
||||
|
||||
utils.ValueMustBe(structValue, reflect.Struct, "jet: data has to be a struct")
|
||||
must.ValueBeOfTypeKind(structValue, reflect.Struct, "jet: data has to be a struct")
|
||||
|
||||
for _, column := range columns {
|
||||
columnName := column.Name()
|
||||
structFieldName := utils.ToGoIdentifier(columnName)
|
||||
structFieldName := dbidentifier.ToGoIdentifier(columnName)
|
||||
|
||||
structField := structValue.FieldByName(structFieldName)
|
||||
|
||||
|
|
@ -179,7 +180,7 @@ func UnwindRowFromModel(columns []Column, data interface{}) []Serializer {
|
|||
// UnwindRowsFromModels func
|
||||
func UnwindRowsFromModels(columns []Column, data interface{}) [][]Serializer {
|
||||
sliceValue := reflect.Indirect(reflect.ValueOf(data))
|
||||
utils.ValueMustBe(sliceValue, reflect.Slice, "jet: data has to be a slice.")
|
||||
must.ValueBeOfTypeKind(sliceValue, reflect.Slice, "jet: data has to be a slice.")
|
||||
|
||||
rows := [][]Serializer{}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue