File: runtime.go

package info (click to toggle)
golang-entgo-ent 0.11.3-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 21,976 kB
  • sloc: javascript: 641; makefile: 8; sql: 2
file content (199 lines) | stat: -rw-r--r-- 9,038 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
// Copyright 2019-present Facebook Inc. All rights reserved.
// This source code is licensed under the Apache 2.0 license found
// in the LICENSE file in the root directory of this source tree.

// Code generated by ent, DO NOT EDIT.

package ent

import (
	"time"

	"entgo.io/ent/entc/integration/customid/ent/account"
	"entgo.io/ent/entc/integration/customid/ent/blob"
	"entgo.io/ent/entc/integration/customid/ent/bloblink"
	"entgo.io/ent/entc/integration/customid/ent/car"
	"entgo.io/ent/entc/integration/customid/ent/device"
	"entgo.io/ent/entc/integration/customid/ent/doc"
	"entgo.io/ent/entc/integration/customid/ent/link"
	"entgo.io/ent/entc/integration/customid/ent/mixinid"
	"entgo.io/ent/entc/integration/customid/ent/note"
	"entgo.io/ent/entc/integration/customid/ent/other"
	"entgo.io/ent/entc/integration/customid/ent/pet"
	"entgo.io/ent/entc/integration/customid/ent/schema"
	"entgo.io/ent/entc/integration/customid/ent/session"
	"entgo.io/ent/entc/integration/customid/ent/token"
	"entgo.io/ent/entc/integration/customid/sid"
	uuidc "entgo.io/ent/entc/integration/customid/uuidcompatible"
	"github.com/google/uuid"
)

// The init function reads all schema descriptors with runtime code
// (default values, validators, hooks and policies) and stitches it
// to their package variables.
func init() {
	accountFields := schema.Account{}.Fields()
	_ = accountFields
	// accountDescEmail is the schema descriptor for email field.
	accountDescEmail := accountFields[1].Descriptor()
	// account.EmailValidator is a validator for the "email" field. It is called by the builders before save.
	account.EmailValidator = accountDescEmail.Validators[0].(func(string) error)
	// accountDescID is the schema descriptor for id field.
	accountDescID := accountFields[0].Descriptor()
	// account.DefaultID holds the default value on creation for the id field.
	account.DefaultID = accountDescID.Default.(func() sid.ID)
	blobFields := schema.Blob{}.Fields()
	_ = blobFields
	// blobDescUUID is the schema descriptor for uuid field.
	blobDescUUID := blobFields[1].Descriptor()
	// blob.DefaultUUID holds the default value on creation for the uuid field.
	blob.DefaultUUID = blobDescUUID.Default.(func() uuid.UUID)
	// blobDescCount is the schema descriptor for count field.
	blobDescCount := blobFields[2].Descriptor()
	// blob.DefaultCount holds the default value on creation for the count field.
	blob.DefaultCount = blobDescCount.Default.(int)
	// blobDescID is the schema descriptor for id field.
	blobDescID := blobFields[0].Descriptor()
	// blob.DefaultID holds the default value on creation for the id field.
	blob.DefaultID = blobDescID.Default.(func() uuid.UUID)
	bloblinkFields := schema.BlobLink{}.Fields()
	_ = bloblinkFields
	// bloblinkDescCreatedAt is the schema descriptor for created_at field.
	bloblinkDescCreatedAt := bloblinkFields[0].Descriptor()
	// bloblink.DefaultCreatedAt holds the default value on creation for the created_at field.
	bloblink.DefaultCreatedAt = bloblinkDescCreatedAt.Default.(func() time.Time)
	carMixin := schema.Car{}.Mixin()
	carMixinFields0 := carMixin[0].Fields()
	_ = carMixinFields0
	carFields := schema.Car{}.Fields()
	_ = carFields
	// carDescBeforeID is the schema descriptor for before_id field.
	carDescBeforeID := carMixinFields0[0].Descriptor()
	// car.BeforeIDValidator is a validator for the "before_id" field. It is called by the builders before save.
	car.BeforeIDValidator = carDescBeforeID.Validators[0].(func(float64) error)
	// carDescAfterID is the schema descriptor for after_id field.
	carDescAfterID := carMixinFields0[2].Descriptor()
	// car.AfterIDValidator is a validator for the "after_id" field. It is called by the builders before save.
	car.AfterIDValidator = carDescAfterID.Validators[0].(func(float64) error)
	// carDescID is the schema descriptor for id field.
	carDescID := carMixinFields0[1].Descriptor()
	// car.IDValidator is a validator for the "id" field. It is called by the builders before save.
	car.IDValidator = carDescID.Validators[0].(func(int) error)
	deviceFields := schema.Device{}.Fields()
	_ = deviceFields
	// deviceDescID is the schema descriptor for id field.
	deviceDescID := deviceFields[0].Descriptor()
	// device.DefaultID holds the default value on creation for the id field.
	device.DefaultID = deviceDescID.Default.(func() schema.ID)
	// device.IDValidator is a validator for the "id" field. It is called by the builders before save.
	device.IDValidator = deviceDescID.Validators[0].(func([]byte) error)
	docFields := schema.Doc{}.Fields()
	_ = docFields
	// docDescID is the schema descriptor for id field.
	docDescID := docFields[0].Descriptor()
	// doc.DefaultID holds the default value on creation for the id field.
	doc.DefaultID = docDescID.Default.(func() schema.DocID)
	// doc.IDValidator is a validator for the "id" field. It is called by the builders before save.
	doc.IDValidator = func() func(string) error {
		validators := docDescID.Validators
		fns := [...]func(string) error{
			validators[0].(func(string) error),
			validators[1].(func(string) error),
		}
		return func(id string) error {
			for _, fn := range fns {
				if err := fn(id); err != nil {
					return err
				}
			}
			return nil
		}
	}()
	linkFields := schema.Link{}.Fields()
	_ = linkFields
	// linkDescLinkInformation is the schema descriptor for link_information field.
	linkDescLinkInformation := linkFields[1].Descriptor()
	// link.DefaultLinkInformation holds the default value on creation for the link_information field.
	link.DefaultLinkInformation = linkDescLinkInformation.Default.(map[string]schema.LinkInformation)
	// linkDescID is the schema descriptor for id field.
	linkDescID := linkFields[0].Descriptor()
	// link.DefaultID holds the default value on creation for the id field.
	link.DefaultID = linkDescID.Default.(func() uuidc.UUIDC)
	mixinidMixin := schema.MixinID{}.Mixin()
	mixinidMixinFields0 := mixinidMixin[0].Fields()
	_ = mixinidMixinFields0
	mixinidFields := schema.MixinID{}.Fields()
	_ = mixinidFields
	// mixinidDescID is the schema descriptor for id field.
	mixinidDescID := mixinidMixinFields0[0].Descriptor()
	// mixinid.DefaultID holds the default value on creation for the id field.
	mixinid.DefaultID = mixinidDescID.Default.(func() uuid.UUID)
	noteFields := schema.Note{}.Fields()
	_ = noteFields
	// noteDescID is the schema descriptor for id field.
	noteDescID := noteFields[0].Descriptor()
	// note.DefaultID holds the default value on creation for the id field.
	note.DefaultID = noteDescID.Default.(func() schema.NoteID)
	// note.IDValidator is a validator for the "id" field. It is called by the builders before save.
	note.IDValidator = func() func(string) error {
		validators := noteDescID.Validators
		fns := [...]func(string) error{
			validators[0].(func(string) error),
			validators[1].(func(string) error),
		}
		return func(id string) error {
			for _, fn := range fns {
				if err := fn(id); err != nil {
					return err
				}
			}
			return nil
		}
	}()
	otherFields := schema.Other{}.Fields()
	_ = otherFields
	// otherDescID is the schema descriptor for id field.
	otherDescID := otherFields[0].Descriptor()
	// other.DefaultID holds the default value on creation for the id field.
	other.DefaultID = otherDescID.Default.(func() sid.ID)
	petFields := schema.Pet{}.Fields()
	_ = petFields
	// petDescID is the schema descriptor for id field.
	petDescID := petFields[0].Descriptor()
	// pet.DefaultID holds the default value on creation for the id field.
	pet.DefaultID = petDescID.Default.(func() string)
	// pet.IDValidator is a validator for the "id" field. It is called by the builders before save.
	pet.IDValidator = func() func(string) error {
		validators := petDescID.Validators
		fns := [...]func(string) error{
			validators[0].(func(string) error),
			validators[1].(func(string) error),
		}
		return func(id string) error {
			for _, fn := range fns {
				if err := fn(id); err != nil {
					return err
				}
			}
			return nil
		}
	}()
	sessionFields := schema.Session{}.Fields()
	_ = sessionFields
	// sessionDescID is the schema descriptor for id field.
	sessionDescID := sessionFields[0].Descriptor()
	// session.DefaultID holds the default value on creation for the id field.
	session.DefaultID = sessionDescID.Default.(func() schema.ID)
	// session.IDValidator is a validator for the "id" field. It is called by the builders before save.
	session.IDValidator = sessionDescID.Validators[0].(func([]byte) error)
	tokenFields := schema.Token{}.Fields()
	_ = tokenFields
	// tokenDescBody is the schema descriptor for body field.
	tokenDescBody := tokenFields[1].Descriptor()
	// token.BodyValidator is a validator for the "body" field. It is called by the builders before save.
	token.BodyValidator = tokenDescBody.Validators[0].(func(string) error)
	// tokenDescID is the schema descriptor for id field.
	tokenDescID := tokenFields[0].Descriptor()
	// token.DefaultID holds the default value on creation for the id field.
	token.DefaultID = tokenDescID.Default.(func() sid.ID)
}