diff --git a/entc/gen/internal/bindata.go b/entc/gen/internal/bindata.go index 23ee003db..9ffabe769 100644 --- a/entc/gen/internal/bindata.go +++ b/entc/gen/internal/bindata.go @@ -250,7 +250,7 @@ func templateBuilderQueryTmpl() (*asset, error) { return a, nil } -var _templateBuilderSetterTmpl = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xb4\x57\x5d\x6f\xdb\x36\x17\xbe\xb6\x7e\xc5\x79\x05\xbf\x80\x6c\x2c\x74\xdb\xbb\x0d\xf0\x45\x1a\xb7\x80\x81\xb5\x05\xe6\xe6\xaa\xe8\x05\x23\x1e\x39\x6c\x15\x52\x25\x29\x6f\x81\xa6\xff\x3e\xf0\x4b\x92\x65\xc7\x8e\xd3\xed\xce\x26\xcf\x17\x9f\xf3\x9c\x0f\x35\xcd\x62\x9e\xdc\xc8\xea\x51\xf1\xed\xbd\x81\x37\xaf\x5e\xff\x7a\x55\x29\xd4\x28\x0c\xbc\xa7\x39\xde\x49\xf9\x1d\xd6\x22\x27\x70\x5d\x96\xe0\x84\x34\xd8\x7b\xb5\x43\x46\x92\xcf\xf7\x5c\x83\x96\xb5\xca\x11\x72\xc9\x10\xb8\x86\x92\xe7\x28\x34\x32\xa8\x05\x43\x05\xe6\x1e\xe1\xba\xa2\xf9\x3d\xc2\x1b\xf2\x2a\xde\x42\x21\x6b\xc1\x12\x2e\xdc\xfd\xef\xeb\x9b\x77\x1f\x37\xef\xa0\xe0\x25\x42\x38\x53\x52\x1a\x60\x5c\x61\x6e\xa4\x7a\x04\x59\x80\x19\x38\x33\x0a\x91\x24\xf3\x45\xdb\x26\x49\xd3\x00\xc3\x82\x0b\x84\x54\xa3\x31\xa8\x52\x68\x5b\x7b\x3a\xbd\xab\x79\x69\x63\xf8\x6d\x09\x15\xd5\x39\x2d\x61\x4a\x36\xb9\xac\x90\xbc\x0d\x37\x41\x50\x61\x8e\x7c\xe7\x25\xbb\xdf\x9d\x7a\x10\x2a\x38\x96\x4c\x5b\x91\x29\x79\xef\x7f\x87\x9b\xba\x62\xd4\x78\xed\x82\x96\x1a\xfd\xf9\x15\xf0\x02\xa4\x82\xec\x9e\xea\x4d\x5d\x14\xfc\xaf\xde\x64\x7a\xeb\x54\xd2\xd9\xa9\xdb\x4f\xc2\x0a\xb4\x6d\x32\x19\x3a\x59\x82\x51\x35\x76\xc7\x21\x2a\x1b\xd4\x87\xda\xd0\xbb\x12\x87\xb1\x5d\x01\xda\x78\x78\x01\x53\xb2\x5e\x91\x5b\x8d\x6a\xe5\xb0\x62\x87\x06\x68\x55\xa1\x60\xdd\x81\x55\xe8\x8c\x08\x27\x6f\x1f\xab\xa8\xd8\x22\x4c\x0b\x87\x43\xd1\xb9\x72\xa6\xaa\x7d\xfc\x0a\xf2\xf9\xb1\x42\xb2\x31\x8a\x8b\x2d\xb4\x6d\xd3\xd8\x40\xf0\x87\x15\xec\x21\x6f\x5b\xf0\xba\x4b\x48\x77\xb4\xac\x31\x0d\x47\xc1\xa9\x0f\xb2\x16\xb9\x4b\xa3\xe2\xc2\x40\xba\x41\x93\x5a\xfb\x1b\xa3\xea\xdc\xb8\x07\x3b\xd1\xc5\x02\x3a\xe9\xb6\x05\x8d\x46\x3b\x32\xb9\x43\xf2\x91\x3e\x58\xdc\xc0\x45\x4d\x92\x89\x13\xcb\xf6\xf2\xdf\xb6\x30\x1f\x32\xa7\x6d\x67\x43\x8b\x99\x8f\x34\x84\xec\xdf\xe7\x64\x46\x4a\xd0\x24\x93\x89\x05\x6e\x31\xb7\x41\x18\xfb\x7e\x51\x3f\xa0\xe2\x39\x18\xab\x23\x77\xa8\x14\x67\x08\x95\xc2\x1d\x97\xb5\x86\x9c\x96\xa5\x06\x23\xe1\x9a\x31\x02\x8e\xd9\xde\x04\x2f\x80\xba\xb4\x78\x34\x3f\x06\x33\x1d\x1f\x9c\xe0\x64\xf4\x0a\xf2\x50\x1b\x6a\xb8\x14\xa4\x69\x22\x68\x7f\xa0\x3e\x0a\x5b\x36\x0b\x9e\x22\xe0\x27\x8d\x1d\x40\x61\xb5\x15\x9a\x5a\x09\x18\xe9\x25\x93\x36\xb1\xe9\x5b\xcc\x81\xee\x24\x67\xb0\x45\x81\xca\x83\xc1\xcb\xd2\x72\x15\x7c\xc5\x6a\x28\xa4\xea\x0f\x2d\x44\x3a\x82\xe0\x59\x63\x21\xc8\x84\x34\x3d\x0e\x41\x78\x06\x99\x74\x5c\xfb\x54\xd9\x10\x6d\x8d\x17\x64\x85\x05\xad\x4b\x33\xf3\x2a\x99\xc3\x2f\xe2\x35\x2d\x88\x2f\xaf\x28\x34\xeb\x1f\x1d\x23\x78\x7f\x40\xb7\xe8\xee\x28\xed\x22\xef\xf6\xd4\xcf\xf0\xcf\x3e\xca\x5e\x6d\xf9\x0e\x05\x38\xe2\xdb\xee\x69\xe3\x15\xbc\x24\xc9\xe4\x12\x7a\x8e\x1c\xf7\x34\x9d\x3f\x83\xa7\x13\x5e\x40\xa7\xf0\xbf\xa5\x75\xef\xcf\x0f\x78\x30\x4c\xff\x7c\x98\xff\x89\xe3\xe0\x53\x2c\x98\xf8\x2c\xc6\x26\x32\xc8\xe8\x01\xa9\x0b\x72\x23\xc5\x0e\x95\x41\xf6\x59\xbe\xa5\xfa\x80\xe8\x47\x9a\xc1\x35\x63\x27\xb3\x12\xbb\x01\x65\x4c\xf7\x0f\x35\x72\x3f\x2b\x17\x22\xfe\x92\x86\x70\x79\x5d\xbd\x0c\xd2\xbe\x12\xce\x41\x77\x53\x22\x55\xcf\x02\x2f\xb7\x92\x9e\xcc\x9e\xab\xb2\xf8\x57\xf0\xfb\x19\xa4\x2e\x40\x68\x80\x55\x3f\xc3\xd0\xcf\xf2\x77\x6c\x8b\xfd\x0c\x93\x6e\x88\xa5\xd4\x92\x2a\x8e\xac\x29\x92\x5b\xc1\x7f\xb8\xa9\x1b\x64\x96\x6e\xd9\x08\x22\xc3\x49\xc5\x99\xde\xef\x1e\x59\x5c\x3d\x64\x35\x83\x4c\x73\xb1\xad\x4b\xaa\xac\x4d\x87\xdc\xdf\x61\x35\x99\x41\xba\x5e\xe9\xa7\x7d\x46\xbb\xc7\xcd\xc6\x3f\xde\xa8\xb3\x35\x8a\x2d\xe4\x33\x9a\x09\x8c\x95\x96\x69\x7d\x8f\xc2\xae\x47\x21\xdb\x62\xac\x11\x0c\x45\x1a\xae\xee\x1e\x81\x33\x1f\xa4\x6b\xc8\x83\x40\x75\xe7\xf0\xb2\xf1\xda\x47\x95\x1d\xbe\xde\x39\x43\xbf\x56\x71\xa6\x81\x10\xd2\xb9\x19\xc6\xb7\x5e\x9d\x9b\xc7\x27\x38\xf5\xe2\x08\x4e\x8f\xbf\x61\x61\x76\x06\xa7\xd8\x97\xe8\xc1\xe8\x59\xaf\xf4\xc9\xe9\x83\x7b\xa5\x1a\xf2\x7c\x38\x82\xa2\x99\xf1\x14\x7a\x7e\x86\xff\x93\x01\xd5\x87\x95\x71\xe6\x45\x9f\x99\x3d\x3b\xa5\x38\x7b\x7a\x3e\xb5\x2d\x2c\xc7\x19\x18\x67\x76\xce\xd9\xa5\xd3\xaa\xdf\x6b\x4b\xf9\x27\x2a\xc8\x5c\x52\x0a\x48\xff\x4f\x5e\xeb\x74\x0f\xb9\x6e\x55\x3f\xb7\xe4\x9e\x5f\x70\xf7\x8a\x7b\x94\xf2\x23\x7b\xee\xd9\x4a\x6e\x9a\x71\xb1\x0e\x6b\xf5\x38\x0b\x7e\x7e\x41\x3e\xd2\x20\x86\x95\x33\x1f\xf9\x3c\x51\xb7\x7b\xf5\x78\xd5\x9e\xc8\xdf\x91\x62\x76\xf1\x90\xf5\xaa\x5b\x73\x6d\x21\x07\x23\xdc\x7f\xd0\x3d\xd0\xef\x98\x7d\xf9\x7a\x94\x8e\xbf\x40\x89\xa2\x9f\xca\xb3\x38\x9e\xb8\x9b\x13\x3c\xdd\xfb\xb0\xe1\x5e\xca\xdf\x2f\x21\xfd\x36\xe8\xc2\xc1\xa5\xdd\x74\xfd\x7d\xdb\xba\xef\x25\x37\x8c\x7a\xdc\x1c\xb3\x39\xd3\x5f\xa2\xd0\xd7\x40\x6c\x7b\xdd\x1f\x92\xf5\xea\x0c\x95\xc7\x50\x70\xa6\x09\x21\xe3\x65\x7f\x6f\x36\x2e\x16\xf0\x21\x74\x45\xf0\x46\x7b\x46\x91\x78\x13\x89\x25\xef\xbe\x61\x6e\xfc\x97\x39\x42\x48\x1a\x49\x9e\x49\x9a\x68\x2d\x6e\x00\x07\xe6\x9b\xe4\xa9\x77\xc5\xc6\x9d\xf8\x69\x1e\x82\xff\x27\x00\x00\xff\xff\x37\x9e\x70\x0b\xcb\x10\x00\x00") +var _templateBuilderSetterTmpl = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xb4\x57\x4f\x6f\xdb\xb8\x13\x3d\x5b\x9f\x62\x7e\x82\x7f\x80\x6c\x6c\xe8\xb6\xb7\x5d\xc0\x87\x34\x6e\x01\x03\xbb\x2d\xb0\x4e\x4e\x45\x0f\x8a\x38\x72\xd8\x2a\xa4\x4a\x52\xde\x0d\x04\x7e\xf7\x05\xff\x49\xb2\xec\xd8\x71\xba\x7b\x13\xc8\xe1\xcc\xf0\xcd\x9b\x79\x54\xdb\x2e\xe6\xc9\x8d\xa8\x9f\x24\xdb\x3e\x68\x78\xf7\xe6\xed\xaf\x57\xb5\x44\x85\x5c\xc3\xc7\xbc\xc0\x7b\x21\xbe\xc3\x9a\x17\x04\xae\xab\x0a\x9c\x91\x02\xbb\x2f\x77\x48\x49\x72\xfb\xc0\x14\x28\xd1\xc8\x02\xa1\x10\x14\x81\x29\xa8\x58\x81\x5c\x21\x85\x86\x53\x94\xa0\x1f\x10\xae\xeb\xbc\x78\x40\x78\x47\xde\xc4\x5d\x28\x45\xc3\x69\xc2\xb8\xdb\xff\x7d\x7d\xf3\xe1\xd3\xe6\x03\x94\xac\x42\x08\x6b\x52\x08\x0d\x94\x49\x2c\xb4\x90\x4f\x20\x4a\xd0\x83\x60\x5a\x22\x92\x64\xbe\x30\x26\x49\xda\x16\x28\x96\x8c\x23\xa4\x0a\xb5\x46\x99\x82\x31\x76\x75\x7a\xdf\xb0\xca\xe6\xf0\xdb\x12\xea\x5c\x15\x79\x05\x53\xb2\x29\x44\x8d\xe4\x7d\xd8\x09\x86\x12\x0b\x64\x3b\x6f\xd9\x7d\x77\xc7\x83\x51\xc9\xb0\xa2\xca\x9a\x4c\xc9\x47\xff\x1d\x76\x9a\x9a\xe6\xda\x9f\x2e\xf3\x4a\xa1\x5f\xbf\x02\x56\x82\x90\x90\x3d\xe4\x6a\xd3\x94\x25\xfb\xbb\x77\x99\xde\xb9\x23\xe9\xec\xd4\xee\x67\x6e\x0d\x8c\x49\x26\xc3\x20\x4b\xd0\xb2\xc1\x6e\x39\x64\x65\x93\xfa\xa3\xd1\xf9\x7d\x85\xc3\xdc\xae\x00\x6d\x3e\xac\x84\x29\x59\xaf\xc8\x9d\x42\xb9\x72\x58\xd1\x43\x07\x79\x5d\x23\xa7\xdd\x82\x3d\xd0\x39\xe1\xce\xde\x5e\x56\xe6\x7c\x8b\x30\x2d\x1d\x0e\x65\x17\xca\xb9\xaa\xf7\xf1\x2b\xc9\xed\x53\x8d\x64\xa3\x25\xe3\x5b\x30\xa6\x6d\x6d\x22\xf8\xc3\x1a\xf6\x90\x1b\x03\xfe\xec\x12\xd2\x5d\x5e\x35\x98\x86\xa5\x10\xd4\x27\xd9\xf0\xc2\x95\x51\x32\xae\x21\xdd\xa0\x4e\xad\xff\x8d\x96\x4d\xa1\xdd\x85\x9d\xe9\x62\x01\x9d\xb5\x31\xa0\x50\x2b\x47\x26\xb7\x48\x3e\xe5\x8f\x16\x37\x70\x59\x93\x64\xe2\xcc\xb2\xbd\xfa\x1b\x03\xf3\x21\x73\x8c\x99\x0d\x3d\x66\x3e\xd3\x90\xb2\xbf\x9f\xb3\x19\x1d\x82\x36\x99\x4c\x2c\x70\x8b\xb9\x4d\x42\xdb\xfb\xf3\xe6\x11\x25\x2b\x40\xdb\x33\x62\x87\x52\x32\x8a\x50\x4b\xdc\x31\xd1\x28\x28\xf2\xaa\x52\xa0\x05\x5c\x53\x4a\xc0\x31\xdb\xbb\x60\x25\xe4\xae\x2c\x1e\xcd\x4f\xc1\x4d\xc7\x07\x67\x38\x19\xdd\x82\x3c\x36\x3a\xd7\x4c\x70\xd2\xb6\x11\xb4\x3f\x51\x1d\x85\x2d\x9b\x85\x48\x11\xf0\x93\xce\x0e\xa0\xb0\xa7\x25\xea\x46\x72\x18\x9d\x4b\x26\x26\xb1\xe5\x5b\xcc\x21\xdf\x09\x46\x61\x8b\x1c\xa5\x07\x83\x55\x95\xe5\x2a\xf8\x8e\x55\x50\x0a\xd9\x2f\x5a\x88\x54\x04\xc1\xb3\xc6\x42\x90\x71\xa1\x7b\x1c\x82\xf1\x0c\x32\xe1\xb8\xf6\xb9\xb6\x29\xda\x1e\x2f\xc9\x0a\xcb\xbc\xa9\xf4\xcc\x1f\xc9\x1c\x7e\x11\xaf\x69\x49\x7c\x7b\x45\xa3\x59\x7f\xe9\x98\xc1\xc7\x03\xba\xc5\x70\x47\x69\x17\x79\xb7\x77\xfc\x0c\xff\xec\xa5\xec\xd6\x96\xed\x90\x83\x23\xbe\x9d\x9e\x36\x5f\xce\x2a\x92\x4c\x2e\xa1\xe7\x28\x70\x4f\xd3\xf9\x0b\x78\x3a\x61\x25\x74\x07\xfe\xb7\xb4\xe1\xfd\xfa\x01\x0f\x86\xe5\x9f\x0f\xeb\x3f\x71\x1c\x7c\x8e\x05\x13\x5f\xc5\x38\x44\x06\x15\x3d\x20\x75\x49\x6e\x04\xdf\xa1\xd4\x48\x6f\xc5\xfb\x5c\x1d\x10\xfd\xc8\x30\xb8\xa6\xf4\x64\x55\xe2\x34\xc8\x29\x55\xfd\x45\xb5\xd8\xaf\xca\x85\x88\xbf\x66\x20\x5c\xde\x57\xaf\x83\xb4\xef\x84\x73\xd0\xdd\x54\x98\xcb\x17\x81\x57\x58\x4b\x4f\x66\xcf\x55\x51\xfe\x2b\xf8\xfd\x0c\x52\x17\x20\x34\xc0\xaa\xd7\x30\xf4\x5a\xfe\x81\x6e\xb1\xd7\x30\xe1\x44\x2c\xcd\x2d\xa9\x9c\x64\x4d\x19\x55\x71\x1e\x4c\xd1\x89\xac\xcd\xe4\x9a\xd2\x4e\xd2\xa6\x48\xee\x38\xfb\xe1\x54\x39\xf8\x58\xba\xc7\xc8\xd8\xc5\x9e\x87\x0d\x6a\xbf\x1d\xe7\x6e\x80\x3c\x1a\x07\x52\x09\x4b\x86\x7e\x8c\x60\x37\x46\x90\x6e\x31\xd2\x18\x43\x1f\x85\xad\xfb\x27\x60\xd4\xe7\xe6\x66\xe6\x20\x3f\xd5\x05\xbc\x4c\x01\xfb\xac\xb2\xc3\x4b\xbb\x60\xe8\x5f\x3e\x8c\x2a\x20\x84\x74\x61\x86\xf9\xad\x57\xe7\x24\xf3\x44\xd9\x5f\x9d\xc1\x69\x85\x1a\xf6\x4e\xe7\x70\x8a\x7d\x17\x1d\xa8\xc3\x7a\xa5\x4e\x0a\x04\xee\x75\x53\xba\x5e\xa5\x47\x55\x22\xba\x19\x0b\xc5\xcb\x2b\xfc\x9f\x68\x48\x9f\x56\xc6\xa8\x37\x7d\x61\xf5\xac\x90\x30\xfa\xbc\x84\x18\x03\xcb\x71\x05\xc6\x95\x9d\x33\x7a\xa9\xa0\xf4\x4f\xcf\x4a\xfc\x85\x12\x32\x57\x94\x12\xd2\xff\x93\xb7\x2a\xdd\x43\xae\x7b\x4d\x9f\x7b\x87\x9e\x7f\x83\x66\xf1\x8f\x42\xd4\xb3\x71\xc9\x8f\x3c\x45\xcf\x76\x72\xdb\x8e\x9b\x75\xd8\xab\xc7\x59\xf0\xf3\x6f\xd8\x23\x03\x62\xd8\x39\xf3\x51\xcc\x13\x7d\xbb\xd7\x8f\x57\xe6\x44\xfd\x8e\x34\xb3\xcb\x87\xac\x57\xdd\x4b\xd4\x36\x72\x70\xc2\xfc\x3f\xd7\x63\xfe\x1d\xb3\x2f\x5f\x8f\xd2\xf1\x17\xa8\x90\xf7\xc2\x39\x8b\x0a\xc2\xdc\x28\x67\xe9\xde\xbf\x07\xf3\x56\x7e\x7f\x09\xe9\xb7\xb4\x9f\xc2\x21\xa4\x7d\x8c\xfa\x7d\x63\xdc\x2f\x8d\xd3\x8b\x1e\x37\xc7\x6c\x46\xd5\x97\x68\xf4\x35\x10\xdb\x6e\xf7\x8b\x64\xbd\x3a\x43\xe5\x31\x14\x8c\x2a\x42\xc8\xf8\x3d\xbe\x27\x5f\x8b\x05\x44\x01\x01\xef\xb4\x67\x54\x27\x2d\x91\x58\xe2\xfe\x1b\x16\xda\xff\x3c\x23\x84\xa2\x91\xe4\x85\xa4\x89\xde\xa2\x48\x1f\xb8\x6f\x93\xe7\xee\x15\x07\x77\xe2\x05\x37\x24\xff\x4f\x00\x00\x00\xff\xff\x59\x51\xf2\x6f\x6e\x10\x00\x00") func templateBuilderSetterTmplBytes() ([]byte, error) { return bindataRead( @@ -265,7 +265,7 @@ func templateBuilderSetterTmpl() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "template/builder/setter.tmpl", size: 4299, mode: os.FileMode(420), modTime: time.Unix(1, 0)} + info := bindataFileInfo{name: "template/builder/setter.tmpl", size: 4206, mode: os.FileMode(420), modTime: time.Unix(1, 0)} a := &asset{bytes: bytes, info: info} return a, nil } diff --git a/entc/gen/template/builder/setter.tmpl b/entc/gen/template/builder/setter.tmpl index ef8004d80..09415f0cc 100644 --- a/entc/gen/template/builder/setter.tmpl +++ b/entc/gen/template/builder/setter.tmpl @@ -61,8 +61,7 @@ in the LICENSE file in the root directory of this source tree. {{ end }} {{ range $e := $.Edges }} - {{ $op := "add" }}{{ if $e.Unique }}{{ $op = "set" }}{{ end }} - {{ $idsFunc := print (pascal $op) (singular $e.Name | pascal) "IDs" }}{{ if $e.Unique }}{{ $idsFunc = print (pascal $op) (pascal $e.Name) "ID" }}{{ end }} + {{ $op := "add" }}{{ $idsFunc := $e.MutationAdd }}{{ if $e.Unique }}{{ $op = "set" }}{{ $idsFunc = $e.MutationSet }}{{ end }} // {{ $idsFunc }} {{ $op }}s the {{ $e.Name }} edge to {{ $e.Type.Name }} by id{{ if not $e.Unique }}s{{ end }}. func ({{ $receiver }} *{{ $builder }}) {{ $idsFunc }}({{ if $e.Unique }}id{{ else }}ids ...{{ end }} {{ $e.Type.ID.Type }}) *{{ $builder }} { {{ $receiver }}.mutation.{{ $idsFunc }}({{ if $e.Unique }}id{{ else }}ids ...{{ end }})