// Code generated by ent, DO NOT EDIT.

package testsummary

import (
	"fmt"
	"io"
	"strconv"

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

const (
	// Label holds the string label denoting the testsummary type in the database.
	Label = "test_summary"
	// FieldID holds the string denoting the id field in the database.
	FieldID = "id"
	// FieldOverallStatus holds the string denoting the overall_status field in the database.
	FieldOverallStatus = "overall_status"
	// FieldTotalRunCount holds the string denoting the total_run_count field in the database.
	FieldTotalRunCount = "total_run_count"
	// FieldRunCount holds the string denoting the run_count field in the database.
	FieldRunCount = "run_count"
	// FieldAttemptCount holds the string denoting the attempt_count field in the database.
	FieldAttemptCount = "attempt_count"
	// FieldShardCount holds the string denoting the shard_count field in the database.
	FieldShardCount = "shard_count"
	// FieldTotalNumCached holds the string denoting the total_num_cached field in the database.
	FieldTotalNumCached = "total_num_cached"
	// FieldFirstStartTime holds the string denoting the first_start_time field in the database.
	FieldFirstStartTime = "first_start_time"
	// FieldLastStopTime holds the string denoting the last_stop_time field in the database.
	FieldLastStopTime = "last_stop_time"
	// FieldTotalRunDuration holds the string denoting the total_run_duration field in the database.
	FieldTotalRunDuration = "total_run_duration"
	// FieldLabel holds the string denoting the label field in the database.
	FieldLabel = "label"
	// EdgeTestCollection holds the string denoting the test_collection edge name in mutations.
	EdgeTestCollection = "test_collection"
	// EdgePassed holds the string denoting the passed edge name in mutations.
	EdgePassed = "passed"
	// EdgeFailed holds the string denoting the failed edge name in mutations.
	EdgeFailed = "failed"
	// Table holds the table name of the testsummary in the database.
	Table = "test_summaries"
	// TestCollectionTable is the table that holds the test_collection relation/edge.
	TestCollectionTable = "test_summaries"
	// TestCollectionInverseTable is the table name for the TestCollection entity.
	// It exists in this package in order to avoid circular dependency with the "testcollection" package.
	TestCollectionInverseTable = "test_collections"
	// TestCollectionColumn is the table column denoting the test_collection relation/edge.
	TestCollectionColumn = "test_collection_test_summary"
	// PassedTable is the table that holds the passed relation/edge.
	PassedTable = "test_files"
	// PassedInverseTable is the table name for the TestFile entity.
	// It exists in this package in order to avoid circular dependency with the "testfile" package.
	PassedInverseTable = "test_files"
	// PassedColumn is the table column denoting the passed relation/edge.
	PassedColumn = "test_summary_passed"
	// FailedTable is the table that holds the failed relation/edge.
	FailedTable = "test_files"
	// FailedInverseTable is the table name for the TestFile entity.
	// It exists in this package in order to avoid circular dependency with the "testfile" package.
	FailedInverseTable = "test_files"
	// FailedColumn is the table column denoting the failed relation/edge.
	FailedColumn = "test_summary_failed"
)

// Columns holds all SQL columns for testsummary fields.
var Columns = []string{
	FieldID,
	FieldOverallStatus,
	FieldTotalRunCount,
	FieldRunCount,
	FieldAttemptCount,
	FieldShardCount,
	FieldTotalNumCached,
	FieldFirstStartTime,
	FieldLastStopTime,
	FieldTotalRunDuration,
	FieldLabel,
}

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

// 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
}

// OverallStatus defines the type for the "overall_status" enum field.
type OverallStatus string

// OverallStatusNO_STATUS is the default value of the OverallStatus enum.
const DefaultOverallStatus = OverallStatusNO_STATUS

// OverallStatus values.
const (
	OverallStatusNO_STATUS                  OverallStatus = "NO_STATUS"
	OverallStatusPASSED                     OverallStatus = "PASSED"
	OverallStatusFLAKY                      OverallStatus = "FLAKY"
	OverallStatusTIMEOUT                    OverallStatus = "TIMEOUT"
	OverallStatusFAILED                     OverallStatus = "FAILED"
	OverallStatusINCOMPLETE                 OverallStatus = "INCOMPLETE"
	OverallStatusREMOTE_FAILURE             OverallStatus = "REMOTE_FAILURE"
	OverallStatusFAILED_TO_BUILD            OverallStatus = "FAILED_TO_BUILD"
	OverallStatusTOOL_HALTED_BEFORE_TESTING OverallStatus = "TOOL_HALTED_BEFORE_TESTING"
)

