diff --git a/doc/md/schema-fields.md b/doc/md/schema-fields.md index 5f044a826..fa5c69b52 100755 --- a/doc/md/schema-fields.md +++ b/doc/md/schema-fields.md @@ -297,7 +297,7 @@ func (User) Fields() []ent.Field { } ``` -## Struct Fields +## Additional Struct Fields By default, `entc` generates the entity model with fields that are configured in the `schema.Fields` method. For example, given this schema configuration: @@ -333,17 +333,15 @@ type User struct { ``` In order to add additional fields to the generated struct **that are not stored in the database**, -add them to the schema struct as follows: - -```go -// User schema. -type User struct { - ent.Schema - // Additional struct-only fields. - Tenant string - Logger *log.Logger -} +use [external templates](code-gen.md/#external-templates). For example: +```gotemplate +{{ define "model/fields/additional" }} + {{- if eq $.Name "User" }} + // StaticField defined by template. + StaticField string `json:"static,omitempty"` + {{- end }} +{{ end }} ``` The generated model will be as follows: @@ -355,9 +353,8 @@ type User struct { Age *int `json:"age,omitempty"` // Name holds the value of the "name" field. Name string `json:"name,omitempty" gqlgen:"gql_name"` - // additional struct fields defined in the schema. - Tenant string - Logger *log.Logger + // StaticField defined by template. + StaticField string `json:"static,omitempty"` } ``` diff --git a/entc/gen/internal/bindata.go b/entc/gen/internal/bindata.go index 901e08769..efa8a9e79 100644 --- a/entc/gen/internal/bindata.go +++ b/entc/gen/internal/bindata.go @@ -194,7 +194,7 @@ func templateBuilderQueryTmpl() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "template/builder/query.tmpl", size: 15859, mode: os.FileMode(420), modTime: time.Unix(1571154251, 0)} + info := bindataFileInfo{name: "template/builder/query.tmpl", size: 15859, mode: os.FileMode(420), modTime: time.Unix(1571161760, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -779,7 +779,7 @@ func templateDialectSqlUpdateTmpl() (*asset, error) { return a, nil } -var _templateEntTmpl = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x9c\x57\x5f\x6f\xe3\xb8\x11\x7f\x96\x3e\xc5\x9c\xe0\x2b\xec\xc0\x96\xb7\xf7\xd6\x6d\x53\x60\x9b\xec\x01\x06\x8a\xf4\x4f\xb2\xe8\xc3\x62\x91\xd0\xe2\x48\x66\x43\x91\x3e\x92\x72\x62\x08\xfa\xee\xc5\x90\x94\x22\xd9\xbe\x6b\x6e\x9f\x2c\x93\xc3\xf9\xf3\x9b\xe1\xcc\x8f\x6d\xbb\xbe\x4a\x6f\xf4\xfe\x68\x44\xb5\x73\xf0\xd3\x87\x3f\xfe\x69\xb5\x37\x68\x51\x39\xf8\x99\x15\xb8\xd5\xfa\x19\x36\xaa\xc8\xe1\x93\x94\xe0\x85\x2c\xd0\xbe\x39\x20\xcf\xd3\x87\x9d\xb0\x60\x75\x63\x0a\x84\x42\x73\x04\x61\x41\x8a\x02\x95\x45\x0e\x8d\xe2\x68\xc0\xed\x10\x3e\xed\x59\xb1\x43\xf8\x29\xff\xd0\xef\x42\xa9\x1b\xc5\x53\xa1\xfc\xfe\xdf\x37\x37\x9f\xef\xee\x3f\x43\x29\x24\x42\x5c\x33\x5a\x3b\xe0\xc2\x60\xe1\xb4\x39\x82\x2e\xc1\x8d\x8c\x39\x83\x98\xa7\x57\xeb\xae\x4b\xd3\xb6\x05\x8e\xa5\x50\x08\x59\xad\x39\xca\x0c\xe2\xea\x6c\xff\x5c\xc1\xc7\x6b\xd8\x32\x8b\x30\xcb\x6f\xb4\x2a\x45\x95\xff\x93\x15\xcf\xac\x42\x12\x6a\x5b\x70\x58\xef\x25\x73\x08\xd9\x0e\x19\x47\x93\xc1\xac\x3f\xfe\xb6\x25\xea\xbd\x36\xae\xdf\x5a\xaf\x81\x94\xe7\x77\xac\x26\x2d\x14\x33\x39\xec\x6d\x03\x2a\x27\xdc\x11\x4a\x1d\x22\x9f\x08\xda\x62\x87\x35\xcb\x53\x77\xdc\x9f\xee\x38\xd3\x14\x0e\xda\x34\x29\xbc\x93\x30\x31\xef\x35\xaf\x75\x2d\x9c\x63\x95\x8d\x6e\x24\xeb\x35\x6c\x6e\x03\x2e\x48\x66\xf3\x34\xd9\xdc\x06\xb5\x9b\xdb\xfc\x81\x6c\x74\x1d\x3c\xfd\xd7\x6a\xf5\x31\x13\x7c\x49\xe7\xb1\xde\xbb\x63\xf6\x94\x26\x6d\x0b\x86\xa9\x0a\x61\xf6\xb8\x84\x59\x49\x28\xcd\xf2\x9f\x05\x4a\x6e\x61\x45\xda\x93\x18\x65\x99\xdf\x7b\xdf\xfc\x1e\x29\xdc\x69\x92\x21\x9b\x07\x26\x1b\xec\x1d\xc8\x82\x70\x0c\x28\x83\x92\xe4\xf3\x14\x00\x20\xb9\xa8\xa7\x6d\x41\x94\xfe\x88\x90\x92\x6d\x25\x1d\xbb\x6a\x5b\x40\x45\xdb\xe1\x48\x1f\x44\x90\x55\xda\x79\x3d\xa8\xac\x70\xe2\x40\x3b\x4f\x63\xd5\x0f\xac\x8a\x4b\x28\x2d\x06\x25\xbf\x0d\xe2\x60\xce\x03\x42\x9f\xab\xf8\x3d\x02\x07\x03\x38\x9f\x79\x85\x3d\x36\x74\x6b\x40\x54\x4a\x1b\x84\x0a\x15\x1a\xe6\x84\xaa\x00\x79\x85\x21\x70\x0b\xbe\x34\x49\x72\x05\x2f\xc2\xed\x60\x86\x23\x2f\x83\x96\x1e\x62\x7c\x27\xc4\x41\xb6\x2f\x19\x32\x96\xc3\xc3\x20\x64\xd1\x81\xd3\xa0\x84\x5c\x02\x53\x1c\xec\x4e\x37\x92\xc3\x16\xa1\xd9\x73\xe6\x90\x43\xcd\x54\xc3\xa4\x3c\xe6\x64\xfb\xa2\xe1\x11\xce\x98\x7f\x51\xe2\x97\x86\x4c\x7d\xfd\x36\xe0\x74\x15\x8e\x51\x5e\x06\x47\x9e\xc6\xaa\x62\x0e\x7c\xe4\x13\x40\xc7\xdf\x01\x90\xb1\xf1\x51\xd1\x31\xce\x85\x13\x5a\x31\xd9\xdf\x8a\x88\x68\xb8\xe3\xbc\xef\x0f\xfd\x65\x4a\x2e\xd7\xf2\x05\xe5\xc9\xa4\x44\xe1\xac\xc4\x82\x5b\x65\x1e\x33\x44\x71\xe5\x7d\x41\x29\x7e\x22\x74\xa3\xeb\x9a\x9a\xe4\xaa\xeb\x42\x1a\xf3\x69\x3d\xfd\x5a\xfc\xa1\xb5\x8c\xfc\xb5\x4e\x1b\x6a\x47\xd1\xeb\xf0\x27\x1e\x9a\xb9\x7a\x2f\x69\x67\x6f\x84\x72\x25\x64\x5c\x30\x89\x85\x5b\xff\x68\xd7\x1c\xa9\xe1\xae\xb5\xc2\xec\x4d\x49\x3c\xf7\x3a\x94\x7d\xd0\x30\x8b\xcd\x2e\x3a\xe7\x7b\xa3\xc1\x02\xc5\x01\x4d\x30\xfc\xef\xfe\x5f\x77\xe6\xe0\xa4\xfe\x7b\xc7\xca\x46\x15\x83\x63\x90\xfd\xab\x41\x73\xcc\xce\x2b\x2a\x1d\xda\x08\xc9\x77\x1d\xfc\xd2\xa0\x11\x68\x7f\xa5\x9e\xc7\x95\xde\x6f\xe4\x69\xe2\x0f\xcf\x27\x4e\x77\x1d\x5c\x8d\xa5\x16\x63\x2b\xf3\x05\x9c\x16\x6a\xd7\x79\x17\xa9\xc3\x26\x06\x5d\x63\x14\xcc\xff\x30\x56\x70\x23\x05\x2a\xd7\xc2\x89\x95\x3c\xf4\xe3\x6e\x91\x8f\xf5\x9f\x08\x2d\xd2\x64\x02\xef\x7a\x0d\x5f\xfc\x9d\x83\x60\xca\x02\x83\x6d\x23\x24\x8d\x43\x1a\x0c\xfe\x42\x52\xc3\xf0\x13\x6d\x1a\xec\x7a\x0d\x77\xda\x21\xb8\x1d\x73\x4b\x38\xea\x06\x14\x22\xa7\x9b\x5d\x30\x29\xa7\xc2\x5f\xd4\x8b\x61\xfb\xf9\x02\xb6\x58\x52\x2b\x22\x89\x41\x6d\x8d\x6e\xa7\xf9\x92\x2e\xf4\x99\x19\xb2\xf2\xc2\x6c\x74\x0f\x39\x94\x46\xd7\xc0\xc0\x19\xa6\x2c\x2b\xe8\xfa\x85\x26\x42\xc9\x18\x2d\xfa\x43\x85\xae\xa9\x89\x22\x07\x6d\xc0\x68\x29\x91\xc3\x96\x15\xcf\x79\xfa\xae\x3c\x05\x64\xfa\x14\xf5\xeb\x61\xf5\x1f\x0a\x29\x43\xdf\x97\xa0\x41\xc5\x79\x7a\x62\x4e\x3c\x5c\xd0\xf8\x1f\xdb\x8f\x4d\x9a\xd6\x04\xf6\xff\x03\x04\x58\xe9\xd0\x80\x08\x82\x85\xd4\x16\xf9\x92\xd4\x5a\x1d\xce\x53\x7a\x14\xbe\xba\xa1\xc6\x5f\x84\x94\xd4\x7f\xf1\x15\x8b\x86\xf0\x72\x3b\xa3\x9b\x6a\xe7\x2d\x73\xe3\xbd\x7b\xd9\x89\x62\x07\x85\x41\x16\x04\x26\x70\xbf\x17\xd1\xbe\x0c\x26\xeb\x04\xa4\x7b\x5d\x82\x7e\xa6\x7b\x7a\x19\xb5\x3c\x78\x91\xcf\xaf\xdc\xeb\xad\xff\x5c\xa4\x89\x28\xe1\x07\xfd\xec\x6f\xca\x9e\x29\x51\xcc\xb3\x9e\x4a\x75\xdd\xc7\x33\xe6\x43\xc3\x62\x82\x13\xeb\x39\x50\xe6\xaf\x45\xf2\x9b\x96\xe1\x1a\xdc\x6b\xce\xcd\x61\x48\xfa\x89\x78\x4c\xdd\xbd\x33\x54\xd8\xa2\xde\x4b\xa4\xb6\x1b\xb2\x57\xd6\x2e\x0f\x3b\x68\xde\x89\x55\x10\x9f\x2f\x68\xb6\x90\xc6\x36\x4d\xb6\x8d\x1f\x19\xdb\xa3\x43\x9b\xdf\xe1\xcb\xdf\x9a\xb2\x44\x33\x57\x42\x2e\xfc\x66\xfe\x1f\x23\x1c\xc6\x83\xd9\x58\xdd\x3c\xbb\x20\xe1\x9d\x0a\xfd\x7a\x9e\x09\x7e\xfd\xe3\x21\x5b\x9e\xc1\xbf\xb9\x5d\x2c\x52\x4f\x0e\x62\xa3\x15\x67\x2c\x6c\xa0\x0f\x81\x25\x8d\x59\x0f\xcd\xb2\x33\xc7\x96\x30\x19\x6f\xd7\x6d\x3b\x4c\x8d\xbf\xd8\xfe\xf0\x5f\x89\x1b\x93\xd7\x5e\x73\xa4\x49\x61\x34\xae\xce\xe9\x18\x6d\x50\x39\x1c\x2e\x55\xd0\x25\x52\xf7\x67\x38\xc0\x0f\xd7\xc4\x41\x7c\xf9\x5c\x70\x73\x82\xce\xa9\xcb\x1e\xaa\xab\x03\x41\x93\x24\xc9\xe0\xd7\xc8\xcd\xef\xd0\xf7\x1e\xbf\x83\x45\x6f\xeb\x6d\x7c\xaf\x46\xdc\xf0\xed\xfb\x0c\xf7\x05\xc1\x19\x8b\x97\x36\xfb\x0a\x0b\x93\x3e\xa0\x4a\x84\x7c\x63\x63\x11\x87\xf6\x2b\xf8\x30\x1c\xa8\x94\x69\x8a\x1a\x8c\x2f\x2f\xe6\xfb\x4d\x9c\x85\x9b\xdb\x9e\x4b\xbf\xab\xc0\x05\x9f\x2f\xbc\xb6\x36\x4d\x04\x5f\xc2\x23\xe5\xce\x3a\x53\x68\x75\xc8\x3f\x39\x2d\x4e\x15\x50\x2d\x0e\x01\x08\x9e\x76\xe9\x28\x5c\xcf\x14\x2c\xbd\xd9\xfc\xb0\x97\x8d\x61\x72\x3a\x46\xde\x04\x42\x3f\x60\xb0\x67\xc6\xfa\x02\x0a\xcb\xba\x3c\x99\x70\xc3\xeb\x67\x38\xf6\xf5\xdb\x24\x88\xdf\xc3\x90\x3c\x1d\xc3\x57\x47\xfe\xce\x20\xbb\x27\x95\xd9\x9b\xea\xc0\xc3\xde\x41\xa3\x6a\xa6\x8e\x27\x3c\xea\x12\x91\xca\xc7\x6f\x85\x29\xa7\xba\x9c\x9d\x71\x9c\x0b\x08\xbd\x6f\x5e\x94\x55\xfc\x5c\x50\x9a\x88\x12\x3c\x0a\xf2\x2f\x04\x7d\xa6\x23\x46\x31\x5a\xfb\xfa\x28\xbe\xc5\x4e\x0a\xd7\x50\x94\x15\xb5\xda\x53\x8a\x37\x79\x14\x8f\x5e\x3e\x9e\xa7\x46\x0e\xfe\xc0\x2a\xe2\x48\x36\xf2\xdc\x51\x37\x72\xe4\x50\x24\xb5\xf4\x28\xa0\x65\xf8\x10\x63\x7a\x7b\xa4\x39\x9a\x0a\xd9\x2a\x1b\x16\x9f\xc6\xdb\xd1\x9b\xff\x05\x00\x00\xff\xff\x87\x16\x26\x80\x66\x10\x00\x00") +var _templateEntTmpl = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x9c\x57\x5f\x6f\xe3\xb8\x11\x7f\xb6\x3e\xc5\x9c\xe0\x2b\xec\xc0\xa1\xb6\xf7\xd6\x6d\x53\x60\xbb\xd9\x03\x0c\x14\xdb\x3f\xc9\xa2\x0f\x8b\x45\x42\x8b\x23\x89\x0d\x45\xfa\x48\xca\x89\x21\xe8\xbb\x17\x43\x4a\x8a\x64\xfb\xae\xb9\x7d\xb2\xcc\x19\xce\x0c\x7f\x33\x9c\xf9\xb1\x6d\xb3\xab\xe4\xa3\xd9\x1f\xad\x2c\x2b\x0f\x3f\xbd\xfb\xe3\x9f\xae\xf7\x16\x1d\x6a\x0f\x3f\xf3\x1c\x77\xc6\x3c\xc1\x56\xe7\x0c\x3e\x28\x05\x41\xc9\x01\xc9\xed\x01\x05\x4b\xee\x2b\xe9\xc0\x99\xc6\xe6\x08\xb9\x11\x08\xd2\x81\x92\x39\x6a\x87\x02\x1a\x2d\xd0\x82\xaf\x10\x3e\xec\x79\x5e\x21\xfc\xc4\xde\x0d\x52\x28\x4c\xa3\x45\x22\x75\x90\xff\x7d\xfb\xf1\xd3\xe7\xbb\x4f\x50\x48\x85\xd0\xaf\x59\x63\x3c\x08\x69\x31\xf7\xc6\x1e\xc1\x14\xe0\x27\xce\xbc\x45\x64\xc9\x55\xd6\x75\x49\xd2\xb6\x20\xb0\x90\x1a\x21\xad\x8d\x40\x95\x42\xbf\xba\xdc\x3f\x95\xf0\xfe\x06\x76\xdc\x21\x2c\xd9\x47\xa3\x0b\x59\xb2\x7f\xf2\xfc\x89\x97\x48\x4a\x6d\x0b\x1e\xeb\xbd\xe2\x1e\x21\xad\x90\x0b\xb4\x29\x2c\x87\xed\xaf\x22\x59\xef\x8d\xf5\x83\x28\xcb\x80\x8c\xb3\xcf\xbc\x26\x2b\x74\x66\x0a\x38\xf8\x06\xd4\x5e\xfa\x23\x14\x26\x9e\x7c\xa6\xe8\xf2\x0a\x6b\xce\x12\x7f\xdc\x9f\x4a\xbc\x6d\x72\x0f\x6d\xb2\xc8\x43\x90\x30\x73\x1f\x2c\x67\xa6\x96\xde\xf3\xd2\xf5\x61\x2c\xb2\x0c\xb6\xb7\x11\x17\x24\xb7\x2c\x59\x6c\x6f\xa3\xd9\xed\x2d\xbb\x27\x1f\x5d\x07\x8f\xff\x75\x46\xbf\x4f\xa5\xd8\xd0\x7e\xac\xf7\xfe\x98\x3e\x26\x8b\xb6\x05\xcb\x75\x89\xb0\x7c\xd8\xc0\xb2\x20\x94\x96\xec\x67\x89\x4a\x38\xb8\x26\xeb\x8b\xfe\x94\x05\xbb\x0b\xb1\x05\x19\x19\xac\x0c\xe9\x90\xcf\x03\x57\x0d\x0e\x01\xa4\x51\xb9\x3f\x50\x0a\x05\xe9\xb3\x04\x00\x60\x71\xd1\x4e\xdb\x82\x2c\xc2\x16\xa9\x14\xdf\x29\xda\x76\xd5\xb6\x80\x9a\xc4\x71\xcb\x70\x88\xa8\xab\x8d\x0f\x76\x50\x3b\xe9\xe5\x81\x24\x8f\x53\xd3\xf7\xbc\xec\x97\x50\x39\x8c\x46\x7e\x1b\xc4\xd1\x5d\x00\x84\x3e\xaf\xfb\xef\x09\x38\x18\xc1\xf9\x24\x4a\x1c\xb0\xa1\x5b\x03\xb2\xd4\xc6\x22\x94\xa8\xd1\x72\x2f\x75\x09\x28\x4a\x8c\x07\x77\x10\x4a\x93\x34\xaf\xe1\x59\xfa\x0a\x96\x38\x89\x32\x5a\x19\x20\xc6\x37\x42\x1c\x75\x87\x92\x21\x67\x0c\xee\x47\x25\x87\x1e\xbc\x01\x2d\xd5\x06\xb8\x16\xe0\x2a\xd3\x28\x01\x3b\x84\x66\x2f\xb8\x47\x01\x35\xd7\x0d\x57\xea\xc8\xc8\xf7\x45\xc7\x13\x9c\x91\x7d\xd1\xf2\x97\x86\x5c\x7d\xfd\x36\xe2\x74\x15\xb7\x51\x5e\xc6\x40\x1e\xa7\xa6\xfa\x1c\x84\x93\xcf\x00\x9d\x7e\x9f\x26\x25\x42\x96\x71\x21\xa4\x97\x46\x73\xd5\x97\x78\xbc\x86\x93\x54\x38\x6f\x2c\x5d\xdd\x90\x90\xbb\xfe\x4f\x6f\x74\xe9\xeb\xbd\x22\xc9\xde\x4a\xed\x0b\x48\x85\xe4\x0a\x73\x9f\xfd\xe8\x32\x81\xd4\x9c\x32\xa3\x31\x7d\x35\xd2\xef\x7b\x19\xa3\x89\x16\x96\x7d\x63\xe8\x0b\x23\xf4\x11\x8b\x39\xca\x03\xda\xe8\xf8\xdf\xc3\xbf\xee\x2c\xc0\x59\xad\x0c\x81\x15\x8d\xce\xc7\xc0\x20\xfd\x57\x83\xf6\x98\x9e\xa3\x9f\x8c\x57\x8e\xf4\xbb\x0e\x7e\x69\xd0\x4a\x74\xbf\x92\xfb\x69\x55\x0c\x02\x96\x2c\xc2\xe6\xd5\x2c\xe8\xae\x83\xab\xa9\xd6\x7a\xea\x65\xb5\x86\xd3\xa4\x76\x5d\x08\x91\xba\xd1\xc2\xa2\x6f\xac\x86\xd5\x1f\xa6\x06\x3e\x2a\x89\xda\xb7\x70\xe2\x85\xc5\xde\xd5\xad\xd9\xd4\xfe\x89\xd2\x3a\x59\xcc\xe0\xcd\x32\xf8\x12\xea\x13\xa2\x2b\x07\x1c\x76\x8d\x54\x34\x3a\xa8\x89\x86\xe2\xa5\xcb\x15\xba\xff\xfc\xb0\x59\x06\x9f\x8d\x47\xf0\x15\xf7\x1b\x38\x9a\x06\x34\xa2\xa0\x5b\x90\x73\xa5\xe6\xca\x5f\xf4\xb3\xe5\xfb\xd5\x1a\x76\x58\xd0\xb5\x25\x8d\xd1\x6c\x8d\xbe\x32\x62\x43\xc5\x7f\xe6\x86\xbc\x3c\x73\xd7\x87\x87\x02\x0a\x6b\x6a\xe0\xe0\x2d\xd7\x8e\xe7\x54\xb0\xf1\xc2\x51\x32\x26\x8b\x61\x53\x6e\x6a\x6a\x38\x28\xc0\x58\xb0\x46\x29\x14\xb0\xe3\xf9\x13\x4b\xde\x94\xa7\x88\xcc\x90\xa2\x61\x3d\xae\xfe\x43\x23\x65\xe8\xfb\x12\x34\x9a\x38\x4f\x4f\x9f\x93\x00\x17\x34\xe1\xc7\x0d\x23\x86\x26\x1b\x81\xfd\xff\x00\x01\x5e\x78\xb4\x20\xa3\x62\xae\x8c\x43\xb1\x21\xb3\xce\xc4\xfd\x94\x1e\x8d\x2f\x7e\xac\xf1\x67\xa9\x14\xf5\x2a\x7c\xc1\xbc\x21\xbc\x7c\x65\x4d\x53\x56\xc1\xb3\xb0\x21\xba\xe7\x4a\xe6\x15\xe4\x16\x79\x54\x98\xc1\xfd\x56\x44\x87\x32\x98\xad\x13\x90\xfe\x65\x03\xe6\x89\xee\xe9\x65\xd4\x58\x8c\x82\xad\xae\xfc\xcb\x6d\xf8\x5c\x27\x0b\x59\xc0\x0f\xe6\x29\xdc\x94\x3d\xd7\x32\x5f\xa5\x03\xed\xe8\xba\xf7\x67\x2c\x81\x1a\xeb\x0c\x27\x3e\xf0\x85\x34\x5c\x8b\xc5\x6f\x7a\x86\x1b\xf0\x2f\x4c\xd8\xc3\x98\xf4\x13\xf5\x3e\x75\x77\xde\x52\x61\xcb\x7a\xaf\xb0\x46\xed\x63\xf6\x8a\xda\xb3\x28\x41\xfb\x46\xac\xa2\xfa\x6a\x4d\xec\x84\x2c\xb6\xc9\x62\xd7\x04\xaa\xb0\x3b\x7a\x74\xec\x33\x3e\xff\xad\x29\x0a\xb4\x2b\x2d\xd5\x3a\x08\xd9\x7f\xac\xf4\xd8\x6f\x4c\xa7\xe6\x56\xe9\x05\x8d\x10\x54\xec\xd7\xab\x54\x8a\x9b\x1f\x0f\xe9\xe6\x0c\xfe\xed\xed\x7a\x9d\x84\x41\xda\x37\x5a\x79\xc6\x58\xc6\x51\x1b\x19\xc5\x94\x21\xd0\xac\x3b\x0b\x6c\x03\x33\xb6\x72\xd3\xb6\xe3\xd4\xf8\x8b\x1b\x36\xff\x95\x78\x24\x45\x1d\x2c\xf7\x94\x22\x8e\xce\xeb\x73\xea\x42\x02\x2a\x87\xc3\xa5\x0a\xba\x44\x80\xfe\x0c\x07\xf8\xe1\x86\xe6\x75\x28\x9f\x0b\x61\xce\xd0\x39\x0d\x39\x40\x75\x75\x20\x68\x16\x8b\xc5\x18\xd7\x24\xcc\xef\xb0\xf7\x96\xb8\xa3\xc7\xe0\xab\xa7\x4e\xb3\x3f\xd3\xef\x33\xdc\xd7\x04\x67\x5f\xbc\x24\x1c\x2a\x2c\x4e\xfa\x88\x2a\x91\xd7\xad\xeb\x8b\x38\xb6\x5f\x29\xc6\xe1\x40\xa5\x4c\x53\xd4\x62\xff\x4a\xe1\xa1\xdf\xf4\xb3\x70\x7b\x3b\xf0\xce\x37\x15\xb8\x14\xab\x75\xb0\xd6\x26\x0b\x29\x36\xf0\x40\xb9\x73\xde\xe6\x46\x1f\xd8\x07\x6f\xe4\xa9\x01\xaa\xc5\xf1\x00\x52\x24\x5d\x32\x39\x6e\x60\x0a\x8e\xde\x37\x61\xd8\xab\xc6\x72\x35\x1f\x23\xaf\x0a\xb1\x1f\x70\xd8\x73\xeb\x42\x01\xc5\x65\x53\x9c\x4c\xb8\xf1\xa5\x30\x6e\xfb\xfa\x6d\x76\x88\xdf\xc3\x90\x02\x0f\xc5\x17\x4f\xf1\x2e\x21\xbd\x23\x93\xe9\xab\xe9\xc8\xd9\xde\x40\xa3\x6a\xae\x8f\x27\x3c\xea\x12\x91\x62\x53\x5e\x3d\xe7\x54\x97\xb3\x33\x3d\xe7\x1a\x62\xef\x5b\xe5\x45\xd9\x7f\xae\x29\x4d\x44\x09\x1e\x24\xc5\x17\x0f\x7d\x66\xa3\x3f\xc5\x64\xed\xeb\x83\xfc\xd6\x77\x52\xb8\x81\xbc\x28\xa9\xd5\x9e\x50\xbc\xec\x0a\x3e\xbc\xd2\x52\x72\x12\x1e\x0a\x54\x82\xf1\x69\x76\x4d\x8f\x06\x16\x59\xfd\xe9\x7b\x73\xf2\xa8\x08\x4f\x8a\xc8\xf7\xd9\x3d\x2f\x89\x52\xb9\xfe\x4d\x32\x69\x5e\x9e\xe2\x67\x51\x99\xf8\x36\x2d\xc3\xbb\x1e\x82\xd7\xf7\x8f\xa7\x21\x92\x5e\xa7\xe3\xe2\xe3\x54\xfc\x6b\xc1\x87\xf9\x9a\x73\x4d\xd3\xd4\x1c\xd0\x5a\x29\x50\xd0\xa3\xda\xd8\xf0\x1c\x37\xc0\x85\x80\x57\xae\x3d\x3c\x58\xbc\x89\x53\x9e\xe7\x15\x50\xd9\xb1\xcb\x67\xbd\xc0\xd5\x29\x1c\xd4\xa2\xeb\xfe\x17\x00\x00\xff\xff\x29\x5b\xef\x79\x4d\x10\x00\x00") func templateEntTmplBytes() ([]byte, error) { return bindataRead( @@ -794,7 +794,7 @@ func templateEntTmpl() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "template/ent.tmpl", size: 4198, mode: os.FileMode(420), modTime: time.Unix(1571144482, 0)} + info := bindataFileInfo{name: "template/ent.tmpl", size: 4173, mode: os.FileMode(420), modTime: time.Unix(1571161760, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -839,7 +839,7 @@ func templateHeaderTmpl() (*asset, error) { return a, nil } -var _templateImportTmpl = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x9c\x53\x51\x6b\xdb\x30\x10\x7e\x8e\x7f\xc5\x61\xf2\xd0\x86\x55\xee\xfa\xb6\xc1\x1e\x4a\x68\x21\x30\x46\x20\x7d\x1f\x8a\x74\xb2\x8f\xd8\x92\x77\x3a\x77\x0b\xc6\xff\x7d\xc8\x71\x88\x47\x56\x0a\x7d\xf2\x77\xf7\x7d\xba\xef\xe4\x3b\xf5\x7d\xb1\xca\xd6\xa1\x3d\x32\x95\x95\xc0\xc3\xfd\xe7\x2f\x77\x2d\x63\x44\x2f\xf0\xac\x0d\xee\x43\x38\xc0\xc6\x1b\x05\x8f\x75\x0d\xa3\x28\x42\xe2\xf9\x15\xad\xca\x5e\x2a\x8a\x10\x43\xc7\x06\xc1\x04\x8b\x40\x11\x6a\x32\xe8\x23\x5a\xe8\xbc\x45\x06\xa9\x10\x1e\x5b\x6d\x2a\x84\x07\x75\x7f\x66\xc1\x85\xce\xdb\x8c\xfc\xc8\x7f\xdf\xac\x9f\x7e\xec\x9e\xc0\x51\x8d\x30\xe5\x38\x04\x01\x4b\x8c\x46\x02\x1f\x21\x38\x90\x99\x99\x30\xa2\xca\x56\xc5\x30\x64\x59\xdf\x83\x45\x47\x1e\x21\xa7\xa6\x0d\x2c\x39\x0c\x43\x76\x82\x70\x93\x2d\x72\xd7\x48\x9e\x2d\x72\x13\xbc\xe0\x9f\x11\x22\x73\xe0\x98\x50\xa3\xa5\x4a\xdf\x28\x6c\x82\x7f\x9d\x20\xf9\x72\x64\x85\x1a\xcc\xb3\x45\xdf\xdf\x41\xb1\x02\x2a\x7d\x60\x84\x12\x3d\xb2\x90\x2f\x21\x78\x28\x59\xb7\x15\xc4\x16\x0d\x39\x72\x06\x04\x9b\xb6\xd6\x82\x11\xc6\xe6\xc6\xa3\xe4\xc0\x07\x81\x1b\xfc\x05\x4b\xb5\x0e\xde\x51\xa9\xb6\xda\x1c\x74\x89\xb0\x3c\xa3\xdb\xd4\xf4\x62\x91\xf7\xfd\xb5\x68\x18\x8a\x96\xd1\x92\xd1\x92\xda\x79\x53\x34\xa6\x2f\x71\x92\x26\xff\xdf\x24\xd5\x45\xbf\x33\x15\x36\x1a\x4e\x76\x63\x29\x35\xd3\xa2\xb7\x27\x26\x05\xac\x7d\x6a\xf1\xe7\x27\x58\x3a\xf8\xfa\x0d\x96\x6a\x27\xdc\x19\x79\x26\xac\x6d\x9c\x2a\x5c\x1c\x9c\xda\x1e\xca\xad\x96\x6a\x62\xfe\x29\x7e\x5d\xfd\x1d\xab\x37\x4d\x5e\x8e\x2d\x7e\xcc\x69\x8e\xf3\x92\xa4\xea\xf6\xca\x84\xa6\x70\xd3\xa6\x93\x37\xdd\x5e\x4b\xe0\x02\xfd\xb8\x27\xef\x69\x0a\x4b\xba\x46\x23\xd3\x8e\xcc\x2e\x11\x25\x70\x9a\xc2\xf4\xd7\x4e\xc1\xff\x6e\x3b\xed\x69\xd2\x4d\x67\xd4\x66\x4c\xc5\xd9\x84\xce\xaa\xeb\x39\xcd\xf0\x6d\x7a\x09\x13\xfe\x1b\x00\x00\xff\xff\xcb\x8c\xa7\x03\xd8\x03\x00\x00") +var _templateImportTmpl = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x84\x53\x4d\x6b\xdc\x30\x10\x3d\xaf\x7f\xc5\x60\xf6\x90\x84\x46\x4e\x73\x6b\xa1\x87\x10\x12\x08\x94\x12\x48\xee\x45\x2b\x8d\xec\x21\xb6\xc6\x1d\xcd\xa6\x0d\xc6\xff\xbd\x48\xeb\xed\x6e\xd8\x96\x9e\xfc\x46\xef\xcd\x87\xe4\x37\xd3\xd4\x5c\x54\xb7\x3c\xbe\x09\xb5\x9d\xc2\xf5\xd5\xc7\x4f\x97\xa3\x60\xc2\xa8\x70\x6f\x1d\x6e\x98\x5f\xe0\x21\x3a\x03\x37\x7d\x0f\x45\x94\x20\xf3\xf2\x8a\xde\x54\xcf\x1d\x25\x48\xbc\x15\x87\xe0\xd8\x23\x50\x82\x9e\x1c\xc6\x84\x1e\xb6\xd1\xa3\x80\x76\x08\x37\xa3\x75\x1d\xc2\xb5\xb9\xda\xb3\x10\x78\x1b\x7d\x45\xb1\xf0\x5f\x1f\x6e\xef\xbe\x3d\xdd\x41\xa0\x1e\x61\x39\x13\x66\x05\x4f\x82\x4e\x59\xde\x80\x03\xe8\x51\x33\x15\x44\x53\x5d\x34\xf3\x5c\x55\xd3\x04\x1e\x03\x45\x84\x9a\x86\x91\x45\x6b\x98\xe7\x6a\x07\xe1\xac\x5a\xd5\x61\xd0\xba\x5a\xd5\x8e\xa3\xe2\xaf\x02\x51\x84\x25\x65\x34\x58\xed\xf2\x37\xa9\x38\x8e\xaf\x0b\xa4\xd8\x16\x56\x69\xc0\xba\x5a\x4d\xd3\x25\x34\x17\x40\x6d\x64\x41\x68\x31\xa2\x28\xc5\x16\x38\x42\x2b\x76\xec\x20\x8d\xe8\x28\x50\x70\xa0\x38\x8c\xbd\x55\x4c\x50\x86\x2b\xa9\x14\x20\xb2\xc2\x19\xfe\x80\xb5\xb9\xe5\x18\xa8\x35\x8f\xd6\xbd\xd8\x16\x61\xbd\x47\xe7\x79\xe8\xd5\xaa\x9e\xa6\x53\xd1\x3c\x37\xa3\xa0\x27\x67\x35\x8f\xf3\x4f\x51\x39\x3e\xc4\x59\x9a\xfb\xff\x24\xed\x0e\xfa\x27\xd7\xe1\x60\x61\xd7\xae\x94\x32\x47\x5a\x8c\x7e\xc7\xe4\x40\x6c\xcc\x23\x7e\xff\x00\xeb\x00\x9f\xbf\xc0\xda\xdc\x13\xf6\x3e\x2d\xb9\x87\xda\xc1\x3c\xbf\x8d\x68\x1e\x5f\xda\x47\xab\xdd\x42\xbf\xab\x7d\x5a\x7c\x1f\x1c\xe3\xba\x25\xed\xb6\x1b\xe3\x78\x68\xc2\x62\x3f\x8a\x6e\xbb\xb1\xca\xd2\x60\x2c\x3f\xef\x7f\x9a\xc6\x93\xed\xd1\xe9\xf2\xe3\x8e\x2e\x91\x94\x25\x3f\x4d\xb9\xca\xd3\x12\xfc\xed\xb6\x8b\x79\xb2\x6e\xc9\x31\x0f\xe5\x28\x1d\x3d\xdb\x5e\x75\xfa\x78\xef\xf1\x1f\x4f\xec\xfd\x99\x1a\xeb\x3d\x29\x71\xb4\x7d\x0d\xeb\x2c\x3b\xcf\x2e\x5e\x52\xaa\xbc\x94\x70\x73\x48\xd3\xce\x2a\x38\x1b\x61\x83\xc0\xaf\x28\x42\x1e\x7d\xde\x13\x96\xb2\x61\x0c\xd6\x7b\x38\xd4\x84\xa5\x4d\x66\xc6\x9d\x1b\x92\x29\x76\x3c\x59\x95\xf7\xa3\xcc\xf3\x34\x61\xf4\xf3\x5c\xfd\x0e\x00\x00\xff\xff\x60\x79\x63\x66\x18\x04\x00\x00") func templateImportTmplBytes() ([]byte, error) { return bindataRead( @@ -854,7 +854,7 @@ func templateImportTmpl() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "template/import.tmpl", size: 984, mode: os.FileMode(420), modTime: time.Unix(1571077131, 0)} + info := bindataFileInfo{name: "template/import.tmpl", size: 1048, mode: os.FileMode(420), modTime: time.Unix(1571161760, 0)} a := &asset{bytes: bytes, info: info} return a, nil } diff --git a/entc/gen/template/ent.tmpl b/entc/gen/template/ent.tmpl index 2ea9ddd5f..b6a400fe7 100644 --- a/entc/gen/template/ent.tmpl +++ b/entc/gen/template/ent.tmpl @@ -27,12 +27,7 @@ type {{ $.Name }} struct { {{ $e.StructField }} {{ if not $e.Unique }}[]{{ end }}*{{ $e.Type.Name }} `{{ $e.StructTag }}` {{ end -}} {{ end -}} - {{ with $.StructFields -}} - // additional struct fields defined in the schema. - {{ range $_, $f := $.StructFields -}} - {{ $f.Name }} {{ $f.Type }} {{ with $f.Tag -}}`{{ . }}`{{ end }} {{ with $f.Comment -}}// {{ . }}{{ end }} - {{ end -}} - {{ end -}} + {{ template "model/fields/additional" $ }} } {{ range $_, $storage := $.Storage }} @@ -116,4 +111,8 @@ func ({{ $receiver }} {{ $slice }}) config(cfg config) { } {{ end }} +{{/* A template for omitting struct-tags. */}} {{ define "model/omittags" }}{{ with $.TagTypes }}`{{ range $i, $t := . }}{{ if ne $i 0 }} {{ end }}{{ $t }}:"-"{{ end }}`{{ end }}{{ end }} + +{{/* A template that can be overrided in order to add additional fields to the each type.*/}} +{{ define "model/fields/additional" }}{{end}} \ No newline at end of file diff --git a/entc/gen/template/import.tmpl b/entc/gen/template/import.tmpl index 5c744a20b..9ab1977af 100644 --- a/entc/gen/template/import.tmpl +++ b/entc/gen/template/import.tmpl @@ -20,11 +20,6 @@ import ( {{- with $.Config.Schema }} "{{ . }}" {{- end }} - {{- range $_, $f := $.StructFields }} - {{- with $f.PkgPath }} - "{{ . }}" - {{- end }} - {{- end }} {{- range $_, $f := $.Fields }} {{- with $f.Type.PkgPath }} "{{ . }}" @@ -38,5 +33,9 @@ import ( "{{ $import }}" {{- end }} {{- end }} + {{ template "imports/additional" $ }} ) {{ end }} + +{{/* A template that can be overrided in order to add additional imports to packages.*/}} +{{ define "imports/additional" }}{{end}} diff --git a/entc/gen/type.go b/entc/gen/type.go index 8dcd00bcf..f329ba890 100644 --- a/entc/gen/type.go +++ b/entc/gen/type.go @@ -40,9 +40,6 @@ type ( Edges []*Edge // Indexes are the configured indexes for this type. Indexes []*Index - // StructFields are additional struct fields to be added to - // the generated entity. - StructFields []*load.StructField } // Field holds the information of a type field used for the templates. @@ -138,11 +135,10 @@ func NewType(c *Config, schema *load.Schema) (*Type, error) { Type: c.IDType, StructTag: `json:"id,omitempty"`, }, - schema: schema, - Name: schema.Name, - Fields: make([]*Field, len(schema.Fields)), - fields: make(map[string]*Field, len(schema.Fields)), - StructFields: schema.StructFields, + schema: schema, + Name: schema.Name, + Fields: make([]*Field, len(schema.Fields)), + fields: make(map[string]*Field, len(schema.Fields)), } for i, f := range schema.Fields { switch { diff --git a/entc/integration/ent/card.go b/entc/integration/ent/card.go index 77068d559..92e7d23e8 100644 --- a/entc/integration/ent/card.go +++ b/entc/integration/ent/card.go @@ -9,7 +9,6 @@ package ent import ( "bytes" "fmt" - "log" "strconv" "time" @@ -28,9 +27,9 @@ type Card struct { UpdatedAt time.Time `json:"updated_at,omitempty"` // Number holds the value of the "number" field. Number string `json:"number,omitempty"` - // additional struct fields defined in the schema. - RequestID string // RequestID. - Logger *log.Logger // Logger. + + // StaticField defined by templates. + StaticField string `json:"boring,omitempty"` } // FromRows scans the sql response data into Card. diff --git a/entc/integration/ent/schema/card.go b/entc/integration/ent/schema/card.go index 1ed01f53b..ad78de840 100644 --- a/entc/integration/ent/schema/card.go +++ b/entc/integration/ent/schema/card.go @@ -5,7 +5,6 @@ package schema import ( - "log" "time" "github.com/facebookincubator/ent" @@ -30,11 +29,6 @@ func (TimeMixin) Fields() []ent.Field { // Card holds the schema definition for the CreditCard entity. type Card struct { ent.Schema - - // additional fields to be added to the schema. - internal int // internal. - RequestID string // RequestID. - Logger *log.Logger // Logger. } func (Card) Mixin() []ent.Mixin { diff --git a/entc/integration/ent/template/fields.tmpl b/entc/integration/ent/template/fields.tmpl new file mode 100644 index 000000000..723d958b5 --- /dev/null +++ b/entc/integration/ent/template/fields.tmpl @@ -0,0 +1,8 @@ +{{/* A template for adding additional fields to specific types. */}} +{{ define "model/fields/additional" }} + {{- /* Add static fields to the "Card" entity. */}} + {{- if eq $.Name "Card" }} + // StaticField defined by templates. + StaticField string `json:"boring,omitempty"` + {{- end }} +{{ end }} diff --git a/entc/integration/generate.go b/entc/integration/generate.go index c4ab587ad..57a372e2f 100644 --- a/entc/integration/generate.go +++ b/entc/integration/generate.go @@ -4,7 +4,7 @@ package integration -//go:generate go run github.com/facebookincubator/ent/cmd/entc generate --storage=sql,gremlin --idtype string --header "// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.\n// This source code is licensed under the Apache 2.0 license found\n// in the LICENSE file in the root directory of this source tree.\n\n// Code generated (@generated) by entc, DO NOT EDIT." ./ent/schema +//go:generate go run github.com/facebookincubator/ent/cmd/entc generate --storage=sql,gremlin --idtype string --template ./ent/template --header "// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.\n// This source code is licensed under the Apache 2.0 license found\n// in the LICENSE file in the root directory of this source tree.\n\n// Code generated (@generated) by entc, DO NOT EDIT." ./ent/schema //go:generate go run github.com/facebookincubator/ent/cmd/entc generate --header "// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.\n// This source code is licensed under the Apache 2.0 license found\n// in the LICENSE file in the root directory of this source tree.\n\n// Code generated (@generated) by entc, DO NOT EDIT." ./migrate/entv1/schema //go:generate go run github.com/facebookincubator/ent/cmd/entc generate --header "// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.\n// This source code is licensed under the Apache 2.0 license found\n// in the LICENSE file in the root directory of this source tree.\n\n// Code generated (@generated) by entc, DO NOT EDIT." ./migrate/entv2/schema //go:generate go run github.com/facebookincubator/ent/cmd/entc generate --header "// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.\n// This source code is licensed under the Apache 2.0 license found\n// in the LICENSE file in the root directory of this source tree.\n\n// Code generated (@generated) by entc, DO NOT EDIT." ./template/ent/schema --template=template/ent/template diff --git a/entc/load/internal/bindata.go b/entc/load/internal/bindata.go index d8cafc96c..7938029de 100644 --- a/entc/load/internal/bindata.go +++ b/entc/load/internal/bindata.go @@ -93,12 +93,12 @@ func templateMainTmpl() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "template/main.tmpl", size: 843, mode: os.FileMode(420), modTime: time.Unix(1567360769, 0)} + info := bindataFileInfo{name: "template/main.tmpl", size: 843, mode: os.FileMode(420), modTime: time.Unix(1567330508, 0)} a := &asset{bytes: bytes, info: info} return a, nil } -var _schemaGo = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xb4\x58\xdd\x6f\xdb\x38\x12\x7f\xb6\xfe\x8a\xa9\x81\x06\x56\xe0\x95\x7b\x8b\xc3\x01\xa7\xc2\x0f\x8b\x6e\x16\xc8\xed\x35\x2d\x36\xb9\x7b\x09\x82\xac\x2c\x0d\x6d\x36\x12\xa5\x92\x74\x9a\x6c\x90\xff\x7d\x31\x43\x52\x1f\x96\x9d\x7e\x26\x2f\xb1\x86\x33\xc3\x99\xdf\x7c\x4a\x8b\x05\xbc\xa9\x9b\x7b\x2d\xd7\x1b\x0b\x3f\xbf\xfa\xc7\xbf\x7f\x6a\x34\x1a\x54\x16\x7e\xcb\x72\x5c\xd5\xf5\x0d\x9c\xaa\x3c\x81\x5f\xca\x12\x98\xc9\x00\x9d\xeb\x5b\x2c\x92\x68\xb1\x80\x8b\x8d\x34\x60\xea\xad\xce\x11\xf2\xba\x40\x90\x06\x4a\x99\xa3\x32\x58\xc0\x56\x15\xa8\xc1\x6e\x10\x7e\x69\xb2\x7c\x83\xf0\x73\xf2\x2a\x9c\x82\xa8\xb7\xaa\x20\x15\x52\x31\xcb\x7f\x4f\xdf\x9c\x9c\x9d\x9f\x80\x90\x25\x06\x9a\xae\x6b\x0b\x85\xd4\x98\xdb\x5a\xdf\x43\x2d\xc0\xf6\xee\xb3\x1a\x31\x89\xa2\x26\xcb\x6f\xb2\x35\x42\x59\x67\x45\x14\xc9\xaa\xa9\xb5\x85\x59\x34\x99\xa2\xca\xeb\x42\xaa\xf5\xe2\x83\xa9\xd5\x34\x9a\x4c\x45\x65\xe9\x9f\x46\x51\x62\x6e\xa7\x51\x34\x99\xae\xa5\xdd\x6c\x57\x49\x5e\x57\x0b\xe1\x1d\x96\x2a\xdf\xae\x32\x5b\xeb\x05\x2a\xe6\xff\x1c\xcf\xc2\xe4\x1b\xac\xb2\x05\x16\x6b\xfc\x1a\x7e\x21\xb1\x2c\xa6\x51\x1c\x11\x0a\xe7\x4c\x03\x8d\x1e\x7f\x03\x99\x02\x54\x36\xf1\x07\x76\x93\x59\xf8\x94\x19\x76\x13\x0b\x10\xba\xae\x20\x83\xbc\xae\x9a\x52\x12\xd6\x06\x35\x78\x28\x92\xc8\xde\x37\x18\x54\x1a\xab\xb7\xb9\x85\x87\x68\x72\x96\x55\x08\xe1\xcf\x58\x2d\xd5\xba\x7d\xfc\x93\x40\x4a\xa7\x2a\xab\x70\x5e\x57\xd2\x62\xd5\xd8\xfb\xe9\x9f\xd1\xe4\x4d\xad\x84\x0c\x7c\x64\x50\x8f\xe0\x85\x72\xa6\x0c\xc5\x4e\x8a\x35\x9a\xa0\xfc\xf2\xea\x98\x9e\x77\xee\x22\xbc\xcc\x50\xea\x37\x82\xc4\x74\x52\xfc\x3c\x94\x62\xd4\x76\xc4\x4e\x55\x81\x77\xe1\xba\xcb\xab\x63\x7e\x1e\x8a\x49\xc7\x32\x94\x3b\x67\x68\xfc\xa5\x97\x57\xc7\xbd\xe7\x20\xe7\xd0\xbb\xde\x73\xeb\x23\xc7\xed\x7d\x6d\xa4\x95\xb5\x82\x02\x4d\xae\xe5\x0a\x0d\x64\xc0\xdc\xd0\x84\x23\x9f\xcd\x2e\xec\x3e\x38\xad\x5c\x17\x9e\x9e\xd5\x52\x59\x80\xc5\xc2\x2b\x62\xdb\x83\x16\x47\x2a\xa5\xb1\x49\x34\x79\x2b\xef\xb0\x38\x55\x24\xb2\xaa\xeb\x12\xb8\x9c\x0a\x99\x67\x16\x0d\x48\xd1\x13\xa0\xd4\xa9\x88\xfb\x27\xa9\x9c\xa0\x54\xa7\x5e\xaf\xbb\xab\x22\xd2\xf0\x2e\x47\x72\x77\x39\x77\x1d\x36\xe3\x2c\x75\xf4\x6f\x48\x52\x27\x78\x20\x47\x77\x93\xf4\x70\x96\x9e\x2a\x51\x77\x6c\xc7\xec\x73\x72\x71\xdf\x20\x1f\x78\x31\xba\x70\x28\x76\x91\xf5\x94\x1f\xba\xcd\x66\x3b\xb9\x7d\x2e\xff\xea\xd9\x78\x2c\x95\xfd\xd7\x3f\x47\x52\x46\xfe\xb5\x73\xd9\x89\xda\x56\x6d\x49\xc0\xe5\xd5\xf0\xba\x50\x14\xc4\x34\x94\xfb\x9f\x92\x1f\xb7\xed\x85\x1c\x67\x18\x5d\xb7\x65\xa6\xa1\xe0\x99\x2c\xcb\x6c\x55\xe2\x93\x82\xca\x33\x0d\x45\xdf\x35\x94\x9c\x59\xf9\xa4\x68\xed\x99\x86\xa2\xbf\xa2\xc8\xb6\xa5\x7d\xda\xdc\xc2\x31\xed\x38\xda\x14\x99\xc5\x20\x7f\xc8\x51\x66\xba\xde\xab\xe0\xb4\xaa\xb6\xb6\xf5\xf8\x80\x02\x19\x98\x86\xb2\xff\xcf\x4a\x59\x50\x8b\xe6\x10\x71\x51\x8c\x65\x6f\x5b\xa6\xdd\x46\x52\xeb\x6c\x8d\xbf\xe3\xfd\x13\x79\x64\x1c\xd3\xf5\x0d\xde\x0f\xa5\xdb\x5e\xe0\xf2\x69\xf8\x18\xa4\x43\x37\xd9\xb9\x18\x15\x91\x6f\x9f\xf4\xd8\x04\xa6\x3d\xfd\xab\xdf\xf2\x76\xca\xfa\xce\xa2\xa6\x14\xf0\xc5\xe9\xfa\x48\x81\x42\x2a\x2c\xf6\xf6\xb4\xbe\xae\xae\xa2\xdb\x1a\xf3\xb0\x1c\xaa\xaa\xb6\xf2\x87\x7c\xe3\x5a\xa7\xb2\xde\xa7\x70\x54\xdd\x6f\xea\xaa\xa2\x55\x66\x87\x31\x77\xe4\x9d\x18\xdc\xac\xdf\x67\x76\xb3\xcb\xdb\xdc\xac\xaf\x9b\xcc\x6e\x76\x2a\xb9\x5a\x61\x41\x0d\xce\x03\x1e\x6a\xd7\x93\xf7\xc0\xcc\xe3\x6f\xdc\x36\x99\xfc\x0d\x5d\x93\xe5\xf6\x34\xcd\x1f\x06\xdd\x97\x06\xed\x0f\x14\xee\xf2\x21\x9f\x46\x71\x3d\xbe\xfd\x0f\x14\x3e\xc5\xdd\x36\xd0\x31\x1f\x68\x78\x43\x78\xf7\xb5\xb8\x53\x75\x8b\xda\xe0\x2e\xab\x74\xe4\xdd\xeb\x3f\x6e\xa5\x1e\x45\x4d\x7b\xf2\x9e\xa8\xb9\x01\x39\x0e\x9b\xa3\x7f\x43\xdc\x9c\x60\x17\x38\xef\x69\x5b\xb7\x4f\x78\xea\x17\xaa\x76\x6c\x7c\x76\x89\xda\xe5\x3c\xb8\xc2\x9c\xe1\x27\x8e\x47\xae\x91\xf7\x86\x4c\x05\x8f\x48\xb9\x73\x8b\x7f\xb9\x15\xa7\xb1\xb5\x4e\x22\xb1\x55\x79\x90\x9c\x61\x01\xc7\xc4\x91\xfc\xda\x72\xc4\x3e\xc8\x0f\xd1\x44\x21\xa4\x4b\x38\xa2\xc7\x87\x68\x42\xa9\x95\xba\x34\xc0\x22\xb9\xc8\xd6\x73\xa2\xdd\x37\x98\xb6\x34\xca\xc6\x68\xc2\x59\xdd\x12\xe9\x81\x88\x0e\xb1\xd4\x11\xdd\x03\x91\x7d\x1e\xa4\x4c\xf6\x0f\x44\x0f\x31\x4f\x89\x1e\x1e\xdc\x81\xf0\xfa\xf9\x40\x78\xfd\x8f\xd1\x44\x0a\xd0\x28\xc8\x64\x77\xf2\x9a\x1f\x5f\x2c\x41\xc9\x92\xdc\x99\x28\x24\x32\x2c\x5b\xf7\x35\x8a\x98\x45\x35\xda\xad\x56\xa0\xb0\x43\xd6\x75\xc3\x31\xb4\xae\x9b\x3e\x8d\x2d\xcb\xce\x44\x11\xf6\x99\x3e\xba\x33\xb7\x1b\xcf\x01\xb5\xa6\xe7\x87\x68\x62\xd8\xe8\x23\xa6\x3f\x0c\xf0\xe3\x3f\xd1\x81\x48\x4b\xd1\xf0\x84\x28\xf3\x41\x70\xc2\x89\x8f\x10\x2f\x2f\x69\xff\x80\x29\xc3\x90\x84\xa3\x2e\x2e\x61\x05\x49\x3b\x1b\xc2\xbe\x11\x4d\xda\x2d\xa3\x3b\x0d\x14\xb6\x32\x0c\xea\xb4\xb5\xb2\x1d\xdd\xd1\xa4\x37\x73\x53\x7f\xdc\x51\xe8\xbc\x1b\xe8\x7c\x5e\xa2\x9a\x89\x22\xe9\xa8\x31\x31\xf9\x65\x23\xed\x6c\x0f\xeb\x87\x0b\x38\xfb\xd7\x5f\x4b\x52\xf6\x6f\xb0\xa8\x74\x9c\xed\x34\x6e\x2d\x6e\x29\x6d\x6e\x19\xc1\x60\xc3\xb2\x4b\xa8\x90\x36\xb2\x9c\x83\xa8\x6c\x72\x42\x21\x15\xb3\x69\x25\x8d\xa1\x02\xe6\xd6\x21\x49\x48\xd4\xda\x67\xce\xcb\x8f\xd3\x39\xe9\xa2\x90\xc6\xad\x6e\x5a\x4c\xd3\x25\xf0\x46\x4a\xde\xd2\xa6\x1a\xbf\x76\xf4\x17\x4b\x78\xc5\xd7\x19\xc1\x74\x58\xc2\x11\x1d\xf4\x33\xd7\x88\x39\x99\xe1\xd3\xf7\x6d\xa6\xcd\x26\x2b\xfd\x7b\x24\xbf\x4e\x23\x4f\xfd\xde\x7b\xa9\x54\x16\x35\xbd\xe6\xd2\xaf\x1a\x32\xf8\xcf\xf9\xbb\x33\x12\xe6\xee\x98\x67\x0a\x56\x94\xdc\x24\x5a\x38\x16\x52\xe0\x85\xeb\xd5\x07\xcc\xad\xff\xe7\xf3\x7e\x70\xe9\xcc\x84\xbb\xa9\xe9\xfa\x9b\x62\x98\xad\xe0\xf2\x6a\x75\x6f\x91\xd3\xbf\x5f\x02\x5c\x01\x4e\x96\x5c\x75\xef\xaa\x69\x58\x53\xdc\xe3\x2c\xee\x77\x17\x7a\x5f\xd2\x98\xdb\x99\xff\x2c\xc0\xed\xe7\x9d\xf0\x37\xc7\x31\x23\xcc\x22\x0e\x63\xba\x30\x5d\x82\x49\xa8\x90\x5d\xab\x0d\xbc\xaf\xf9\xf0\xc5\xfe\xc0\xa2\xd6\xac\xc2\x35\xec\x56\x4d\x26\x90\x3b\x7b\xd0\xd1\xde\x71\x40\x4d\x3f\x3f\x3c\x38\x2f\x3f\xa6\xf0\xf2\x96\xd2\xc1\x15\x38\x89\xbb\x94\xa0\x74\xb9\x9e\x03\xe7\x84\xce\xd4\x1a\xb9\xd7\x18\x97\x05\x89\x9b\x28\x4b\xc8\x9a\x06\x55\x31\xf3\x84\x79\xd7\xd5\x7b\x0d\x67\x16\xc7\x3e\xcb\xfc\x7b\x74\xdf\x01\xff\xfa\xfd\x9c\x2e\xc8\xe2\xae\x73\xc2\xdb\xc0\x8a\xfd\x81\x2c\xee\x06\xd6\xb2\x83\xe1\xb3\x40\xcf\xc5\xd3\x60\xfe\x11\xff\x22\x0d\x6e\xb2\xa6\xc0\x3a\x1c\x04\x44\x75\xa1\x4d\x99\xea\x7e\x33\x39\x34\x3b\x22\x77\x6d\xee\x71\xd0\xff\x69\xde\x26\x3e\x8f\x67\x26\xf6\xd5\xd4\xe5\x0b\xff\x34\xbe\x90\x6d\xed\xb3\xd3\x0f\x83\x7e\xa6\xfb\x92\x98\x19\x38\x76\x39\x1d\xc3\x28\xeb\x76\x6b\x83\x8b\x81\xa0\xe1\x97\xf7\x41\x9c\xf8\xa5\xff\x0b\xa2\xf4\xd5\x01\x92\x73\xa8\x7a\xf1\x71\x9f\x0d\x48\xa1\xdf\x39\xfa\x46\x78\xe3\xab\x3b\x8a\xd1\xd8\x84\xaf\xb7\x81\x8c\x60\x2b\x3e\xcc\x41\x74\x46\xb8\xab\x9d\x4e\x6a\x6b\xde\x84\x6e\xac\x0e\xb3\x9b\xd8\xf6\x58\xf3\x0d\xe6\xb0\x3d\xd4\x64\xdb\xf7\xb8\x25\x1c\x85\xdf\x4e\x29\xe7\x9e\x9f\x39\x1f\x38\xad\xc2\x97\x1c\x26\x5a\xed\xb2\x6a\xd2\xfb\x4c\x93\x82\x9c\x77\xca\x7d\x46\xf6\x33\xdb\xe7\x28\x18\xe1\x31\xa1\xd8\x1c\x84\xff\x79\x92\x60\x3f\xfc\x5f\x86\xfe\x0f\x4b\x85\x43\xc8\x07\x18\x99\xe7\x73\x00\xf6\x96\xb9\x76\x1c\x76\xf0\xc1\x27\x9d\x35\xa6\xff\x02\xec\xe9\x99\x2a\x5c\xf6\x07\x42\x85\x76\x53\x17\xf0\x49\xda\x0d\x68\xcc\xeb\x5b\xd4\x54\xf1\xa8\xcc\x56\x23\xa8\x1a\x9a\x4c\xc9\xdc\xd0\xeb\x74\xe5\x1a\x86\x54\x6b\x5f\xf6\xbd\x70\x89\xa2\x1b\xb4\x0f\xe0\x89\x31\x5c\x5e\x75\xdf\xde\x1e\x63\x98\x89\xb0\xf9\xb7\xe4\xdd\x01\x59\xa0\x40\x0d\xa4\x7e\x16\xbb\xfe\x29\xe0\x96\xa3\xe6\x8c\x9b\xc5\xaf\xe1\x76\x10\x04\x92\x5f\x0e\x62\xf0\xf2\x22\x78\xe7\x8c\xf7\xa1\x10\xc5\x1c\x6e\xb9\x00\x44\xc0\x96\xb0\x73\xb9\x48\x1d\x39\x84\xb3\x48\x82\x03\xf3\x1d\x74\xdd\x44\x1a\x81\xeb\xc8\xdf\x0b\x65\x7f\xcc\x8e\x16\x0a\x37\x17\x1d\x70\xc4\xf8\x1c\xb8\x0d\xbc\x19\x40\xe7\x60\x43\x3f\x8f\xf7\xa2\xd6\x17\x1e\x03\x17\x26\xdd\x08\xba\x70\xf0\xbd\xe0\x0d\x47\xfc\x08\xbe\x30\x91\x1d\x80\xcc\xfc\x8c\x08\x06\xa7\xf6\x60\x28\xdb\x91\xff\x14\x8a\xc1\x9b\x11\x8e\xdc\x6f\xc7\x28\x3a\xf2\xf7\x62\xd8\x1f\xbf\x23\x04\xdd\xcc\x74\xf8\xbd\xed\x26\xf7\xb3\xe0\xe7\xdc\xd9\x83\x9e\x33\xe2\x69\xec\x9c\x17\x1d\x72\xec\x5e\xbb\x44\x5b\xe8\xaf\xd1\xf1\xe0\x89\xac\xa2\x41\x61\x93\xdf\xa5\x2a\x66\x31\xbd\x02\x85\xf3\xf7\x96\x77\x96\x89\x85\x25\xd8\xe4\xa4\xc4\x6a\x36\xe8\xc2\x36\x7a\x8c\xfe\x0e\x00\x00\xff\xff\xc1\xa3\x85\x8a\xac\x1c\x00\x00") +var _schemaGo = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xb4\x58\x5f\x8f\xdb\x38\x0e\x7f\x8e\x3f\x05\x1b\xa0\x85\x3d\xc8\x3a\xbd\xc5\xe1\x80\x73\x91\x87\x45\x77\x16\x98\xdb\xeb\x74\xb1\x9d\xbb\x97\xa2\xe8\x3a\x36\x95\xa8\xb5\x65\x57\x52\xd2\xc9\x0e\xe6\xbb\x1f\x48\x49\xfe\x13\x67\xd2\x6d\x7b\x33\x2f\x63\x53\x24\x45\xfe\xf8\x13\x69\x65\xb9\x84\x97\x4d\x7b\xd0\x72\xb3\xb5\xf0\xe3\xf3\xbf\xfd\xf3\x87\x56\xa3\x41\x65\xe1\x97\xbc\xc0\x75\xd3\x7c\x84\x2b\x55\xa4\xf0\x53\x55\x01\x2b\x19\xa0\x75\xbd\xc7\x32\x8d\x96\x4b\xb8\xd9\x4a\x03\xa6\xd9\xe9\x02\xa1\x68\x4a\x04\x69\xa0\x92\x05\x2a\x83\x25\xec\x54\x89\x1a\xec\x16\xe1\xa7\x36\x2f\xb6\x08\x3f\xa6\xcf\xc3\x2a\x88\x66\xa7\x4a\x72\x21\x15\xab\xfc\xfb\xea\xe5\xe5\xf5\x9b\x4b\x10\xb2\xc2\x20\xd3\x4d\x63\xa1\x94\x1a\x0b\xdb\xe8\x03\x34\x02\xec\x60\x3f\xab\x11\xd3\x28\x6a\xf3\xe2\x63\xbe\x41\xa8\x9a\xbc\x8c\x22\x59\xb7\x8d\xb6\x10\x47\xb3\x39\xaa\xa2\x29\xa5\xda\x2c\x3f\x98\x46\xcd\xa3\xd9\x5c\xd4\x96\xfe\x69\x14\x15\x16\x76\x1e\x45\xb3\xf9\x46\xda\xed\x6e\x9d\x16\x4d\xbd\x14\x3e\x61\xa9\x8a\xdd\x3a\xb7\x8d\x5e\xa2\x62\xfd\x2f\xe9\x2c\x4d\xb1\xc5\x3a\x5f\x62\xb9\xc1\xaf\xd1\x17\x12\xab\x72\x1e\x25\x11\xa1\xf0\x86\x65\xa0\xd1\xe3\x6f\x20\x57\x80\xca\xa6\x7e\xc1\x6e\x73\x0b\x9f\x73\xc3\x69\x62\x09\x42\x37\x35\xe4\x50\x34\x75\x5b\x49\xc2\xda\xa0\x06\x0f\x45\x1a\xd9\x43\x8b\xc1\xa5\xb1\x7a\x57\x58\xb8\x8b\x66\xd7\x79\x8d\x00\x40\x12\xa9\x36\xf4\x04\x7f\x10\x36\xd9\x5c\xe5\x35\x2e\x9a\x5a\x5a\xac\x5b\x7b\x98\xff\x11\xcd\x5e\x36\x4a\xc8\x0d\x70\x08\xfe\xd9\xeb\x16\xfc\x36\xd6\xbe\x2c\x37\x68\x00\xe0\xed\xbb\x0b\x7a\x1c\x78\x26\x50\xcc\x58\xf9\x17\xca\xdb\xb0\x32\x3f\xf6\xca\x8c\xc8\x91\xf6\x95\x2a\xf1\x16\x0d\x69\xf3\x63\xaf\x2d\xdd\xca\x48\xfd\x9e\xc1\xfc\xad\x31\xd2\xca\x46\x41\x89\xa6\xd0\x72\x8d\x06\x72\x60\xe7\xd0\x86\x25\x4f\x31\x57\x0b\x8f\x58\x67\xd7\x63\x16\xf6\x04\x00\xa9\x2c\xc0\x72\xe9\x1d\xf1\xee\xc1\x8b\x13\x55\xd2\xd8\x34\x9a\xbd\x92\xb7\x58\x5e\x29\x32\x59\x37\x4d\x05\xcc\xf1\x52\x16\xb9\x45\x03\x52\x0c\x0c\xa8\x9e\x35\x69\xff\x20\x95\x33\x94\xea\xca\xfb\x75\x7b\xd5\x24\x1a\xef\xe5\x44\x6e\x2f\x97\xae\x43\x71\x4a\x1d\x27\xff\x06\xe6\x38\xc3\x29\x71\xdc\xdf\x80\x3e\xe7\x39\x74\xa5\x44\xd3\xab\x5d\x70\xce\xe9\xcd\xa1\x45\x5e\xf0\x66\xb4\xe1\xd8\xec\x26\x1f\x38\x7f\x68\x37\x9b\x1f\x51\xf0\x8d\xfc\x73\x10\xe3\x85\x54\xf6\x1f\x7f\x9f\x58\x19\xf9\xe7\xd1\x66\x97\x6a\x57\x9b\x4e\xed\xed\xbb\xf1\x76\x81\xc4\xa4\x34\xb6\xfb\x8f\x92\x9f\x76\xdd\x86\x5c\x67\x98\x6c\xb7\x63\xa5\xb1\xe1\xb5\xac\xaa\x7c\x5d\xe1\x59\x43\xe5\x95\xc6\xa6\xaf\x5b\x22\x67\x5e\x9d\x35\x6d\xbc\xd2\xd8\xf4\x67\x14\xf9\xae\xb2\xe7\xc3\x2d\x9d\xd2\x51\xa2\x6d\x99\x5b\x0c\xf6\x0f\x25\xca\x4a\xef\x4f\x3a\xb8\xaa\xeb\x9d\xed\x32\x7e\xc0\x81\x0c\x4a\x63\xdb\xff\xe6\x95\x2c\xa9\x6f\x72\x89\xf8\x50\x4c\x6d\xf7\x9d\xd2\x11\x23\x6c\xa3\xf3\x0d\xfe\x8a\x87\x33\x3c\x32\x4e\xe9\xfd\x47\x3c\x8c\xad\xbb\x5e\xe0\xf8\x34\x7e\x0d\xd6\xa1\x9b\x1c\x6d\x8c\x8a\xc4\xfb\xb3\x19\x9b\xa0\x74\xa2\x7f\x71\x0f\x9d\x9e\x67\x16\x7f\xc3\x71\x66\xbb\x13\xa7\xd9\x43\xf2\xe0\xf9\xa5\xa3\x7a\x42\xf1\xcc\x89\x3d\x52\x3c\x3e\xa3\xbf\xa3\x70\x9b\x8f\xf5\x34\x8a\xf7\xd3\xdd\x7f\x47\xe1\xb1\x77\x23\xa5\x57\x7e\xe0\x24\x7a\xa0\xcf\x9c\xbd\x2b\xb5\x47\x6d\xf0\x58\x55\x3a\xf1\xf1\xf6\x9f\x76\x52\x63\x79\xa4\xab\xbd\xf8\x44\xd5\x5c\xe7\x9e\x96\xcd\xc9\xbf\xa1\x6e\xce\xb0\x2f\x9c\xcf\xb4\x23\xd4\x99\x4c\xfd\x40\xee\xfa\xd9\x17\xa7\xf1\xb1\xe6\x89\x51\xec\xb2\xbc\xc6\xcf\x5c\x8f\x42\x23\x0f\xb4\x5c\x85\x8c\xc8\xb9\x4b\x8b\x9f\xdc\xec\x6d\x6d\xa3\xd3\x48\xec\x54\x11\x2c\x63\x2c\xe1\x82\x34\xd2\x9f\x3b\x8d\xc4\x17\xf9\x2e\x9a\x29\x84\x6c\x05\xcf\xe8\xf5\x2e\x9a\x11\xb5\x32\x47\x03\x2c\xd3\x9b\x7c\xb3\x20\xd9\xa1\xc5\xac\x93\x11\x1b\xa3\x19\xb3\xba\x13\xd2\x0b\x09\x1d\x62\x99\x13\xba\x17\x12\x7b\x1e\x64\x2c\xf6\x2f\x24\x0f\x35\xcf\x48\x1e\x5e\xdc\x82\xf0\xfe\x79\x41\x78\xff\xf7\xd1\x4c\x0a\xd0\x28\x28\x64\xb7\xf2\x82\x5f\x9f\xac\x40\xc9\x8a\xd2\x99\x29\x24\x31\xac\xba\xf4\x35\x8a\x84\x4d\x35\xda\x9d\x56\xa0\xb0\x47\xd6\x0d\xde\x29\xb4\xee\x73\xe1\x3c\xb6\x6c\x1b\x8b\x32\x0c\xda\x21\xba\xb1\xfb\xd2\x5a\x00\x6a\x4d\xef\x77\xd1\xcc\x70\xd0\xcf\x58\x7e\x37\xc2\x8f\xff\x44\x0f\x22\x4d\xeb\xf1\x0a\x49\x16\xa3\xe2\x84\x15\x5f\x21\x9e\xaa\xd9\x70\x81\x25\xe3\x92\x84\xa5\xbe\x2e\x61\x36\x66\x7d\x0c\x61\x10\x46\xb3\x6e\xfc\xf5\xab\x41\xc2\x51\x86\x09\x92\x75\x51\x76\x33\x25\x9a\x0d\x86\x41\xe6\x97\x7b\x09\xad\xf7\x93\x86\xd7\x2b\x54\xb1\x28\xd3\x5e\x9a\x90\x92\x9f\x82\x59\x1f\x7b\x98\x8b\xae\xe0\x9c\xdf\x70\x5e\x66\x9c\xdf\x68\x82\xf6\x9a\xdd\x98\xe8\x22\xee\x24\x1d\xb7\x8c\x60\xb0\x61\xd5\x13\x2a\xd0\x46\x56\x0b\x10\xb5\x4d\x2f\xa9\xa4\x22\x9e\xd7\xd2\x18\x3a\xc0\xdc\x3a\x24\x19\x89\x46\x7b\xe6\x3c\xfd\x34\x5f\x90\x2f\x2a\x69\xd2\xf9\xa6\x2f\xa6\x6c\x05\xfc\xa9\x44\xd9\xd2\x27\x54\xf2\xc2\xc9\x9f\xac\xe0\x39\x6f\x67\x04\xcb\x61\x05\xcf\x68\x61\xc8\x5c\x23\x16\x14\x86\xa7\xef\xab\x5c\x9b\x6d\x5e\xf9\x5b\x07\x5f\xbe\x90\x3f\x58\x07\xb7\x18\xa9\x2c\x6a\xba\x14\xd1\x53\x03\x39\xfc\xeb\xcd\xeb\x6b\x32\xe6\xee\x58\xe4\x0a\xd6\x44\x6e\x32\x2d\x9d\x0a\x39\xf0\xc6\xcd\xfa\x03\x16\xd6\xff\xf3\xbc\x1f\x6d\x1a\x9b\xb0\x37\x35\x5d\xbf\x53\x02\xf1\x1a\xde\xbe\x5b\x1f\x2c\x32\xfd\x87\x47\x80\x4f\x80\xb3\xa5\x54\xdd\x3d\x27\x0b\x77\x02\xf7\x1a\x27\xc3\xee\x42\x1f\xf2\x74\x1d\x8d\xfd\x25\x92\xdb\xcf\x6b\xe1\x77\x4e\x12\x46\x98\x4d\x1c\xc6\xb4\x61\xb6\x02\x93\xd2\x41\x76\xad\x36\xe8\xbe\xe0\xc5\x27\xa7\x0b\x8b\x5a\xb3\x0b\xd7\xb0\x3b\x37\xb9\x40\xee\xec\xc1\x47\xb7\xc7\x03\x6e\x86\xfc\xf0\xe0\x3c\xfd\x94\xc1\xd3\x3d\xd1\xc1\x1d\x70\x32\x77\x94\x20\xba\xbc\x5f\x00\x73\x42\xe7\x6a\x83\xdc\x6b\x8c\x63\x41\xea\x26\xca\x0a\xf2\xb6\x45\x55\xc6\x5e\xb0\xe8\xbb\xfa\xa0\xe1\xc4\x49\xe2\x59\xe6\xaf\x68\xc3\x04\xfc\x85\xee\x31\x53\x90\xe5\x6d\x9f\x84\x8f\x81\x1d\xfb\x05\x59\xde\x8e\xa2\xe5\x04\xc3\x45\x73\x90\xe2\x55\x08\xff\x19\x3f\x91\x07\x37\x59\x33\x60\x1f\x0e\x02\x92\xba\xd2\x66\x2c\x75\xcf\x2c\x0e\xcd\x8e\xc4\x7d\x9b\xbb\x1f\xf5\x7f\x9a\xb7\xa9\xe7\x71\x6c\x12\x7f\x9a\x7a\xbe\xf0\xa3\xf1\x07\xd9\x36\x9e\x9d\x7e\x18\x0c\x99\xee\x8f\x44\x6c\xe0\xc2\x71\x3a\x81\x09\xeb\x8e\xcf\x06\x1f\x06\x82\x86\x6f\x95\xa3\x3a\xf1\x6d\xf4\x2f\x54\xe9\xab\x0b\x24\x17\x50\x0f\xea\xe3\xee\xb3\xe4\xd0\x7f\x73\x0c\x83\xf0\xc1\xd7\xb7\x54\xa3\x69\x08\x5f\x1f\x03\x05\xc1\x51\x7c\x58\x80\xe8\x83\x70\x5b\x3b\x9f\xd4\xd6\x7c\x08\xfd\x58\x1d\xb3\x9b\xd4\x4e\x44\xf3\x0d\xe1\x70\x3c\xd4\x64\xbb\x0b\xc6\x0a\x9e\x85\x67\xe7\x94\xb9\xe7\x67\xce\x07\xa6\x55\xf8\x89\x81\x85\x56\x3b\x56\xcd\x06\xbf\x1f\x64\x20\x17\xbd\x73\xcf\xc8\x21\xb3\x3d\x47\xc1\x08\x8f\x09\xd5\xe6\x41\xf8\x1f\x87\x04\xa7\xe1\xff\x6b\xe8\xff\xdf\xa8\xf0\x10\xf2\x01\x46\xd6\xf9\x12\x80\x83\x8f\xb9\x6e\x1c\xf6\xf0\xc1\x67\x9d\xb7\x66\xf8\x6b\x93\x97\xe7\xaa\x74\xec\x0f\x82\x1a\xed\xb6\x29\xe1\xb3\xb4\x5b\xd0\x58\x34\x7b\xd4\x74\xe2\x51\x99\x9d\x46\x50\x0d\xb4\xb9\x92\x85\x01\xa9\xa0\x76\x0d\x43\xaa\x8d\x3f\xf6\x83\x72\x89\xb2\x1f\xb4\x77\xe0\x85\x09\xbc\x7d\xd7\xff\x28\x74\x9f\x40\x2c\xc2\x97\x7f\x27\x3e\x1e\x90\x25\x0a\xd4\x40\xee\xe3\xc4\xf5\x4f\x01\x7b\xae\x9a\x0b\x2e\x4e\x5e\xc0\x7e\x54\x04\xb2\x5f\x8d\x6a\xf0\xf4\x26\x64\xe7\x82\xf7\xa5\x10\xe5\x02\xf6\x7c\x00\x44\xc0\x96\xb0\x73\x5c\xa4\x8e\x1c\xca\x59\xa6\x21\x81\xc5\x11\xba\x6e\x22\x4d\xc0\x75\xe2\xef\x85\x72\x38\x66\x27\x1f\x14\x6e\x2e\x3a\xe0\x48\xf1\x31\x70\x1b\x65\x33\x82\xce\xc1\x86\x7e\x1e\x9f\x44\x6d\x68\x3c\x05\x2e\x4c\xba\x09\x74\x61\xe1\x7b\xc1\x1b\x8f\xf8\x09\x7c\xb2\xfb\x49\xb7\xbb\x1e\x3f\x22\x82\x21\xa9\x13\x18\xca\x6e\xe4\x9f\x43\x31\x64\x33\xc1\x91\xfb\xed\x14\x45\x27\xfe\x5e\x0c\x87\xe3\x77\x82\xa0\x9b\x99\x0e\xbf\x57\xfd\xe4\x7e\x14\xfc\x5c\x3a\x27\xd0\x73\x41\x9c\xc7\xce\x65\xd1\x23\xc7\xe9\x75\x1f\xd1\x16\x86\x9f\xd1\xc9\xe8\x8d\xa2\xa2\x41\x61\xd3\x5f\xa5\x2a\xe3\x84\xae\x40\x61\xfd\x37\xcb\xdf\x2c\x33\x0b\x2b\xb0\xe9\x65\x85\x75\x3c\xea\xc2\x36\xba\x8f\xfe\x17\x00\x00\xff\xff\x9f\xab\xe4\xff\xda\x1a\x00\x00") func schemaGoBytes() ([]byte, error) { return bindataRead( @@ -113,7 +113,7 @@ func schemaGo() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "schema.go", size: 7340, mode: os.FileMode(420), modTime: time.Unix(1570473114, 0)} + info := bindataFileInfo{name: "schema.go", size: 6874, mode: os.FileMode(420), modTime: time.Unix(1571161760, 0)} a := &asset{bytes: bytes, info: info} return a, nil } diff --git a/entc/load/load.go b/entc/load/load.go index f53e0df26..83651eeff 100644 --- a/entc/load/load.go +++ b/entc/load/load.go @@ -48,8 +48,6 @@ type Config struct { // Names are the schema names to run the code generation on. // Empty means all schemas in the directory. Names []string - // schema types and their exported struct fields. - fields map[string][]*StructField } // Build loads the schemas package and build the Go plugin with this info. @@ -88,7 +86,6 @@ func (c *Config) Load() (*SchemaSpec, error) { if err := json.Unmarshal([]byte(line), schema); err != nil { return nil, errors.WithMessagef(err, "unmarshal schema %s", line) } - schema.StructFields = c.fields[schema.Name] spec.Schemas = append(spec.Schemas, schema) } return spec, nil @@ -121,13 +118,9 @@ func (c *Config) load() (string, error) { if !ok { return "", fmt.Errorf("invalid declaration %T for %s", k.Obj.Decl, k.Name) } - specType, ok := spec.Type.(*ast.StructType) - if !ok { + if _, ok := spec.Type.(*ast.StructType); !ok { return "", fmt.Errorf("invalid spec type %T for %s", spec.Type, k.Name) } - if err := c.structFields(k.Name, v, specType); err != nil { - return "", err - } names = append(names, k.Name) } if len(c.Names) == 0 { @@ -137,64 +130,6 @@ func (c *Config) load() (string, error) { return pkg.PkgPath, err } -// structFields loads schema type fields if exist. -func (c *Config) structFields(name string, obj types.Object, spec *ast.StructType) (err error) { - typ, ok := obj.(*types.TypeName) - if !ok { - return - } - st, ok := typ.Type().Underlying().(*types.Struct) - if !ok { - return - } - if c.fields == nil { - c.fields = make(map[string][]*StructField) - } - for i := 0; i < st.NumFields(); i++ { - f := st.Field(i) - // skip non-exported fields, because they - // cannot be used outside the package. - if !f.Exported() { - continue - } - sf := &StructField{ - Tag: st.Tag(i), - Name: f.Name(), - Embedded: f.Embedded(), - Comment: strings.TrimSpace(spec.Fields.List[i].Comment.Text()), - Type: types.TypeString(f.Type(), func(p *types.Package) string { - return p.Name() - }), - } - switch typ := indirectType(f.Type()).(type) { - case *types.Named: - sf.PkgPath = typ.Obj().Pkg().Path() - // skip fields used for schema definition. - if sf.PkgPath == entInterface.PkgPath() { - continue - } - c.fields[name] = append(c.fields[name], sf) - default: - if f.Embedded() { - return fmt.Errorf("field %s for schema %q cannot be embbeded", f.Type(), name) - } - c.fields[name] = append(c.fields[name], sf) - } - } - return -} - -// indirectType returns the type at the end of indirection. -func indirectType(typ types.Type) types.Type { - for { - ptr, ok := typ.(*types.Pointer) - if !ok { - return typ - } - typ = ptr.Elem() - } -} - //go:generate go run github.com/go-bindata/go-bindata/go-bindata -pkg=internal -o=internal/bindata.go ./template/... schema.go var buildTmpl = templates() diff --git a/entc/load/load_test.go b/entc/load/load_test.go index f730165df..bb3dc1666 100644 --- a/entc/load/load_test.go +++ b/entc/load/load_test.go @@ -22,12 +22,6 @@ func TestLoad(t *testing.T) { require.Equal(t, "Group", spec.Schemas[0].Name, "ordered alphabetically") require.Equal(t, "Tag", spec.Schemas[1].Name) require.Equal(t, "User", spec.Schemas[2].Name) - - require.Len(t, spec.Schemas[2].StructFields, 3) - fields := spec.Schemas[2].StructFields - require.Equal(t, &StructField{Tag: "json:\"tenant,omitempty\"", Name: "Tenant", Type: "string"}, fields[0]) - require.Equal(t, &StructField{Name: "Logger", Type: "*log.Logger", PkgPath: "log", Comment: "Comment."}, fields[1]) - require.Equal(t, &StructField{Name: "Mutex", Type: "sync.Mutex", PkgPath: "sync", Embedded: true}, fields[2]) } func TestLoadWrongPath(t *testing.T) { diff --git a/entc/load/schema.go b/entc/load/schema.go index 7165267f2..3c30f68d2 100644 --- a/entc/load/schema.go +++ b/entc/load/schema.go @@ -16,12 +16,11 @@ import ( // Schema represents an ent.Schema that was loaded from a complied user package. type Schema struct { - Name string `json:"name,omitempty"` - Config ent.Config `json:"config,omitempty"` - Edges []*Edge `json:"edges,omitempty"` - Fields []*Field `json:"fields,omitempty"` - Indexes []*Index `json:"indexes,omitempty"` - StructFields []*StructField `json:"struct_fields,omitempty"` + Name string `json:"name,omitempty"` + Config ent.Config `json:"config,omitempty"` + Edges []*Edge `json:"edges,omitempty"` + Fields []*Field `json:"fields,omitempty"` + Indexes []*Index `json:"indexes,omitempty"` } // Position describes a field position in the schema. @@ -50,16 +49,6 @@ type Field struct { Sensitive bool `json:"sensitive,omitempty"` } -// StructField represents an external struct field defined in the schema. -type StructField struct { - Tag string `json:"tag,omitempty"` - Name string `json:"name,omitempty"` - Type string `json:"type,omitempty"` - Comment string `json:"comment,omitempty"` - PkgPath string `json:"pkg_path,omitempty"` - Embedded bool `json:"embedded,omitempty"` -} - // Edge represents an ent.Edge that was loaded from a complied user package. type Edge struct { Name string `json:"name,omitempty"` diff --git a/entc/load/testdata/valid/schema.go b/entc/load/testdata/valid/schema.go index 5c5c832a2..a66d3b3b9 100644 --- a/entc/load/testdata/valid/schema.go +++ b/entc/load/testdata/valid/schema.go @@ -5,9 +5,6 @@ package valid import ( - "log" - "sync" - "github.com/facebookincubator/ent" "github.com/facebookincubator/ent/schema/field" ) @@ -15,13 +12,6 @@ import ( // User holds the user schema. type User struct { ent.Schema - - // add additional struct-only - // fields to the generated model. - Tenant string `json:"tenant,omitempty"` - Logger *log.Logger // Comment. - sync.Mutex - Ignored ent.Interface // Ignored comment. } func (User) Fields() []ent.Field {