// Code generated by ent, DO NOT EDIT.

package targetconfigured

import (
	"fmt"
	"io"
	"strconv"

	"entgo.io/ent/dialect/sql"
	"entgo.io/ent/dialect/sql/sqlgraph"
)

const (
	// Label holds the string label denoting the targetconfigured type in the database.
	Label = "target_configured"
	// FieldID holds the string denoting the id field in the database.
	FieldID = "id"
	// FieldTag holds the string denoting the tag field in the database.
	FieldTag = "tag"
	// FieldTargetKind holds the string denoting the target_kind field in the database.
	FieldTargetKind = "target_kind"
	// FieldStartTimeInMs holds the string denoting the start_time_in_ms field in the database.
	FieldStartTimeInMs = "start_time_in_ms"
	// FieldTestSize holds the string denoting the test_size field in the database.
	FieldTestSize = "test_size"
	// EdgeTargetPair holds the string denoting the target_pair edge name in mutations.
	EdgeTargetPair = "target_pair"
	// Table holds the table name of the targetconfigured in the database.
	Table = "target_configureds"
	// TargetPairTable is the table that holds the target_pair relation/edge.
	TargetPairTable = "target_configureds"
	// TargetPairInverseTable is the table name for the TargetPair entity.
	// It exists in this package in order to avoid circular dependency with the "targetpair" package.
	TargetPairInverseTable = "target_pairs"
	// TargetPairColumn is the table column denoting the target_pair relation/edge.
	TargetPairColumn = "target_pair_configuration"
)

// Columns holds all SQL columns for targetconfigured fields.
var Columns = []string{
	FieldID,
	FieldTag,
	FieldTargetKind,
	FieldStartTimeInMs,
	FieldTestSize,
}

// ForeignKeys holds the SQL foreign-keys that are owned by the "target_configureds"
// table and are not defined as standalone fields in the schema.
var ForeignKeys = []string{
	"target_pair_configuration",
}

// ValidColumn reports if the column name is valid (part of the table columns).
func ValidColumn(column string) bool {
	for i := range Columns {
		if column == Columns[i] {
			return true
		}
	}
	for i := range ForeignKeys {
		if column == ForeignKeys[i] {
			return true
		}
	}
	return false
}

// TestSize defines the type for the "test_size" enum field.
type TestSize string

// TestSize values.
const (
	TestSizeUNKNOWN  TestSize = "UNKNOWN"
	TestSizeSMALL    TestSize = "SMALL"
	TestSizeMEDIUM   TestSize = "MEDIUM"
	TestSizeLARGE    TestSize = "LARGE"
	TestSizeENORMOUS TestSize = "ENORMOUS"
)

func (ts TestSize) String() string {
	return string(ts)
}

// TestSizeValidator is a validator for the "test_size" field enum values. It is called by the builders before save.
func TestSizeValidator(ts TestSize) error {
	switch ts {
	case TestSizeUNKNOWN, TestSizeSMALL, TestSizeMEDIUM, TestSizeLARGE, TestSizeENORMOUS:
		return nil
	default:
		return fmt.Errorf("targetconfigured: invalid enum value for test_size field: %q", ts)
	}
}

// OrderOption defines the ordering options for the TargetConfigured queries.
type OrderOption func(*sql.Selector)

// ByID orders the results by the id field.
func ByID(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldID, opts...).ToFunc()
}

// ByTargetKind orders the results by the target_kind field.
func ByTargetKind(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldTargetKind, opts...).ToFunc()
}

// ByStartTimeInMs orders the results by the start_time_in_ms field.
func ByStartTimeInMs(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldStartTimeInMs, opts...).ToFunc()
}

// ByTestSize orders the results by the test_size field.
func ByTestSize(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldTestSize, opts...).ToFunc()
}

// ByTargetPairField orders the results by target_pair field.
func ByTargetPairField(field string, opts ...sql.OrderTermOption) OrderOption {
	return func(s *sql.Selector) {
		sqlgraph.OrderByNeighborTerms(s, newTargetPairStep(), sql.OrderByField(field, opts...))
	}
}
func newTargetPairStep() *sqlgraph.Step {
	return sqlgraph.NewStep(
		sqlgraph.From(Table, FieldID),
		sqlgraph.To(TargetPairInverseTable, FieldID),
		sqlgraph.Edge(sqlgraph.O2O, true, TargetPairTable, TargetPairColumn),
	)
}

// MarshalGQL implements graphql.Marshaler interface.
func (e TestSize) MarshalGQL(w io.Writer) {
	io.WriteString(w, strconv.Quote(e.String()))
}

// UnmarshalGQL implements graphql.Unmarshaler interface.
func (e *TestSize) UnmarshalGQL(val interface{}) error {
	str, ok := val.(string)
	if !ok {
		return fmt.Errorf("enum %T must be a string", val)
	}
	*e = TestSize(str)
	if err := TestSizeValidator(*e); err != nil {
		return fmt.Errorf("%s is not a valid TestSize", str)
	}
	return nil
}