func (os OverallStatus) String() string {
	return string(os)
}

// OverallStatusValidator is a validator for the "overall_status" field enum values. It is called by the builders before save.
func OverallStatusValidator(os OverallStatus) error {
	switch os {
	case OverallStatusNO_STATUS, OverallStatusPASSED, OverallStatusFLAKY, OverallStatusTIMEOUT, OverallStatusFAILED, OverallStatusINCOMPLETE, OverallStatusREMOTE_FAILURE, OverallStatusFAILED_TO_BUILD, OverallStatusTOOL_HALTED_BEFORE_TESTING:
		return nil
	default:
		return fmt.Errorf("testsummary: invalid enum value for overall_status field: %q", os)
	}
}

// OrderOption defines the ordering options for the TestSummary 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()
}

// ByOverallStatus orders the results by the overall_status field.
func ByOverallStatus(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldOverallStatus, opts...).ToFunc()
}

// ByTotalRunCount orders the results by the total_run_count field.
func ByTotalRunCount(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldTotalRunCount, opts...).ToFunc()
}

// ByRunCount orders the results by the run_count field.
func ByRunCount(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldRunCount, opts...).ToFunc()
}

// ByAttemptCount orders the results by the attempt_count field.
func ByAttemptCount(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldAttemptCount, opts...).ToFunc()
}

// ByShardCount orders the results by the shard_count field.
func ByShardCount(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldShardCount, opts...).ToFunc()
}

// ByTotalNumCached orders the results by the total_num_cached field.
func ByTotalNumCached(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldTotalNumCached, opts...).ToFunc()
}

// ByFirstStartTime orders the results by the first_start_time field.
func ByFirstStartTime(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldFirstStartTime, opts...).ToFunc()
}

// ByLastStopTime orders the results by the last_stop_time field.
func ByLastStopTime(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldLastStopTime, opts...).ToFunc()
}

// ByTotalRunDuration orders the results by the total_run_duration field.
func ByTotalRunDuration(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldTotalRunDuration, opts...).ToFunc()
}

// ByLabel orders the results by the label field.
func ByLabel(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldLabel, opts...).ToFunc()
}

// ByTestCollectionField orders the results by test_collection field.
func ByTestCollectionField(field string, opts ...sql.OrderTermOption) OrderOption {
	return func(s *sql.Selector) {
		sqlgraph.OrderByNeighborTerms(s, newTestCollectionStep(), sql.OrderByField(field, opts...))
	}
}

// ByPassedCount orders the results by passed count.
func ByPassedCount(opts ...sql.OrderTermOption) OrderOption {
	return func(s *sql.Selector) {
		sqlgraph.OrderByNeighborsCount(s, newPassedStep(), opts...)
	}
}

// ByPassed orders the results by passed terms.
func ByPassed(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
	return func(s *sql.Selector) {
		sqlgraph.OrderByNeighborTerms(s, newPassedStep(), append([]sql.OrderTerm{term}, terms...)...)
	}
}

// ByFailedCount orders the results by failed count.
func ByFailedCount(opts ...sql.OrderTermOption) OrderOption {
	return func(s *sql.Selector) {
		sqlgraph.OrderByNeighborsCount(s, newFailedStep(), opts...)
	}
}

// ByFailed orders the results by failed terms.
func ByFailed(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
	return func(s *sql.Selector) {
		sqlgraph.OrderByNeighborTerms(s, newFailedStep(), append([]sql.OrderTerm{term}, terms...)...)
	}
}
func newTestCollectionStep() *sqlgraph.Step {
	return sqlgraph.NewStep(
		sqlgraph.From(Table, FieldID),
		sqlgraph.To(TestCollectionInverseTable, FieldID),
		sqlgraph.Edge(sqlgraph.O2O, true, TestCollectionTable, TestCollectionColumn),
	)
}
func newPassedStep() *sqlgraph.Step {
	return sqlgraph.NewStep(
		sqlgraph.From(Table, FieldID),
		sqlgraph.To(PassedInverseTable, FieldID),
		sqlgraph.Edge(sqlgraph.O2M, false, PassedTable, PassedColumn),
	)
}
func newFailedStep() *sqlgraph.Step {
	return sqlgraph.NewStep(
		sqlgraph.From(Table, FieldID),
		sqlgraph.To(FailedInverseTable, FieldID),
		sqlgraph.Edge(sqlgraph.O2M, false, FailedTable, FailedColumn),
	)
}

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

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