package persistence

import (
	"database/sql/driver"
	"strings"

	"github.com/nexuscrm/shared/pkg/constants"
)

func systemFieldRowValues(objectID, apiName, fieldType string, referenceTo interface{}) []driver.Value {
	values := []driver.Value{
		"fld_" + strings.ToLower(apiName),
		objectID,
		apiName,
		apiName,
		nil, // PhysicalName
		fieldType,
		false, // Required
		false, // IsUnique
		false, // IsSystem
		false, // IsNameField
		true,  // Createable
		true,  // Updateable
		false, // Indexed
		nil,   // Options
		referenceTo,
		nil,      // WritableReferenceTo
		nil,      // DeleteRule
		nil,      // Formula
		nil,      // ReturnType
		nil,      // FormulaMode
		nil,      // FormulaStorageMode
		nil,      // ProjectionConfig
		nil,      // DefaultValue
		nil,      // SiblingMaxParentField
		nil,      // HelpText
		nil,      // Description
		false,    // TrackHistory
		int64(0), // HistoryTrackingRevision
		nil,      // MinValue
		nil,      // MaxValue
		nil,      // MinLength
		nil,      // MaxLength
		nil,      // Regex
		nil,      // RegexMessage
		nil,      // Validator
		nil,      // ValidatorConfig
		nil,      // ControllingField
		nil,      // PicklistDependency
		nil,      // RollupConfig
		false,    // IsMasterDetail
		false,    // IsPolymorphic
		nil,      // RelationshipName
		nil,      // ChildRelationshipName
		false,    // IsDeleted
		nil,      // OwnerID
		nil,      // CreatedByID
		nil,      // LastModifiedByID
		nil,      // CreatedDate
		nil,      // LastModifiedDate
		false,    // IsCustomized
		"runtime",
		nil, // OwnerPack
		nil, // WriteProtectionPolicy
		nil, // ReadProtectionPolicy
		nil, // AutoNumberFormat
		nil, // AutoNumberScope
		nil, // AutoNumberStart
		nil, // AutoNumberTokenRefs
		nil, // AutoNumberCanonicalHash
		nil, // AutoNumberCounterResetPolicy
	}
	if len(values) != len(constants.ColsSystemField) {
		panic("systemFieldRowValues out of sync with ColsSystemField")
	}
	return values
}
