dialect/sql/sqlgraph: add builders to create spec (#3288)

This commit is contained in:
Ariel Mashraki
2023-01-31 09:37:51 +02:00
committed by GitHub
parent a0fad09539
commit 037b5a4bc3
125 changed files with 134 additions and 854 deletions

View File

@@ -332,6 +332,11 @@ type (
}
)
// NewFieldSpec creates a new FieldSpec with its required fields.
func NewFieldSpec(column string, typ field.Type) *FieldSpec {
return &FieldSpec{Column: column, Type: typ}
}
// FieldValues returns the values of additional fields that were set on the join-table.
func (e *EdgeTarget) FieldValues() []any {
vs := make([]any, len(e.Fields))
@@ -381,6 +386,11 @@ type (
}
)
// NewCreateSpec creates a new node creation spec.
func NewCreateSpec(table string, id *FieldSpec) *CreateSpec {
return &CreateSpec{Table: table, ID: id}
}
// SetField appends a new field setter to the creation spec.
func (u *CreateSpec) SetField(column string, t field.Type, value driver.Value) {
u.Fields = append(u.Fields, &FieldSpec{