From dd3cdc147dec9b76149ecec80570bfc676650a4f Mon Sep 17 00:00:00 2001 From: Ariel Mashraki <7413593+a8m@users.noreply.github.com> Date: Tue, 28 Jul 2020 10:14:21 +0300 Subject: [PATCH] entc/gen: correctly handle custom storage-key for id fields (#643) Fixed #621 --- entc/gen/internal/bindata.go | 8 ++++---- entc/gen/template/dialect/sql/meta.tmpl | 8 +++++++- entc/gen/template/dialect/sql/predicate.tmpl | 6 ++++-- entc/gen/type.go | 14 ++++++++++++++ entc/integration/customid/customid_test.go | 2 ++ entc/integration/customid/ent/group/group.go | 2 ++ entc/integration/customid/ent/group/where.go | 4 ++-- entc/integration/customid/ent/pet/pet.go | 2 ++ entc/integration/customid/ent/pet/where.go | 4 ++-- entc/integration/customid/ent/user/user.go | 4 ++++ entc/integration/customid/ent/user/where.go | 8 ++++---- entc/integration/migrate/entv1/car/car.go | 2 ++ entc/integration/migrate/entv1/car/where.go | 4 ++-- entc/integration/migrate/entv1/user/user.go | 2 ++ entc/integration/migrate/entv1/user/where.go | 4 ++-- entc/integration/migrate/entv2/car/car.go | 2 ++ entc/integration/migrate/entv2/car/where.go | 4 ++-- entc/integration/migrate/entv2/pet/pet.go | 2 ++ entc/integration/migrate/entv2/pet/where.go | 4 ++-- entc/integration/migrate/entv2/user/user.go | 4 ++++ entc/integration/migrate/entv2/user/where.go | 8 ++++---- 21 files changed, 71 insertions(+), 27 deletions(-) diff --git a/entc/gen/internal/bindata.go b/entc/gen/internal/bindata.go index 648abc1e9..654103599 100644 --- a/entc/gen/internal/bindata.go +++ b/entc/gen/internal/bindata.go @@ -726,7 +726,7 @@ func templateDialectSqlGroupTmpl() (*asset, error) { return a, nil } -var _templateDialectSqlMetaTmpl = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xa4\x54\x4d\x6f\xeb\x36\x10\x3c\x4b\xbf\x62\x61\xf8\xf0\x5e\x90\x50\x79\xbe\xb5\x80\x0f\x0f\x6e\x02\x18\x89\x83\xb4\xc9\xad\x28\x0a\x5a\x5c\xc9\x84\x69\xd2\x21\x69\x3b\x82\xa0\xff\x5e\x90\xd4\x07\xe5\xda\x41\x81\xde\x24\x2e\x39\x3b\x33\xdc\x61\x5d\x67\x37\xe9\x42\xed\x2b\xcd\xcb\x8d\x85\xd9\xfd\x8f\x5f\xee\xf6\x1a\x0d\x4a\x0b\x8f\x34\xc7\xb5\x52\x5b\x58\xca\x9c\xc0\x4f\x21\xc0\x6f\x32\xe0\xea\xfa\x88\x8c\xa4\xef\x1b\x6e\xc0\xa8\x83\xce\x11\x72\xc5\x10\xb8\x01\xc1\x73\x94\x06\x19\x1c\x24\x43\x0d\x76\x83\xf0\x73\x4f\xf3\x0d\xc2\x8c\xdc\x77\x55\x28\xd4\x41\xb2\x94\x4b\x5f\x7f\x5e\x2e\x1e\x5e\xde\x1e\xa0\xe0\x02\xa1\x5d\xd3\x4a\x59\x60\x5c\x63\x6e\x95\xae\x40\x15\x60\xa3\x66\x56\x23\x92\xf4\x26\x6b\x9a\x34\x75\x1a\x20\x57\xd2\x58\x2a\xad\x01\x89\xc8\x90\x41\xa1\x34\x98\x0f\x01\x8c\x53\x81\xb9\x35\x04\xfc\xee\xba\x06\x86\x05\x97\x08\x93\xb6\x92\x99\x0f\x91\xed\xd0\xd2\xac\xc7\x98\x40\xd3\xa4\x49\x96\xc1\x3b\x5d\x0b\x84\x8d\x12\xcc\x78\x52\xd6\xff\x4b\xba\xc3\x40\x08\xa1\xae\x41\xa8\x13\x6a\x98\x92\x17\xb7\xdc\x34\x9d\x00\x46\x2d\x5d\x53\x83\x24\x4d\x02\xcc\x1c\x26\x75\x0d\x53\x12\xfe\x9a\x66\x92\x26\x75\x7d\x07\x9a\xca\x12\x61\xfa\xf7\x2d\x4c\x11\x7e\x9d\xc3\x94\x3c\xb0\x12\x8d\xa7\xe0\x38\xb8\x33\x18\x0e\x2d\x5a\x82\xbe\x4b\xcc\xc8\x7d\x0d\x2c\xc3\x89\x8e\x8e\x46\x41\x2d\x57\x32\x43\x56\x3a\x32\xbe\x29\x2f\xdc\x96\xd5\x6c\xe5\x76\xbc\x6f\x10\xf6\x9a\xef\xa8\xae\x60\x8b\x15\x30\xcc\x05\xd5\xc8\x60\x8d\x42\x9d\x48\x5d\x03\x4a\x16\xf8\x5c\x21\xd3\x4a\x43\xf2\x07\x8a\x58\x5f\xd7\x4b\x62\xaf\xdb\x1d\xaf\xf6\xd8\xef\x4a\x93\x48\xe5\x52\x1e\x51\x1b\xfc\x5a\xac\xb7\xdf\x5d\xef\xa0\xd5\x23\x76\x82\x51\x5a\x6e\x2b\xd2\x02\x2f\x2d\xe0\x27\x37\xd6\x84\x7b\xe1\x06\xf6\x34\xdf\xd2\xd2\x0f\x9a\xd2\x7e\x44\x15\xd0\xa3\xe2\x0c\x72\xae\xf3\x83\xa0\x1a\x18\xee\x51\x32\x94\x79\x05\x27\x6e\x37\xbe\xd3\x24\x6a\xf5\xda\x42\x34\xcd\xa4\x83\xf3\xfd\xbe\x56\x31\x1f\x61\x9c\xdb\x14\x79\x1c\x3c\x53\x76\xb8\xa3\x91\x4b\x0b\x25\x0e\x3b\x79\xd5\x9f\xdc\x97\x81\xa1\x54\x96\xcb\xf2\xbf\x8c\x44\x72\x0d\x78\x74\xb1\xa1\x7c\x81\x72\xf4\x3d\x0c\x4b\xc8\xe5\x91\x6a\xee\x58\xfd\x9f\x5c\xf6\x18\x7d\x2e\x03\x13\xd3\xce\x3c\x15\x02\xde\x7e\x7f\x6e\x85\x1b\xdf\xe2\x42\x2e\x0b\x8e\x82\x19\x92\x26\x47\xaa\x7b\x84\x39\xfc\xf9\x97\xb1\x9a\xcb\xb2\x6e\xc7\x9b\x2c\x7f\x23\x91\x05\xb7\xad\xd6\x36\xa6\x45\x88\xe8\xa3\xc7\x6a\x2f\xc6\x9d\x2a\x2e\x9d\xe9\xfc\xf1\x16\x65\x37\xee\x56\xa9\xac\xba\xa7\x03\x7d\xcc\xd5\x49\x1a\xa0\x8e\x33\xf2\x52\xde\xb9\xfc\x79\x43\x1c\xaa\x9f\xbd\x29\x79\x0c\xb5\x27\xac\x86\x57\x21\x5e\x1b\x92\xef\x5c\x88\x90\xdc\x22\xb5\x40\x35\xba\x36\x2e\xd0\x55\x3f\x0d\xbd\x2d\xd6\x0d\x63\x9a\x78\x57\x62\xd4\xb1\x33\x23\x0f\xb6\xce\x04\xd2\xaa\x4f\xfc\x84\x14\xdb\xe0\x49\x07\x3b\xb9\xed\x0e\xf5\x73\x1d\x34\x75\xd3\x11\xe9\x7b\x39\xec\xfa\x29\x77\x2c\xbe\x9d\xf5\xbb\xfc\x34\xfe\xfb\x21\xf3\x8b\x43\x4c\x5e\x9f\xe2\x49\xa6\x92\x5d\x8b\xcf\xcc\x3b\x74\x1e\x20\x33\x4a\x50\x8f\x1d\x3f\x94\xe3\x47\xe8\x3c\x5d\xf0\x6d\x35\x5b\x7d\x27\xe1\xe4\x25\x4a\x91\xc3\xce\x43\x2e\x19\x7e\x8e\xb3\x66\xe0\xde\x7b\x09\x57\xeb\x3f\x5c\x7d\xb0\xa3\x37\x7b\xfc\xf7\x3d\xb6\xbe\xff\xfa\x27\x00\x00\xff\xff\x4c\x3d\xd2\x31\xfd\x07\x00\x00") +var _templateDialectSqlMetaTmpl = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xa4\x54\x4d\x6f\xdb\x38\x10\x3d\x5b\xbf\x62\x20\xf8\xd0\x06\x09\x95\xfa\xb6\x0b\xe4\x50\xa4\x09\x60\xa4\x09\xba\x9b\xdc\x16\x8b\x05\x23\x8e\x64\xc2\x34\xa9\x92\xb4\x5d\x41\xd0\x7f\x5f\xf0\x43\x12\xe5\xb5\xbb\x87\xde\x24\xce\xf0\xcd\xcc\xe3\x7b\xd3\x75\xc5\x55\x76\xaf\x9a\x56\xf3\x7a\x63\x61\x75\xfb\xe9\xb7\x9b\x46\xa3\x41\x69\xe1\x91\x96\xf8\xae\xd4\x16\xd6\xb2\x24\xf0\x59\x08\xf0\x49\x06\x5c\x5c\x1f\x90\x91\xec\x6d\xc3\x0d\x18\xb5\xd7\x25\x42\xa9\x18\x02\x37\x20\x78\x89\xd2\x20\x83\xbd\x64\xa8\xc1\x6e\x10\x3e\x37\xb4\xdc\x20\xac\xc8\xed\x10\x85\x4a\xed\x25\xcb\xb8\xf4\xf1\xaf\xeb\xfb\x87\x97\xd7\x07\xa8\xb8\x40\x88\x67\x5a\x29\x0b\x8c\x6b\x2c\xad\xd2\x2d\xa8\x0a\x6c\x52\xcc\x6a\x44\x92\x5d\x15\x7d\x9f\x65\x6e\x06\x28\x95\x34\x96\x4a\x6b\x40\x22\x32\x64\x50\x29\x0d\xe6\xbb\x00\xc6\xa9\xc0\xd2\x1a\x02\x3e\xbb\xeb\x80\x61\xc5\x25\x42\x1e\x23\x85\xf9\x2e\x8a\x1d\x5a\x5a\x8c\x18\x39\xf4\x7d\xb6\xe8\xba\x1b\xd0\x54\xd6\x08\x4b\x0b\xbf\xdf\xc1\x92\xfc\x89\x82\x5a\x64\x6f\x6d\x83\xc6\xa7\xf8\x1c\x5e\x81\x74\x39\x64\xfd\x85\xbc\x5a\xa5\x69\x8d\x4f\xd8\xc2\xf2\xe4\xdf\xe7\x2f\x8a\x02\xba\xce\x25\xbf\xd0\x1d\x42\xdf\x3f\x72\x14\x6c\xfd\x05\x36\x4a\x30\xe3\x07\x37\x56\x73\x59\x03\x43\xa9\xac\xfb\x70\x67\x9c\x41\xe5\x12\x03\x0d\x38\x87\x20\x0e\xf7\x2c\xe8\x1d\xe4\xe1\xfc\xb4\x93\x3c\xb6\x8e\x92\x8d\xa3\x0e\xdf\x45\x01\x6f\xf4\x5d\x60\xd2\x92\xf5\xff\xd2\x81\x4f\x0d\x08\x75\x44\x0d\xcb\xa1\xe6\xf0\x6e\x8c\x5a\xfa\x4e\x0d\x92\x6c\x11\x60\x62\x13\x24\xfc\xf9\xda\x09\xb3\x18\x98\x7d\x60\xf5\x40\x69\x64\x08\xc3\x85\xfb\xf8\x26\xbe\x42\xda\x8d\xfb\x9a\x3a\x0c\x37\x86\x56\xb4\x7b\x27\xae\x64\x81\xac\x76\x8d\x0c\xcf\xb4\x44\xf2\xbc\x7a\x76\x19\x6f\x1b\x84\x46\xf3\x1d\xd5\x2d\x6c\xb1\x05\x86\xa5\xa0\x1a\x19\xbc\xa3\x50\x47\xd2\x75\x23\x1d\x8b\x0b\xcd\xc4\xb1\xd0\x89\x22\x9d\x2d\x95\x44\x3c\x77\xd7\xdb\x06\xc7\xac\x44\x07\x48\xd6\xf2\x80\xda\xe0\xcf\x87\xf5\xd4\x3b\x45\x4f\xb3\x7a\xc4\x61\x60\x94\x96\xdb\x96\x44\xe0\xb5\x05\xfc\xc1\x8d\x35\xe1\x4d\xb8\x81\x86\x96\x5b\x5a\x7b\x6f\x29\xed\x5d\xa9\x80\x1e\x14\x67\x50\x72\x5d\xee\x05\xd5\xc0\xb0\x41\xc9\x50\x96\x2d\x1c\xb9\xdd\xf8\x4a\x79\x52\xea\x5b\x84\xe8\xfb\x7c\x80\x1b\x85\x77\x79\x8a\xbb\x19\xc6\x29\x4d\x09\xc7\x81\x33\x65\xa7\x37\x9a\xb1\x74\xaf\xc4\x7e\x27\x2f\xf2\x53\xfa\xf0\xdc\x33\xff\x23\x89\xc5\x25\xe0\xd9\xc3\x86\xf0\xcf\x1d\x33\x89\x25\xac\xa2\x03\xd5\xdc\x75\xf5\x2b\xab\x68\xc4\xc8\x07\x4f\x86\x4e\x4c\xd4\x3c\x15\x02\x5e\xff\xf8\x1a\x07\x37\xbe\xc4\x19\x4f\xfa\xa5\x61\x48\xb6\x38\x50\x3d\x22\xdc\xc1\x5f\x7f\x87\x25\xd3\x45\x79\xbb\xfd\x90\x50\x70\x1d\x67\x8d\x16\xad\x82\x45\xfd\x52\x89\x1e\xf5\xb7\xaa\x73\x77\x06\x7e\x3c\x45\xc5\x95\x7b\x55\x2a\xdb\x61\x6d\xa0\xb7\xb9\x3a\x4a\x03\xd4\xf5\x8c\xbc\x96\x37\xce\x7f\x9e\x10\x87\xea\xb5\xb7\x24\x8f\x21\xf6\x84\xed\xb4\x15\xd2\xb3\xc9\xf9\x8e\x85\x04\xc9\x1d\x52\x0b\x54\xa3\x2b\xe3\x0c\xdd\x8e\x6a\x18\x69\xb1\x4e\x8c\xd9\xc2\xb3\x92\xa2\xce\x99\x99\x71\xb0\x75\x24\x90\x38\xfd\xc2\x2b\xa4\xda\x06\x4e\x06\xd8\xfc\x7a\xb8\x34\xea\x3a\xcc\x34\xa8\x23\x99\xef\x65\xbf\x1b\x55\xee\xba\xf8\x70\x52\xef\x9f\xeb\x73\xab\xf1\xbf\x8b\xcc\x1f\x4e\x36\xf9\xf6\x94\x2a\x99\x4a\x76\xc9\x3e\x2b\xcf\xd0\xa9\x81\xcc\xcc\x41\x23\x76\xba\x28\xe7\x4b\xe8\xd4\x5d\xf0\xe1\x79\xf5\xfc\x91\x84\x9b\xe7\x5a\x4a\x18\x76\x1c\x72\xc9\xf0\xc7\xdc\x6b\x06\x6e\x3d\x97\x70\x31\xfe\xc9\xc5\x27\x3a\x46\xb2\xe7\x7f\x1f\x53\xea\xc7\xaf\x7f\x03\x00\x00\xff\xff\xf8\xdf\x20\x6b\xf0\x08\x00\x00") func templateDialectSqlMetaTmplBytes() ([]byte, error) { return bindataRead( @@ -741,7 +741,7 @@ func templateDialectSqlMetaTmpl() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "template/dialect/sql/meta.tmpl", size: 2045, mode: os.FileMode(420), modTime: time.Unix(1, 0)} + info := bindataFileInfo{name: "template/dialect/sql/meta.tmpl", size: 2288, mode: os.FileMode(420), modTime: time.Unix(1, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -766,7 +766,7 @@ func templateDialectSqlOpenTmpl() (*asset, error) { return a, nil } -var _templateDialectSqlPredicateTmpl = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xec\x56\xdf\x4f\xeb\x36\x14\x7e\x4e\xfe\x8a\x23\x84\x34\x17\x15\x17\x78\xdb\x24\x26\xa1\xae\xd5\xaa\xdd\x5b\xd8\x8a\x76\x1f\x10\x9a\x4c\x7c\x92\x58\xd7\xd8\xc6\x76\x5b\x55\x51\xfe\xf7\xc9\x4e\x9a\xa6\xc0\x80\x0b\x9b\xb4\x87\xfb\xd6\xfa\xfc\xfe\xbe\xef\x38\xae\xaa\xd1\x51\x3a\xd6\x66\x63\x45\x51\x7a\x38\x3b\x39\xfd\xf1\xd8\x58\x74\xa8\x3c\x4c\x59\x86\x77\x5a\x7f\x85\x99\xca\x28\x5c\x48\x09\xd1\xc9\x41\xb0\xdb\x15\x72\x9a\x5e\x97\xc2\x81\xd3\x4b\x9b\x21\x64\x9a\x23\x08\x07\x52\x64\xa8\x1c\x72\x58\x2a\x8e\x16\x7c\x89\x70\x61\x58\x56\x22\x9c\xd1\x93\xad\x15\x72\xbd\x54\x3c\x15\x2a\xda\x3f\xcd\xc6\x93\xf9\x62\x02\xb9\x90\x08\xed\x99\xd5\xda\x03\x17\x16\x33\xaf\xed\x06\x74\x0e\xbe\x57\xcc\x5b\x44\x9a\x1e\x8d\xea\x3a\x4d\xab\x0a\x38\xe6\x42\x21\x1c\x70\xc1\x24\x66\x7e\xe4\x1e\xe4\xc8\x58\xe4\x22\x63\x1e\x47\x82\x1f\xc0\x71\x5d\xa7\x49\xbe\x54\x19\x71\x70\xe4\x1e\x24\x5d\xa0\x8c\xa9\x07\x50\xa5\x49\xe2\xe8\x97\x12\x2d\x92\x60\x99\xfc\x4e\x1c\x1d\x93\xaa\x82\x43\x3a\xfb\x85\x8e\xb5\x72\x9e\x29\x0f\x75\x3d\x18\x82\xe0\x83\x41\x9a\xd4\x69\x55\x1d\x03\x2a\x0e\x6f\x6c\x60\xa4\x8d\x6b\x9b\x08\x91\x87\xda\xc0\x4f\xe7\x70\x48\x17\x99\x36\x48\x2f\x4d\xcf\xc4\x6c\xd1\xb7\x5d\xd8\xa2\x67\x74\x5e\x5b\x56\x60\xdf\x61\xd1\x1e\xbd\x32\x61\x08\x17\x79\xa8\x4c\xff\x64\x56\x30\x2e\xb2\xd0\x7c\x92\x24\xa3\x51\x30\x28\xed\x81\xd9\x62\x79\x8f\xca\x3b\x58\xa3\x45\x30\x56\xaf\x04\x47\x3e\x04\x66\x4c\x18\x36\xf0\x32\xbd\xf8\xb4\x98\x40\xd6\x82\xe2\x86\x6d\x06\x27\x54\x86\xb0\x46\xc8\x98\xfa\xc1\x87\x00\xb9\x81\x83\xd9\x1c\xc8\xe0\x80\x42\xd4\xc9\x5a\x48\x09\xf7\xec\x2b\x36\x4c\x76\xf0\x40\xce\xa4\xdb\xd0\x90\x48\xe4\x20\x51\x45\xe8\x03\x0c\x75\x3d\x80\xf3\x73\x38\x89\x03\xec\x93\x34\x65\xd2\x21\x09\x5c\x24\x49\x62\xd1\x2f\xad\x0a\x3f\xe3\x40\xab\x00\x4f\x28\x44\x6e\x6e\x85\xf2\x68\x73\x96\x61\x55\x0f\x1f\xe7\x8e\xc1\xb9\xb6\x20\x42\x80\x65\xaa\x40\x58\xb5\xb5\x56\x37\xe2\x16\xce\x61\xe7\x7d\x23\x6e\xb7\x05\x7a\xdc\xef\x37\x55\x55\x90\x31\x29\x3b\x9a\xe8\xa5\x19\x87\xad\x08\x74\xd7\xf5\x0b\xaa\xaa\xaa\x67\xb8\x59\x51\x1a\x32\xa2\x74\x08\x75\x2d\x78\xf8\x1d\xab\xbe\x43\x81\xb9\x40\xc9\xfb\x02\xcc\xfb\x12\x9a\x06\xeb\x1b\x24\xf8\xcd\xfb\x93\x3f\x9d\xb3\x07\xfe\x7b\x66\x78\xbc\x48\x2f\xce\xf1\x7d\xcb\xfe\xbb\x2d\xfb\xe8\x12\xec\x4b\xa3\x59\x80\x80\x4e\x80\x6e\x2e\x64\x8b\x5c\x5f\x32\xcf\x2e\x49\xbb\x23\xb1\x91\x8f\x2c\x08\xf2\x02\x47\x25\xdb\xd3\xd6\x9e\x00\x26\xfc\x75\xf6\x9d\xc7\xa8\x38\xf7\x20\x0b\xcb\x4c\x49\xe7\xb8\x5e\x78\x34\x24\x80\xd6\x1d\x4e\xad\xbe\x27\xd7\xec\x4e\x62\x33\xdd\x93\xeb\x60\xcf\xfb\x5a\x47\xb8\x90\xc6\x88\x9e\xdf\x5b\x82\x43\xd3\xa4\xfb\xd7\xe4\xf9\x03\x25\xbd\xde\x18\xec\x52\x20\x9d\xb9\x99\x5a\xa1\x75\xfd\xb3\x27\xe5\xa2\x06\xb6\xfa\x46\xfa\xf9\xec\x73\x03\x47\x73\x1c\x8e\xae\x7e\xeb\xf9\x53\x4a\xbb\x88\x78\x85\x3d\x72\x1e\x6b\xb9\xbc\x57\xbd\x80\x9d\xb7\xe2\x5b\xe7\x38\x4e\x50\x5f\x37\xc3\xaf\xcc\xcd\x51\x14\xe5\x9d\xb6\x8e\xb8\x21\x04\xc8\xdf\xcf\xf6\x5a\xf8\xf2\x7f\xca\x78\x58\x07\x84\xc3\x86\x87\x48\xc8\xc6\xb4\xac\x34\x52\x0f\xbc\x35\xac\x3d\xa6\x6a\xf7\xd1\x88\x96\x6e\x2d\xbe\x2b\xe6\x8b\xf0\xe5\x56\x35\x43\xf8\x67\x5a\xe3\xab\xe0\xaf\x21\x98\xdd\xc3\x20\x88\xc7\xb5\x57\xa4\x21\x6e\xb0\xbd\x07\xeb\x6f\x57\x1f\x53\x6f\x78\x90\x9e\x46\x59\xd1\xb1\xd4\x0a\xc9\x80\x2e\xd0\x5f\x11\x25\x64\xa8\xfb\x7c\x73\x31\x77\xdb\xa1\x21\xee\x34\x78\xee\xdd\xcd\xa7\xf4\x8a\xbc\xe3\x66\xd4\xf6\xc3\xcd\x8a\x17\x9b\x15\x39\x08\xf8\x79\xf7\xfd\x39\xa5\x97\x96\x74\xf8\xfe\xab\xb3\x28\xed\x5f\x1d\xc6\x10\x47\xe7\xda\x3f\x4d\xff\x77\x00\x00\x00\xff\xff\xef\xa4\xbd\xbb\x2c\x0d\x00\x00") +var _templateDialectSqlPredicateTmpl = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xec\x56\x4d\x6f\xe3\x36\x10\x3d\x4b\xbf\x62\x60\x04\xa8\x1c\x38\x74\x9c\x5b\x0b\xb8\x40\xe0\xb5\x51\x63\x77\x9d\xb4\x0e\xba\x87\x20\x28\x18\x71\x64\x11\x4b\x93\x0c\x49\xdb\x30\x04\xfd\xf7\x82\x94\x2c\xcb\x71\x9a\x64\x93\xf6\xd4\xdc\x24\xce\xe7\x7b\xf3\x46\x54\x51\xf4\x4f\xe3\x91\xd2\x5b\xc3\x17\xb9\x83\x8b\xf3\xc1\xcf\x67\xda\xa0\x45\xe9\x60\x42\x53\xbc\x57\xea\x3b\x4c\x65\x4a\xe0\x52\x08\x08\x4e\x16\xbc\xdd\xac\x91\x91\xf8\x26\xe7\x16\xac\x5a\x99\x14\x21\x55\x0c\x81\x5b\x10\x3c\x45\x69\x91\xc1\x4a\x32\x34\xe0\x72\x84\x4b\x4d\xd3\x1c\xe1\x82\x9c\xef\xac\x90\xa9\x95\x64\x31\x97\xc1\xfe\x65\x3a\x1a\xcf\xe6\x63\xc8\xb8\x40\xa8\xcf\x8c\x52\x0e\x18\x37\x98\x3a\x65\xb6\xa0\x32\x70\xad\x62\xce\x20\x92\xf8\xb4\x5f\x96\x71\x5c\x14\xc0\x30\xe3\x12\xa1\xc3\x38\x15\x98\xba\xbe\x7d\x10\x7d\x6d\x90\xf1\x94\x3a\xec\x73\xd6\x81\xb3\xb2\x8c\xa3\x6c\x25\xd3\xc4\xc2\xa9\x7d\x10\x64\x8e\x22\xa4\xee\x42\x11\x47\x91\x25\xdf\x72\x34\x98\x78\xcb\xf8\xf7\xc4\x92\x51\x52\x14\x70\x42\xa6\x9f\xc8\x48\x49\xeb\xa8\x74\x50\x96\xdd\x1e\x70\xd6\xed\xc6\x51\x19\x17\xc5\x19\xa0\x64\xf0\xca\x06\xfa\x4a\xdb\xba\x09\x1f\x79\xa2\x34\xfc\x32\x84\x13\x32\x4f\x95\x46\x72\xa5\x5b\x26\x6a\x16\x6d\xdb\xa5\x59\xb4\x8c\xd6\x29\x43\x17\xd8\x76\x98\xd7\x47\x2f\x20\xf4\xe1\x3c\xf3\x95\xc9\x9f\xd4\x70\xca\x78\xea\x9b\x8f\xa2\xa8\xdf\xf7\x06\xa9\x1c\x50\xb3\x58\x2d\x51\x3a\x0b\x1b\x34\x08\xda\xa8\x35\x67\xc8\x7a\x40\xb5\xf6\x60\xfd\x5c\x26\x97\x5f\xe6\x63\x48\x6b\x52\x6c\xaf\xce\x60\xb9\x4c\x11\x36\x08\x29\x95\x3f\x39\x1f\x20\xb6\xd0\x99\xce\x20\xe9\x76\x08\x04\x9d\x6c\xb8\x10\xb0\xa4\xdf\xb1\x9a\x64\x43\x0f\x64\x54\xd8\x2d\xf1\x89\x78\x06\x02\x65\xa0\xde\xd3\x50\x96\x5d\x18\x0e\xe1\x3c\x00\x38\x1c\xd2\x84\x0a\x8b\x89\x9f\x45\x14\x45\x06\xdd\xca\x48\xff\x18\x00\xad\x3d\x3d\xbe\x50\x72\x7b\xc7\xa5\x43\x93\xd1\x14\x8b\xb2\xf7\x38\x77\x08\xce\x94\x01\xee\x03\x0c\x95\x0b\x84\x75\x5d\x6b\x7d\xcb\xef\x60\x08\x7b\xef\x5b\x7e\xb7\x2b\xd0\x9a\xfd\x61\x53\x45\x01\x29\x15\xa2\x19\x13\xb9\xd2\x23\xbf\x15\x7e\xdc\x65\xf9\x8c\xaa\x8a\xe2\x89\xd9\xac\x09\xf1\x19\x51\x58\x84\xb2\xe4\xcc\x3f\x87\xaa\x6f\x50\x60\xc6\x51\xb0\xb6\x00\xb3\xb6\x84\x26\xde\xfa\x0a\x09\xfe\xf0\xfe\x64\xc7\x38\x5b\xe4\xbf\x05\xc3\xe3\x45\x7a\x16\xc7\xc7\x96\xfd\x77\x5b\xf6\xde\x25\x38\x94\x46\xb5\x00\x9e\x1d\x4f\xdd\x8c\x8b\x9a\xb9\xb6\x64\x9e\x5c\x92\x7a\x47\x42\x23\xef\x59\x10\x64\x0b\xec\xe7\xf4\x40\x5b\x07\x02\x18\xb3\xdd\xf4\x83\xcd\x60\xc6\x59\x65\x3f\xdc\xe6\x1a\x09\xc2\x09\x92\x9b\xad\x46\x6f\xae\xc5\xf3\x19\xb7\x95\x7b\xeb\x3d\x04\xd4\xd9\x86\xa0\x0d\x97\xae\x89\x9c\xd1\x25\x42\x27\x88\x7a\xfa\xa9\xb3\x07\xf8\xd2\x2e\x3a\x0c\xba\xb7\x0f\x62\x61\xa8\xce\xc9\x0c\x37\x73\x87\x3a\xf1\xa3\x6b\x0e\x27\x46\x2d\x93\x1b\x7a\x2f\xb0\xe2\xf8\xe8\xa3\x74\xe0\x7d\xa3\xc2\xd0\x90\x84\x88\x96\x5f\x15\x5c\xf5\x7f\x14\xe5\x39\x4b\x9a\xb7\x2a\xc1\x1f\x28\x02\xba\x26\x16\xc9\xd4\x4e\xe5\x1a\x8d\x6d\x9f\x1d\xd5\x09\x12\xdc\xad\x17\x92\xaf\x17\x5f\x2b\x1e\xaa\x63\x7f\x74\xfd\xb9\xe5\x4f\x08\x69\x22\xc2\x17\xf4\x91\xf3\x48\x89\xd5\x52\xb6\x02\xf6\xde\x3b\x86\xa3\x28\xc0\xf1\xe2\x6f\x30\xfc\x46\xed\x0c\xf9\x22\xbf\x57\xc6\x26\xb6\x07\x9e\xeb\xb7\x8b\x6d\xc3\x5d\xfe\x21\xb8\x67\x04\x57\x03\xab\xd4\xd0\xb4\x59\xbd\x55\x40\x90\xd4\xda\x79\x2c\x98\xfd\xcd\x19\x2c\xcd\xb7\xe1\x7f\x2c\xd8\x6f\xdc\xe5\x3b\xd1\xf6\xe0\x9f\xe7\x19\xfe\x89\xfe\xea\x81\xde\xff\x16\x79\xed\xda\xfa\x82\xd0\x89\xed\xee\x6e\x81\xf2\xc7\xc5\x4f\xe5\x2b\x7e\xc7\x07\x41\x4f\x64\x24\x94\xc4\xa4\x4b\xe6\xe8\xae\x13\xc9\x85\xaf\xfb\x74\x73\x21\x77\xdd\xa1\x4e\xec\xc0\x7b\x1e\xdc\x4c\x03\x72\x9d\xbc\xe1\x5e\x50\xe6\xdd\xcd\xf2\x67\x9b\xe5\x19\x70\xf8\x75\x7f\xfb\x0e\xc8\x95\x49\x1a\x7e\xff\x55\x2c\x52\xb9\x17\xc1\xe8\xc4\x92\x99\x72\xc7\xe9\xff\x0e\x00\x00\xff\xff\xea\x12\x8c\xa7\x2a\x0e\x00\x00") func templateDialectSqlPredicateTmplBytes() ([]byte, error) { return bindataRead( @@ -781,7 +781,7 @@ func templateDialectSqlPredicateTmpl() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "template/dialect/sql/predicate.tmpl", size: 3372, mode: os.FileMode(420), modTime: time.Unix(1, 0)} + info := bindataFileInfo{name: "template/dialect/sql/predicate.tmpl", size: 3626, mode: os.FileMode(420), modTime: time.Unix(1, 0)} a := &asset{bytes: bytes, info: info} return a, nil } diff --git a/entc/gen/template/dialect/sql/meta.tmpl b/entc/gen/template/dialect/sql/meta.tmpl index 710e0dec2..0b7735df8 100644 --- a/entc/gen/template/dialect/sql/meta.tmpl +++ b/entc/gen/template/dialect/sql/meta.tmpl @@ -6,9 +6,15 @@ in the LICENSE file in the root directory of this source tree. {{/* constants needed for sql dialects. */}} {{ define "dialect/sql/meta/constants" }} + {{- range $t := $.RelatedTypes }} + {{- if ne $t.ID.StorageKey $.ID.StorageKey }} + // {{ $t.Name }}FieldID holds the string denoting the id field of the {{ $t.Name }}. + {{ $t.Name }}FieldID = "{{ $t.ID.StorageKey }}" + {{- end }} + {{- end }} // Table holds the table name of the {{ lower $.Name }} in the database. Table = "{{ $.Table }}" - {{- range $_, $e := $.Edges }} + {{- range $e := $.Edges }} // {{ $e.TableConstant }} is the table the holds the {{ $e.Name }} relation/edge. {{- if $e.M2M }} The primary key declared below.{{ end }} {{ $e.TableConstant }} = "{{ $e.Rel.Table }}" diff --git a/entc/gen/template/dialect/sql/predicate.tmpl b/entc/gen/template/dialect/sql/predicate.tmpl index 5e92be849..48663d9d3 100644 --- a/entc/gen/template/dialect/sql/predicate.tmpl +++ b/entc/gen/template/dialect/sql/predicate.tmpl @@ -59,10 +59,11 @@ in the LICENSE file in the root directory of this source tree. {{ define "dialect/sql/predicate/edge/has" -}} {{- $e := $.Scope.Edge -}} + {{- $refid := $.ID.Constant }}{{ if ne $e.Type.ID.StorageKey $.ID.StorageKey }}{{ $refid = print $e.Type.Name "FieldID" }}{{ end -}} func(s *sql.Selector) { step := sqlgraph.NewStep( sqlgraph.From(Table, {{ $.ID.Constant }}), - sqlgraph.To({{ $e.TableConstant }}, {{ $.ID.Constant }}), + sqlgraph.To({{ $e.TableConstant }}, {{ $refid }}), sqlgraph.Edge(sqlgraph.{{ $e.Rel.Type }}, {{ $e.IsInverse }}, {{ $e.TableConstant }}, {{- if $e.M2M -}} {{ $e.PKConstant }}... @@ -77,10 +78,11 @@ in the LICENSE file in the root directory of this source tree. {{ define "dialect/sql/predicate/edge/haswith" -}} {{- $e := $.Scope.Edge -}} + {{- $refid := $.ID.Constant }}{{ if ne $e.Type.ID.StorageKey $.ID.StorageKey }}{{ $refid = print $e.Type.Name "FieldID" }}{{ end -}} func(s *sql.Selector) { step := sqlgraph.NewStep( sqlgraph.From(Table, {{ $.ID.Constant }}), - sqlgraph.To({{ if ne $.Table $e.Type.Table }}{{ $e.InverseTableConstant }}{{ else }}Table{{ end }}, {{ $.ID.Constant }}), + sqlgraph.To({{ if ne $.Table $e.Type.Table }}{{ $e.InverseTableConstant }}{{ else }}Table{{ end }}, {{ $refid }}), sqlgraph.Edge(sqlgraph.{{ $e.Rel.Type }}, {{ $e.IsInverse }}, {{ $e.TableConstant }}, {{- if $e.M2M -}} {{ $e.PKConstant }}... diff --git a/entc/gen/type.go b/entc/gen/type.go index 0c15a8608..960ee19a8 100644 --- a/entc/gen/type.go +++ b/entc/gen/type.go @@ -564,6 +564,20 @@ func (t Type) HasPolicy() bool { return false } +// RelatedTypes returns all the types (nodes) that +// are related (with edges) to this type. +func (t Type) RelatedTypes() []*Type { + seen := make(map[string]struct{}) + related := make([]*Type, 0, len(t.Edges)) + for _, e := range t.Edges { + if _, ok := seen[e.Type.Name]; !ok { + related = append(related, e.Type) + seen[e.Type.Name] = struct{}{} + } + } + return related +} + // check checks the schema type. func (t *Type) check() error { pkg := t.Package() diff --git a/entc/integration/customid/customid_test.go b/entc/integration/customid/customid_test.go index 5154e2456..b2c5398dc 100644 --- a/entc/integration/customid/customid_test.go +++ b/entc/integration/customid/customid_test.go @@ -107,6 +107,8 @@ func CustomID(t *testing.T, client *ent.Client) { require.Equal(t, pedro.ID, a8m.QueryPets().OnlyIDX(ctx)) xabi := client.Pet.Create().SetID("xabi").AddFriends(pedro).SetBestFriend(pedro).SaveX(ctx) require.Equal(t, "xabi", xabi.ID) + pedro = client.Pet.Query().Where(pet.HasOwnerWith(user.ID(a8m.ID))).OnlyX(ctx) + require.Equal(t, "pedro", pedro.ID) pets := client.Pet.Query().WithFriends().WithBestFriend().Order(ent.Asc(pet.FieldID)).AllX(ctx) require.Len(t, pets, 2) diff --git a/entc/integration/customid/ent/group/group.go b/entc/integration/customid/ent/group/group.go index fc574d3ad..7c61742c5 100644 --- a/entc/integration/customid/ent/group/group.go +++ b/entc/integration/customid/ent/group/group.go @@ -15,6 +15,8 @@ const ( // EdgeUsers holds the string denoting the users edge name in mutations. EdgeUsers = "users" + // UserFieldID holds the string denoting the id field of the User. + UserFieldID = "oid" // Table holds the table name of the group in the database. Table = "groups" // UsersTable is the table the holds the users relation/edge. The primary key declared below. diff --git a/entc/integration/customid/ent/group/where.go b/entc/integration/customid/ent/group/where.go index ba30d784c..98156690b 100644 --- a/entc/integration/customid/ent/group/where.go +++ b/entc/integration/customid/ent/group/where.go @@ -100,7 +100,7 @@ func HasUsers() predicate.Group { return predicate.Group(func(s *sql.Selector) { step := sqlgraph.NewStep( sqlgraph.From(Table, FieldID), - sqlgraph.To(UsersTable, FieldID), + sqlgraph.To(UsersTable, UserFieldID), sqlgraph.Edge(sqlgraph.M2M, false, UsersTable, UsersPrimaryKey...), ) sqlgraph.HasNeighbors(s, step) @@ -112,7 +112,7 @@ func HasUsersWith(preds ...predicate.User) predicate.Group { return predicate.Group(func(s *sql.Selector) { step := sqlgraph.NewStep( sqlgraph.From(Table, FieldID), - sqlgraph.To(UsersInverseTable, FieldID), + sqlgraph.To(UsersInverseTable, UserFieldID), sqlgraph.Edge(sqlgraph.M2M, false, UsersTable, UsersPrimaryKey...), ) sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { diff --git a/entc/integration/customid/ent/pet/pet.go b/entc/integration/customid/ent/pet/pet.go index dcbd49126..b7cd29fcb 100644 --- a/entc/integration/customid/ent/pet/pet.go +++ b/entc/integration/customid/ent/pet/pet.go @@ -21,6 +21,8 @@ const ( // EdgeBestFriend holds the string denoting the best_friend edge name in mutations. EdgeBestFriend = "best_friend" + // UserFieldID holds the string denoting the id field of the User. + UserFieldID = "oid" // Table holds the table name of the pet in the database. Table = "pets" // OwnerTable is the table the holds the owner relation/edge. diff --git a/entc/integration/customid/ent/pet/where.go b/entc/integration/customid/ent/pet/where.go index d0624bb54..cc6397920 100644 --- a/entc/integration/customid/ent/pet/where.go +++ b/entc/integration/customid/ent/pet/where.go @@ -100,7 +100,7 @@ func HasOwner() predicate.Pet { return predicate.Pet(func(s *sql.Selector) { step := sqlgraph.NewStep( sqlgraph.From(Table, FieldID), - sqlgraph.To(OwnerTable, FieldID), + sqlgraph.To(OwnerTable, UserFieldID), sqlgraph.Edge(sqlgraph.M2O, true, OwnerTable, OwnerColumn), ) sqlgraph.HasNeighbors(s, step) @@ -112,7 +112,7 @@ func HasOwnerWith(preds ...predicate.User) predicate.Pet { return predicate.Pet(func(s *sql.Selector) { step := sqlgraph.NewStep( sqlgraph.From(Table, FieldID), - sqlgraph.To(OwnerInverseTable, FieldID), + sqlgraph.To(OwnerInverseTable, UserFieldID), sqlgraph.Edge(sqlgraph.M2O, true, OwnerTable, OwnerColumn), ) sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { diff --git a/entc/integration/customid/ent/user/user.go b/entc/integration/customid/ent/user/user.go index a1268ae9c..d3345f83a 100644 --- a/entc/integration/customid/ent/user/user.go +++ b/entc/integration/customid/ent/user/user.go @@ -21,6 +21,10 @@ const ( // EdgePets holds the string denoting the pets edge name in mutations. EdgePets = "pets" + // GroupFieldID holds the string denoting the id field of the Group. + GroupFieldID = "id" + // PetFieldID holds the string denoting the id field of the Pet. + PetFieldID = "id" // Table holds the table name of the user in the database. Table = "users" // GroupsTable is the table the holds the groups relation/edge. The primary key declared below. diff --git a/entc/integration/customid/ent/user/where.go b/entc/integration/customid/ent/user/where.go index e9bea14d2..a3bc69c26 100644 --- a/entc/integration/customid/ent/user/where.go +++ b/entc/integration/customid/ent/user/where.go @@ -100,7 +100,7 @@ func HasGroups() predicate.User { return predicate.User(func(s *sql.Selector) { step := sqlgraph.NewStep( sqlgraph.From(Table, FieldID), - sqlgraph.To(GroupsTable, FieldID), + sqlgraph.To(GroupsTable, GroupFieldID), sqlgraph.Edge(sqlgraph.M2M, true, GroupsTable, GroupsPrimaryKey...), ) sqlgraph.HasNeighbors(s, step) @@ -112,7 +112,7 @@ func HasGroupsWith(preds ...predicate.Group) predicate.User { return predicate.User(func(s *sql.Selector) { step := sqlgraph.NewStep( sqlgraph.From(Table, FieldID), - sqlgraph.To(GroupsInverseTable, FieldID), + sqlgraph.To(GroupsInverseTable, GroupFieldID), sqlgraph.Edge(sqlgraph.M2M, true, GroupsTable, GroupsPrimaryKey...), ) sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { @@ -184,7 +184,7 @@ func HasPets() predicate.User { return predicate.User(func(s *sql.Selector) { step := sqlgraph.NewStep( sqlgraph.From(Table, FieldID), - sqlgraph.To(PetsTable, FieldID), + sqlgraph.To(PetsTable, PetFieldID), sqlgraph.Edge(sqlgraph.O2M, false, PetsTable, PetsColumn), ) sqlgraph.HasNeighbors(s, step) @@ -196,7 +196,7 @@ func HasPetsWith(preds ...predicate.Pet) predicate.User { return predicate.User(func(s *sql.Selector) { step := sqlgraph.NewStep( sqlgraph.From(Table, FieldID), - sqlgraph.To(PetsInverseTable, FieldID), + sqlgraph.To(PetsInverseTable, PetFieldID), sqlgraph.Edge(sqlgraph.O2M, false, PetsTable, PetsColumn), ) sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { diff --git a/entc/integration/migrate/entv1/car/car.go b/entc/integration/migrate/entv1/car/car.go index c054e48a9..e43fc2ef4 100644 --- a/entc/integration/migrate/entv1/car/car.go +++ b/entc/integration/migrate/entv1/car/car.go @@ -15,6 +15,8 @@ const ( // EdgeOwner holds the string denoting the owner edge name in mutations. EdgeOwner = "owner" + // UserFieldID holds the string denoting the id field of the User. + UserFieldID = "oid" // Table holds the table name of the car in the database. Table = "cars" // OwnerTable is the table the holds the owner relation/edge. diff --git a/entc/integration/migrate/entv1/car/where.go b/entc/integration/migrate/entv1/car/where.go index 58b80b256..8247616fc 100644 --- a/entc/integration/migrate/entv1/car/where.go +++ b/entc/integration/migrate/entv1/car/where.go @@ -100,7 +100,7 @@ func HasOwner() predicate.Car { return predicate.Car(func(s *sql.Selector) { step := sqlgraph.NewStep( sqlgraph.From(Table, FieldID), - sqlgraph.To(OwnerTable, FieldID), + sqlgraph.To(OwnerTable, UserFieldID), sqlgraph.Edge(sqlgraph.O2O, true, OwnerTable, OwnerColumn), ) sqlgraph.HasNeighbors(s, step) @@ -112,7 +112,7 @@ func HasOwnerWith(preds ...predicate.User) predicate.Car { return predicate.Car(func(s *sql.Selector) { step := sqlgraph.NewStep( sqlgraph.From(Table, FieldID), - sqlgraph.To(OwnerInverseTable, FieldID), + sqlgraph.To(OwnerInverseTable, UserFieldID), sqlgraph.Edge(sqlgraph.O2O, true, OwnerTable, OwnerColumn), ) sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { diff --git a/entc/integration/migrate/entv1/user/user.go b/entc/integration/migrate/entv1/user/user.go index bfbb79905..f4753b8ba 100644 --- a/entc/integration/migrate/entv1/user/user.go +++ b/entc/integration/migrate/entv1/user/user.go @@ -41,6 +41,8 @@ const ( // EdgeCar holds the string denoting the car edge name in mutations. EdgeCar = "car" + // CarFieldID holds the string denoting the id field of the Car. + CarFieldID = "id" // Table holds the table name of the user in the database. Table = "users" // ParentTable is the table the holds the parent relation/edge. diff --git a/entc/integration/migrate/entv1/user/where.go b/entc/integration/migrate/entv1/user/where.go index 999f11bbe..2c01bbc90 100644 --- a/entc/integration/migrate/entv1/user/where.go +++ b/entc/integration/migrate/entv1/user/where.go @@ -1058,7 +1058,7 @@ func HasCar() predicate.User { return predicate.User(func(s *sql.Selector) { step := sqlgraph.NewStep( sqlgraph.From(Table, FieldID), - sqlgraph.To(CarTable, FieldID), + sqlgraph.To(CarTable, CarFieldID), sqlgraph.Edge(sqlgraph.O2O, false, CarTable, CarColumn), ) sqlgraph.HasNeighbors(s, step) @@ -1070,7 +1070,7 @@ func HasCarWith(preds ...predicate.Car) predicate.User { return predicate.User(func(s *sql.Selector) { step := sqlgraph.NewStep( sqlgraph.From(Table, FieldID), - sqlgraph.To(CarInverseTable, FieldID), + sqlgraph.To(CarInverseTable, CarFieldID), sqlgraph.Edge(sqlgraph.O2O, false, CarTable, CarColumn), ) sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { diff --git a/entc/integration/migrate/entv2/car/car.go b/entc/integration/migrate/entv2/car/car.go index c054e48a9..e43fc2ef4 100644 --- a/entc/integration/migrate/entv2/car/car.go +++ b/entc/integration/migrate/entv2/car/car.go @@ -15,6 +15,8 @@ const ( // EdgeOwner holds the string denoting the owner edge name in mutations. EdgeOwner = "owner" + // UserFieldID holds the string denoting the id field of the User. + UserFieldID = "oid" // Table holds the table name of the car in the database. Table = "cars" // OwnerTable is the table the holds the owner relation/edge. diff --git a/entc/integration/migrate/entv2/car/where.go b/entc/integration/migrate/entv2/car/where.go index fd2cdcd4e..2f7c89015 100644 --- a/entc/integration/migrate/entv2/car/where.go +++ b/entc/integration/migrate/entv2/car/where.go @@ -100,7 +100,7 @@ func HasOwner() predicate.Car { return predicate.Car(func(s *sql.Selector) { step := sqlgraph.NewStep( sqlgraph.From(Table, FieldID), - sqlgraph.To(OwnerTable, FieldID), + sqlgraph.To(OwnerTable, UserFieldID), sqlgraph.Edge(sqlgraph.M2O, true, OwnerTable, OwnerColumn), ) sqlgraph.HasNeighbors(s, step) @@ -112,7 +112,7 @@ func HasOwnerWith(preds ...predicate.User) predicate.Car { return predicate.Car(func(s *sql.Selector) { step := sqlgraph.NewStep( sqlgraph.From(Table, FieldID), - sqlgraph.To(OwnerInverseTable, FieldID), + sqlgraph.To(OwnerInverseTable, UserFieldID), sqlgraph.Edge(sqlgraph.M2O, true, OwnerTable, OwnerColumn), ) sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { diff --git a/entc/integration/migrate/entv2/pet/pet.go b/entc/integration/migrate/entv2/pet/pet.go index fe16499c0..76f1f284a 100644 --- a/entc/integration/migrate/entv2/pet/pet.go +++ b/entc/integration/migrate/entv2/pet/pet.go @@ -15,6 +15,8 @@ const ( // EdgeOwner holds the string denoting the owner edge name in mutations. EdgeOwner = "owner" + // UserFieldID holds the string denoting the id field of the User. + UserFieldID = "oid" // Table holds the table name of the pet in the database. Table = "pets" // OwnerTable is the table the holds the owner relation/edge. diff --git a/entc/integration/migrate/entv2/pet/where.go b/entc/integration/migrate/entv2/pet/where.go index 6e4730321..f5163505d 100644 --- a/entc/integration/migrate/entv2/pet/where.go +++ b/entc/integration/migrate/entv2/pet/where.go @@ -100,7 +100,7 @@ func HasOwner() predicate.Pet { return predicate.Pet(func(s *sql.Selector) { step := sqlgraph.NewStep( sqlgraph.From(Table, FieldID), - sqlgraph.To(OwnerTable, FieldID), + sqlgraph.To(OwnerTable, UserFieldID), sqlgraph.Edge(sqlgraph.O2O, true, OwnerTable, OwnerColumn), ) sqlgraph.HasNeighbors(s, step) @@ -112,7 +112,7 @@ func HasOwnerWith(preds ...predicate.User) predicate.Pet { return predicate.Pet(func(s *sql.Selector) { step := sqlgraph.NewStep( sqlgraph.From(Table, FieldID), - sqlgraph.To(OwnerInverseTable, FieldID), + sqlgraph.To(OwnerInverseTable, UserFieldID), sqlgraph.Edge(sqlgraph.O2O, true, OwnerTable, OwnerColumn), ) sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { diff --git a/entc/integration/migrate/entv2/user/user.go b/entc/integration/migrate/entv2/user/user.go index f19e13699..31939637b 100644 --- a/entc/integration/migrate/entv2/user/user.go +++ b/entc/integration/migrate/entv2/user/user.go @@ -43,6 +43,10 @@ const ( // EdgeFriends holds the string denoting the friends edge name in mutations. EdgeFriends = "friends" + // CarFieldID holds the string denoting the id field of the Car. + CarFieldID = "id" + // PetFieldID holds the string denoting the id field of the Pet. + PetFieldID = "id" // Table holds the table name of the user in the database. Table = "users" // CarTable is the table the holds the car relation/edge. diff --git a/entc/integration/migrate/entv2/user/where.go b/entc/integration/migrate/entv2/user/where.go index a74f27ffc..b1e7b9a59 100644 --- a/entc/integration/migrate/entv2/user/where.go +++ b/entc/integration/migrate/entv2/user/where.go @@ -1105,7 +1105,7 @@ func HasCar() predicate.User { return predicate.User(func(s *sql.Selector) { step := sqlgraph.NewStep( sqlgraph.From(Table, FieldID), - sqlgraph.To(CarTable, FieldID), + sqlgraph.To(CarTable, CarFieldID), sqlgraph.Edge(sqlgraph.O2M, false, CarTable, CarColumn), ) sqlgraph.HasNeighbors(s, step) @@ -1117,7 +1117,7 @@ func HasCarWith(preds ...predicate.Car) predicate.User { return predicate.User(func(s *sql.Selector) { step := sqlgraph.NewStep( sqlgraph.From(Table, FieldID), - sqlgraph.To(CarInverseTable, FieldID), + sqlgraph.To(CarInverseTable, CarFieldID), sqlgraph.Edge(sqlgraph.O2M, false, CarTable, CarColumn), ) sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { @@ -1133,7 +1133,7 @@ func HasPets() predicate.User { return predicate.User(func(s *sql.Selector) { step := sqlgraph.NewStep( sqlgraph.From(Table, FieldID), - sqlgraph.To(PetsTable, FieldID), + sqlgraph.To(PetsTable, PetFieldID), sqlgraph.Edge(sqlgraph.O2O, false, PetsTable, PetsColumn), ) sqlgraph.HasNeighbors(s, step) @@ -1145,7 +1145,7 @@ func HasPetsWith(preds ...predicate.Pet) predicate.User { return predicate.User(func(s *sql.Selector) { step := sqlgraph.NewStep( sqlgraph.From(Table, FieldID), - sqlgraph.To(PetsInverseTable, FieldID), + sqlgraph.To(PetsInverseTable, PetFieldID), sqlgraph.Edge(sqlgraph.O2O, false, PetsTable, PetsColumn), ) sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {