diff --git a/entc/gen/internal/bindata.go b/entc/gen/internal/bindata.go index 1f6a58408..c8538e292 100644 --- a/entc/gen/internal/bindata.go +++ b/entc/gen/internal/bindata.go @@ -690,7 +690,7 @@ func templateDialectSqlDeleteTmpl() (*asset, error) { return a, nil } -var _templateDialectSqlEntqlTmpl = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xb4\x57\x5f\x4f\xdc\x48\x12\x7f\xb6\x3f\x45\x9d\x85\x22\x1b\x4d\x3c\xb9\xbc\x1d\x27\x1e\x08\x90\xcb\xe8\x96\x88\x0d\x64\xf3\x80\xa2\x55\x63\x97\xc7\x2d\xec\xb6\xd3\xdd\x26\x1a\x59\xfe\xee\xab\xea\x6e\xff\x65\x98\x80\x56\xfb\x00\x98\xee\xfa\xfb\xfb\x95\xab\xca\x6d\xbb\x3e\xf6\xcf\xab\x7a\x27\xf9\x36\xd7\xf0\xfe\xdd\xbf\xff\xf3\xb6\x96\xa8\x50\x68\xf8\xc8\x12\xbc\xaf\xaa\x07\xd8\x88\x24\x86\xb3\xa2\x00\x23\xa4\x80\xee\xe5\x23\xa6\xb1\x7f\x9b\x73\x05\xaa\x6a\x64\x82\x90\x54\x29\x02\x57\x50\xf0\x04\x85\xc2\x14\x1a\x91\xa2\x04\x9d\x23\x9c\xd5\x2c\xc9\x11\xde\xc7\xef\xfa\x5b\xc8\xaa\x46\xa4\x3e\x17\xe6\xfe\xb7\xcd\xf9\xe5\xe7\x9b\x4b\xc8\x78\x81\xe0\xce\x64\x55\x69\x48\xb9\xc4\x44\x57\x72\x07\x55\x06\x7a\xe2\x4c\x4b\xc4\xd8\x3f\x5e\x77\x9d\xef\xb7\x2d\xa4\x98\x71\x81\x10\xa4\x9c\x15\x98\xe8\xb5\xfa\x51\xac\x51\xe8\x1f\x45\x00\x4e\xe2\xa8\x7e\xd8\xc2\xc9\x29\xdc\x33\x85\x70\x14\x9f\x57\x22\xe3\xdb\xf8\x9a\x25\x0f\x6c\x8b\x24\xd4\xb6\xa0\xb1\xac\x0b\xa6\x11\x82\x1c\x59\x8a\x32\x80\x23\xa3\xce\xcb\xba\x92\x1a\x42\xdf\x0b\xc8\xd2\x53\xe5\x75\x2d\x31\xe5\x09\xd3\x18\xf8\x5e\xdb\xbe\x05\xc9\xc4\x16\xe1\x48\x90\xc7\xa3\xf8\x73\x95\xa2\x22\x4b\xde\xb3\x06\xe8\x58\x4c\x0e\x9c\x1d\x14\xa9\x89\xc0\x0b\xb6\x5c\xe7\xcd\x7d\x9c\x54\xe5\x3a\x73\xbc\x50\x86\xeb\x49\xc6\xc1\xcb\xc4\xe8\x67\x2b\x59\x9d\x1f\x92\xb7\xe0\x1d\x10\x50\x49\x8e\x25\x5b\x67\x1c\x8b\x34\xf0\x23\xdf\x5f\xaf\xc1\x9e\xfd\x8f\x6c\x43\x5e\x15\xa9\x02\x06\x12\x5d\x39\x31\xcd\x2b\x41\x34\x8e\xda\xc0\x34\xc8\x46\x68\x5e\x62\xec\x3f\x32\x39\x33\x70\x0a\x59\x23\x92\x30\x82\xe3\x3e\xde\xf8\xc6\x6a\xb5\xbe\x67\xfe\x27\x70\xdf\x2c\x2e\x5b\x83\xf5\x09\x94\xec\x01\xc3\xbb\xef\xa3\x2e\x9d\xaf\xa0\x6d\xa1\x40\x31\xa1\x24\xea\x66\x84\xf1\xd5\x3e\xd2\x46\x0b\xea\x8e\x88\xe2\xd0\x75\xdf\x61\xea\x9c\xee\x5a\xdf\xf3\x3c\x7a\xb8\xa9\x31\x39\x81\xd9\x1d\x1d\x99\x7b\xef\x96\xdd\x17\x78\x02\x4b\xbe\x63\x73\xbe\x32\x22\xe7\x55\xd1\x94\x42\xed\x11\x72\x37\x56\x6c\x73\x71\x32\x89\xe0\x23\x11\x31\xba\xf1\x6e\x77\x35\x9e\x80\xa1\x27\xb6\x76\x36\x17\x31\x1d\x52\xf1\x29\xfd\x99\x95\x64\xd1\x5a\x72\x1e\xf7\x38\x1c\x34\x8d\x12\x13\x7a\xd0\xb1\x7f\xec\x6f\xeb\x2b\xb0\xc2\xce\x72\x60\x6e\x4c\x54\x86\x8e\xfa\x4e\x69\xc9\xc5\x76\x42\xc9\x22\xe4\x09\x0d\x99\xa1\x40\x58\x09\x47\x82\x91\xd8\x13\x5e\x36\x8d\xed\x04\xda\x65\xe2\xd9\x9e\xac\xe1\x60\xc2\x33\x8b\x2e\xdd\xc9\xcb\xd8\xa7\xdd\xcd\x5e\xd1\xc3\xaf\xfd\xe4\x12\x5d\x6e\x97\xe9\xb6\xbf\x75\x05\x76\xd5\x28\x7d\x96\xa6\x97\xa1\xf1\x68\xe0\xc4\x39\x9c\xde\xc8\x37\xa9\x4f\xe8\xfe\x82\xc5\xa4\xe4\xac\xea\x17\x2c\x4c\xee\x23\xcf\x1b\xf1\x88\x52\xb9\xf2\xc3\x78\xa3\xdc\xc1\x28\xf1\x5c\x79\x5a\x05\x73\xfb\xa4\x14\x66\x05\xcb\x33\x12\xbc\x7a\x7f\x05\x5d\xf7\x8c\x95\xeb\xff\x4f\x4c\xb4\x2d\x60\x61\x22\xb8\xfb\x6e\x2b\xa4\x7d\xce\xbb\x75\x33\xd1\x05\xa3\x6d\xf0\x77\x91\x7c\xe0\x29\xef\xb3\xa3\xe7\x45\xb9\x7a\xfb\x6a\xb4\x47\xda\x94\xc9\xec\x26\xf2\xbd\x27\x14\xf7\xcf\x12\x75\x23\x05\x18\xbc\xfd\x2e\xb4\x0d\x70\x18\x03\x67\x29\x8d\xbe\x9f\x92\xd5\xca\x0c\x33\x96\xa6\xd7\xfd\x1d\x94\xa8\xf3\x2a\x8d\x49\x81\x86\x6a\x53\xa7\x4c\xe3\xca\xfd\x7d\x5b\x09\x04\x26\x52\xf8\xd1\xa0\xdc\xc1\x7d\xc3\x8b\x14\xa5\x02\x5e\xd6\x05\x96\x34\x96\xcd\x18\xe4\x42\xa3\xa4\x86\x1c\xfb\x9a\x28\x5e\x78\x1e\xae\xa9\x59\x4e\x9d\x87\xa6\xa9\x2a\xd3\x54\xe3\x1b\x2c\xcc\x74\x8d\x22\xdf\x0e\xc9\x43\x5d\x90\x40\x72\xd1\xb8\x0a\xfe\x9d\x22\x74\x80\xd9\x7b\x89\x09\xf2\x47\x2b\x30\x3c\x0f\x5a\xbd\x54\xd9\xb8\x61\x60\xcd\x5c\xb9\x7f\x67\x96\x32\x5e\x68\x6b\xa7\x96\x5c\x68\xdb\x0c\xe8\xa8\x97\xf2\xbd\xf5\x7a\x0e\xeb\x80\x90\x85\xfc\x39\x44\x62\xdf\x23\x0c\x20\x9c\x05\xdc\x75\x70\x3c\xcd\xb0\xeb\xa2\x99\xf5\x90\xcc\xc1\x7e\xf0\x08\x63\x6f\x61\x2d\x1e\xdc\x2b\x38\x05\x56\xd7\x28\xd2\xa5\xc7\x89\xcc\xca\x84\x1b\xf9\x9e\x4b\xcc\xe6\x0a\xb6\xc8\x68\x8c\xba\x83\x21\x47\x0b\xa0\xae\xc8\x74\xb1\x03\x0b\x97\x82\xca\xee\x4e\xf3\x4c\xfa\x22\x7a\x79\xe6\xd6\x1b\xcd\xde\x09\x17\x5d\x67\x12\x75\x85\xff\x66\x76\x63\xdf\xd9\xa9\xcd\x6e\xc8\xe5\x6f\x91\x54\xda\x10\x86\x92\x79\x35\x2f\xe5\x5e\x26\xca\x57\x60\x2f\xc0\x2c\x43\xf1\xb7\x1c\x25\xbe\x86\x81\x49\xd0\x4f\x28\xd8\x97\xd7\xeb\x51\x2f\x47\x94\xe7\x2a\xb5\xac\x1e\x39\xbd\xb9\x0c\xb6\x28\x50\xf2\xc4\x05\xc8\xc5\x16\x12\x56\xb3\x7b\x5e\x70\xbd\x9b\x2c\x60\x90\x55\x72\x51\x37\xb1\xef\x99\xde\x32\x37\xad\xb4\x6c\x12\x6d\x82\x9a\xb3\x37\x84\x62\x81\x22\x58\x38\x5a\x9a\x0d\x80\x23\xd9\x3d\x48\xb6\xc5\x59\xd3\x03\x32\xd9\x22\xfd\xc8\xda\x0b\x6b\x47\xc3\xb5\xe5\x35\x8b\x7f\xdd\xd6\x8c\xa0\xc7\x33\x40\x69\x5a\xc9\x64\xbd\x8c\x2f\x1f\x59\x71\x1d\x4e\x4f\x16\xfb\x9d\x99\x07\x2b\xa8\x57\xa0\xa2\xff\x1a\x0b\xff\x3a\x05\xc1\x0b\x6b\xd4\x53\x31\x8d\x6a\x29\x2b\x19\xa2\x94\x91\xd9\x0a\x68\x29\x70\x75\x44\x66\x0c\x78\xb6\xc7\xf5\xbb\x97\xf9\x75\x63\xc6\xdc\xd0\xea\xb8\xe9\xd3\x43\xa7\x0b\x6b\xa6\x12\x56\x58\xf5\x08\x82\xeb\xa0\x97\xa4\xd1\x6a\x4c\x6d\xd4\xd7\xaf\x9b\x0b\x37\x60\xad\xfa\x29\x04\x7f\xb0\xa2\x41\x23\x3d\x4c\xc5\x91\x8e\xcd\xc5\x1e\x42\x86\x20\x4d\xc5\x2c\xc8\xe1\xa9\x5b\xa2\x7e\x41\xcc\xe6\x62\xa0\x66\x0c\x87\x6e\x2d\x4b\x8e\x3c\xbb\xca\x85\x2f\x5a\x30\xa3\x11\xc3\x03\xfb\xe0\x0c\xe1\x6c\x3f\xbc\xaf\xc0\xb7\x07\x38\x8b\x37\xea\x96\x9b\x19\x33\x43\x97\xce\x06\x70\x69\x61\xe9\x85\x3f\xec\xb4\x99\x90\x33\x69\x73\xb8\x57\xfc\xc5\xcc\x0d\xd4\xd9\x95\xf4\xc6\xbc\x76\x06\x00\xa2\xeb\x95\x64\x5a\x1b\x6e\x76\x0e\xbc\x1e\x26\x76\x9f\xdf\x03\x54\xbf\x8c\xeb\x6c\x49\xb4\x5d\xa3\xc7\x0f\xdd\x91\xf4\x3d\x8b\xb2\xb1\x40\x31\x0f\x6c\x06\xc6\xe7\x27\xa6\x02\x5a\xe1\xe6\xc1\x5a\x0c\x07\x9d\x09\x6a\x6c\x82\x90\xae\x20\xc9\x31\x79\x20\x86\x6c\x43\xca\x99\xed\xfa\xe9\x16\x61\xb6\x84\x1f\x82\x6c\xe2\x26\x5c\x00\x62\x11\xfb\xc4\x14\x65\x12\x2e\xf6\x7a\x87\xc1\x34\xb9\x5f\xe7\x16\x7c\xe3\x3a\x0f\xfe\x89\x14\xe1\x27\xd7\x39\x4d\x0d\xfe\x88\x02\x92\x4a\xa4\x9c\xe6\x93\x82\xb0\xd2\x39\xca\xd1\xa8\x8a\x5e\x8a\x06\xa9\x28\x88\xe3\x71\xe4\xc6\x4f\x17\xee\x43\x90\x51\xb2\x4b\xd8\x56\xe3\xc7\xce\x37\xc9\xea\x8f\xd4\xfe\x0f\xcc\x00\x8f\xa6\xdb\x9f\x2b\xa8\xcd\x66\x6a\xea\xcb\x86\xe5\x3e\x9f\xea\x50\x45\xf6\x3b\xc1\x34\xf2\xe8\x69\x65\x4e\x6a\x74\x7c\xfc\x2b\x00\x00\xff\xff\xd6\xd5\x85\x01\x3e\x13\x00\x00") +var _templateDialectSqlEntqlTmpl = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xb4\x57\x5f\x4f\xdc\x48\x12\x7f\xb6\x3f\x45\x9d\x85\x22\x1b\x4d\x3c\xb9\xbc\x1d\x27\x1e\x08\x90\xcb\xdc\x2e\x2c\x1b\xc8\xe6\x01\x45\xab\xc6\x2e\x8f\x5b\xd8\x6d\xa7\xbb\x87\x08\x59\xfe\xee\xab\xae\xee\xb1\xdb\x66\x98\x80\x56\xfb\x00\x98\xae\x3f\x5d\xf5\xfb\x95\xab\xca\x5d\xb7\x3c\x0c\x4f\x9b\xf6\x51\xf2\x75\xa9\xe1\xfd\xbb\x7f\xff\xe7\x6d\x2b\x51\xa1\xd0\xf0\x91\x65\x78\xd7\x34\xf7\xb0\x12\x59\x0a\x27\x55\x05\xa4\xa4\xc0\xc8\xe5\x03\xe6\x69\x78\x53\x72\x05\xaa\xd9\xc8\x0c\x21\x6b\x72\x04\xae\xa0\xe2\x19\x0a\x85\x39\x6c\x44\x8e\x12\x74\x89\x70\xd2\xb2\xac\x44\x78\x9f\xbe\xdb\x4a\xa1\x68\x36\x22\x0f\xb9\x20\xf9\xaf\xab\xd3\xf3\xcb\xeb\x73\x28\x78\x85\xe0\xce\x64\xd3\x68\xc8\xb9\xc4\x4c\x37\xf2\x11\x9a\x02\xb4\x77\x99\x96\x88\x69\x78\xb8\xec\xfb\x30\xec\x3a\xc8\xb1\xe0\x02\x21\xca\x39\xab\x30\xd3\x4b\xf5\xbd\x5a\xa2\xd0\xdf\xab\x08\x9c\xc6\x41\x7b\xbf\x86\xa3\x63\xb8\x63\x0a\xe1\x20\x3d\x6d\x44\xc1\xd7\xe9\x15\xcb\xee\xd9\x1a\x8d\x52\xd7\x81\xc6\xba\xad\x98\x46\x88\x4a\x64\x39\xca\x08\x0e\xc8\x9c\xd7\x6d\x23\x35\xc4\x61\x10\x19\x4f\x4f\x8d\x97\xad\xc4\x9c\x67\x4c\x63\x14\x06\x5d\xf7\x16\x24\x13\x6b\x84\x03\x61\x6e\x3c\x48\x2f\x9b\x1c\x95\xf1\x14\x3c\xeb\xc0\x1c\x0b\xef\xc0\xf9\x41\x91\x53\x04\x41\xb4\xe6\xba\xdc\xdc\xa5\x59\x53\x2f\x0b\xc7\x8b\xc9\x70\xe9\x65\x1c\xbd\x4c\xcd\xfc\xac\x25\x6b\xcb\x7d\xfa\x16\xbc\x3d\x0a\x2a\x2b\xb1\x66\xcb\x82\x63\x95\x47\x61\x12\x86\xcb\x25\xd8\xb3\xff\x19\xdf\x50\x36\x55\xae\x80\x81\x44\x57\x4e\x4c\xf3\x46\x18\x1a\x47\x6b\x60\x1a\xe4\x46\x68\x5e\x63\x1a\x3e\x30\x39\x71\x70\x0c\xc5\x46\x64\x71\x02\x87\xdb\x78\xd3\x6b\x6b\xd5\x85\x01\xfd\x6f\xc0\x7d\x33\x13\x76\x84\xf5\x11\xd4\xec\x1e\xe3\xdb\x6f\xa3\xad\x39\x5f\x40\xd7\x41\x85\xc2\xa3\x24\xe9\x27\x84\xf1\xc5\x2e\xd2\x46\x0f\xea\xd6\x10\xc5\xa1\xef\xbf\x81\x7f\xb9\x91\x75\x61\x10\x04\xe6\xe1\xba\xc5\xec\x08\x26\x32\x73\x44\xf2\xe0\x86\xdd\x55\x78\x04\x73\xbe\x53\x3a\x5f\x90\xca\x69\x53\x6d\x6a\xa1\x76\x28\x39\x89\x55\x5b\x9d\x1d\x79\x11\x7c\x34\x44\x8c\xd7\x04\x37\x8f\x2d\x1e\x01\xd1\x93\x5a\x3f\xab\xb3\xd4\x1c\x9a\xe2\x53\xfa\x92\xd5\xc6\xa3\xf5\xe4\x6e\xdc\x71\xe1\x60\x49\x46\x4c\xe8\xc1\xc6\xfe\xb1\xbf\xed\x5d\x91\x55\x76\x9e\x23\x92\x50\x54\x44\x47\x7b\xab\xb4\xe4\x62\xed\x51\x32\x0b\xd9\xa3\xa1\x20\x0a\x84\xd5\x70\x24\x90\xc6\x8e\xf0\x0a\x3f\xb6\x23\xe8\xe6\x89\x17\x3b\xb2\x86\xbd\x09\x4f\x3c\xba\x74\xbd\x97\x71\x9b\x76\x3f\x79\x45\xf7\xbf\xf6\x9e\x10\x5d\x6e\xe7\xf9\x7a\x2b\x75\x05\x76\xb1\x51\xfa\x24\xcf\xcf\x63\xba\x91\xe0\xc4\x29\x9c\xc1\xc8\xb7\x31\xf7\xe8\xfe\x8c\x95\x57\x72\xd6\xf4\x33\x56\x94\xfb\xc8\xf3\x4a\x3c\xa0\x54\xae\xfc\x30\x5d\x29\x77\x30\x6a\x3c\x57\x9e\xd6\x80\xa4\x4f\x4a\x61\x52\xb0\xbc\x30\x8a\x17\xef\x2f\xa0\xef\x9f\xf1\x72\xf5\x8b\xe7\xa2\xeb\x00\x2b\x8a\xe0\xf6\x9b\xad\x90\xee\xb9\xdb\xed\x35\x9e\x2d\x90\x35\xe1\xef\x22\xf9\xc0\x73\xbe\xcd\xce\x3c\xcf\xca\x35\xd8\x55\xa3\x5b\xa4\xa9\x4c\x26\x92\x24\x0c\x9e\x50\xbc\x7d\x96\xa8\x37\x52\x00\xe1\x1d\xf6\xb1\x6d\x80\xc3\x18\x38\xc9\xcd\xe8\xfb\x21\x59\xab\x68\x98\xb1\x3c\xbf\xda\xca\xa0\x46\x5d\x36\x79\x6a\x0c\xcc\x50\xdd\xb4\x39\xd3\xb8\x70\x7f\xdf\x36\x02\x81\x89\x1c\xbe\x6f\x50\x3e\xc2\xdd\x86\x57\x39\x4a\x05\xbc\x6e\x2b\xac\xcd\x58\xa6\x31\xc8\x85\x46\x69\x1a\x72\x1a\x6a\x43\xf1\xec\xe6\x41\x6c\x9a\xa5\x7f\x79\x4c\x4d\x55\x51\x53\x4d\xaf\xb1\xa2\xe9\x9a\x24\xa1\x1d\x92\xfb\xba\xa0\x01\xc9\x45\xe3\x2a\xf8\x77\x13\xa1\x03\xcc\xca\x25\x66\xc8\x1f\xac\xc2\xf0\x3c\x58\x6d\xb5\xea\x8d\x1b\x06\xd6\xcd\x85\xfb\x77\xe2\xa9\xe0\x95\xb6\x7e\x5a\xc9\x85\xb6\xcd\xc0\x1c\x6d\xb5\xc2\x60\xb9\x9c\xc2\x3a\x20\x64\x21\x7f\x0e\x91\x34\x0c\x0c\x06\x10\x4f\x02\xee\x7b\x38\xf4\x33\xec\xfb\x64\xe2\x3d\x36\xee\x60\x37\x78\x06\xe3\x60\xe6\x2d\x1d\xae\x57\x70\x0c\xac\x6d\x51\xe4\xf3\x1b\x3d\x9d\x05\x85\x9b\x84\x81\x4b\xcc\xe6\x0a\xb6\xc8\xcc\x18\x75\x07\x43\x8e\x16\x40\xdd\x18\xd7\xd5\x23\x58\xb8\x14\x34\x76\x77\x9a\x66\xb2\x2d\xa2\x97\x67\x6e\x6f\x33\xb3\xd7\xe3\xa2\xef\x29\x51\x57\xf8\x6f\x26\x12\xfb\xce\xfa\x3e\xfb\x21\x97\xbf\x45\x52\x6d\x43\x18\x4a\xe6\xd5\xbc\xd4\x3b\x99\xa8\x5f\x81\xbd\x00\x5a\x86\xd2\xaf\x25\x4a\x7c\x0d\x03\x5e\xd0\x4f\x28\xd8\x95\xd7\xeb\x51\xaf\x47\x94\xa7\x26\xad\x6c\x1e\xb8\x79\x73\x19\xac\x51\xa0\xe4\x99\x0b\x90\x8b\x35\x64\xac\x65\x77\xbc\xe2\xfa\xd1\x5b\xc0\xa0\x68\xe4\xac\x6e\xd2\x30\xa0\xde\x32\x75\xad\xb4\xdc\x64\x9a\x82\x9a\xb2\x37\x84\x62\x81\x32\xb0\x70\xb4\x34\x13\x80\x23\xd9\x5b\x90\x6c\x8b\xb3\xae\x07\x64\x8a\x59\xfa\x89\xf5\x17\xb7\x8e\x86\x2b\xcb\x6b\x91\xfe\xbc\xad\x91\x62\xc0\x0b\x40\x49\xad\xc4\x5b\x2f\xd3\xf3\x07\x56\x5d\xc5\xfe\xc9\x6c\xbf\xa3\x79\xb0\x80\x76\x01\x2a\xf9\x2f\x79\xf8\xd7\x31\x08\x5e\x59\xa7\x81\x4a\xcd\xa8\x96\xb2\x91\x31\x4a\x99\xd0\x56\x60\x96\x02\x57\x47\xc6\x0d\x81\x67\x7b\xdc\x76\xf7\xa2\x5f\xd7\x34\xe6\x86\x56\xc7\xa9\x4f\x0f\x9d\x2e\x6e\x99\xca\x58\x65\xcd\x13\x88\xae\xa2\xad\xa6\x19\xad\xe4\x6a\xa5\xbe\x7c\x59\x9d\xb9\x01\x6b\xcd\x8f\x21\xfa\x83\x55\x1b\x24\xed\x61\x2a\x8e\x74\xac\xce\x76\x10\x32\x04\x49\x15\x33\x23\x87\xe7\x6e\x89\xfa\x09\x31\xab\xb3\x81\x9a\x31\x1c\x23\xb5\x2c\x39\xf2\xec\x2a\x17\xbf\x68\xc1\x4c\x46\x0c\xf7\xec\x83\x13\x84\x8b\xdd\xf0\xbe\x02\x5f\x1a\xee\x06\xe1\x22\x5d\xa9\x1b\x4e\x43\x66\x02\xaf\x39\xf3\x75\x69\x6b\xe1\x05\x34\xd2\xda\x7c\x78\x34\x1d\x86\x1e\xff\x7f\xfd\xdb\xe5\xdc\x9c\xc4\xbb\xec\xc9\x62\x3f\x9f\xb3\x35\x64\x20\xd5\x2e\xab\xd7\xf4\x42\x12\x34\x86\xc8\x57\xd2\x6c\x7d\xb8\xa9\x3a\x30\xbe\x9f\xf2\x5d\xf7\xee\x29\x82\x97\x55\x41\x31\x2f\x01\xbb\x60\x8f\x9f\xc0\x63\x39\xec\x58\xa1\xc9\x83\x89\x79\xe0\x39\xa2\x3b\x3f\x31\x15\x99\xe5\x6e\x1a\xac\xc5\x70\xb0\xf1\x50\x63\x1e\x42\xba\x81\xac\xc4\xec\xde\xb0\x64\x5b\x55\xc9\xec\x3c\xc8\xd7\x08\x93\xf5\x7c\x1f\x64\xde\x35\xf1\x0c\x10\x8b\xd8\x27\xa6\x4c\x26\xf1\x6c\xe3\x77\x18\xf8\xc9\xfd\x3c\xb7\xe8\x2b\xd7\x65\xf4\x4f\xa4\x08\x3f\xb8\x2e\xcd\x3c\xe1\x0f\x28\x20\x6b\x44\xce\xcd\xe4\x52\x10\x37\xba\x44\x39\x3a\x55\xc9\x4b\xd1\x30\x26\x0a\xd2\x74\x1c\xc6\xe9\xd3\x55\x7c\x1f\x64\x26\xd9\x39\x6c\x8b\xf1\x33\xe8\xab\x64\xed\x47\x33\x18\xf6\x4c\x87\xc0\xcc\xbd\x3f\x17\xd0\xd2\xce\x4a\xf5\x65\xc3\x72\x1f\x56\x6d\xac\x12\xfb\x05\x41\x2d\x3e\x79\x5a\x99\x5e\x8d\x8e\x8f\x7f\x05\x00\x00\xff\xff\x8b\xe0\xfd\x2a\x58\x13\x00\x00") func templateDialectSqlEntqlTmplBytes() ([]byte, error) { return bindataRead( @@ -705,7 +705,7 @@ func templateDialectSqlEntqlTmpl() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "template/dialect/sql/entql.tmpl", size: 4926, mode: os.FileMode(420), modTime: time.Unix(1, 0)} + info := bindataFileInfo{name: "template/dialect/sql/entql.tmpl", size: 4952, 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/entql.tmpl b/entc/gen/template/dialect/sql/entql.tmpl index fa470ae3f..8b25cab0b 100644 --- a/entc/gen/template/dialect/sql/entql.tmpl +++ b/entc/gen/template/dialect/sql/entql.tmpl @@ -118,7 +118,10 @@ type predicateAdder interface { {{ range $f := $n.Fields }} {{ $type := $f.Type.Type.String }} {{ $iface := print (pascal $type) "P" }} - {{ if $f.IsTime }}{{ $iface = "TimeP" }}{{ else if $f.IsBytes }}{{ $iface = "BytesP" }}{{ else if $f.IsUUID }}{{ $iface = "ValueP" }}{{ end }} + {{- if $f.IsTime }}{{ $iface = "TimeP" }} + {{- else if or $f.IsBytes $f.IsJSON }}{{ $iface = "BytesP" }} + {{- else if $f.IsUUID }}{{ $iface = "ValueP" }} + {{- end }} // Where{{ $f.StructField }} applies the entql {{ $type }} predicate on the {{ $f.Name }} field. func (f *{{ $filter }}) Where{{ $f.StructField }}(p entql.{{ $iface }}) { f.Where(p.Field({{ $n.Package }}.{{ $f.Constant }})) diff --git a/examples/privacytenant/ent/entql.go b/examples/privacytenant/ent/entql.go index c70b2396f..94e04c891 100644 --- a/examples/privacytenant/ent/entql.go +++ b/examples/privacytenant/ent/entql.go @@ -60,7 +60,8 @@ var schemaGraph = func() *sqlgraph.Schema { }, Type: "User", Fields: map[string]*sqlgraph.FieldSpec{ - user.FieldName: {Type: field.TypeString, Column: user.FieldName}, + user.FieldName: {Type: field.TypeString, Column: user.FieldName}, + user.FieldFoods: {Type: field.TypeJSON, Column: user.FieldFoods}, }, } graph.MustAddE( @@ -280,6 +281,11 @@ func (f *UserFilter) WhereName(p entql.StringP) { f.Where(p.Field(user.FieldName)) } +// WhereFoods applies the entql json.RawMessage predicate on the foods field. +func (f *UserFilter) WhereFoods(p entql.BytesP) { + f.Where(p.Field(user.FieldFoods)) +} + // WhereHasTenant applies a predicate to check if query has an edge tenant. func (f *UserFilter) WhereHasTenant() { f.Where(entql.HasEdge("tenant")) diff --git a/examples/privacytenant/ent/internal/schema.go b/examples/privacytenant/ent/internal/schema.go index 9ac33a887..42d5e817c 100644 --- a/examples/privacytenant/ent/internal/schema.go +++ b/examples/privacytenant/ent/internal/schema.go @@ -9,4 +9,4 @@ // Package internal holds a loadable version of the latest schema. package internal -const Schema = `{"Schema":"github.com/facebook/ent/examples/privacytenant/ent/schema","Package":"github.com/facebook/ent/examples/privacytenant/ent","Schemas":[{"name":"Group","config":{"Table":""},"edges":[{"name":"tenant","type":"Tenant","unique":true,"required":true},{"name":"users","type":"User","ref_name":"groups","inverse":true}],"fields":[{"name":"name","type":{"Type":7,"Ident":"","PkgPath":"","Nillable":false,"RType":null},"default":true,"default_value":"Unknown","default_kind":24,"position":{"Index":0,"MixedIn":false,"MixinIndex":0}}],"policy":[{"Index":0,"MixedIn":true,"MixinIndex":0},{"Index":0,"MixedIn":true,"MixinIndex":1},{"Index":0,"MixedIn":false,"MixinIndex":0}]},{"name":"Tenant","config":{"Table":""},"fields":[{"name":"name","type":{"Type":7,"Ident":"","PkgPath":"","Nillable":false,"RType":null},"validators":1,"position":{"Index":0,"MixedIn":false,"MixinIndex":0}}],"policy":[{"Index":0,"MixedIn":true,"MixinIndex":0},{"Index":0,"MixedIn":false,"MixinIndex":0}]},{"name":"User","config":{"Table":""},"edges":[{"name":"tenant","type":"Tenant","unique":true,"required":true},{"name":"groups","type":"Group"}],"fields":[{"name":"name","type":{"Type":7,"Ident":"","PkgPath":"","Nillable":false,"RType":null},"default":true,"default_value":"Unknown","default_kind":24,"position":{"Index":0,"MixedIn":false,"MixinIndex":0}}],"policy":[{"Index":0,"MixedIn":true,"MixinIndex":0},{"Index":0,"MixedIn":true,"MixinIndex":1}]}],"Features":["privacy","entql","schema/snapshot"]}` +const Schema = `{"Schema":"github.com/facebook/ent/examples/privacytenant/ent/schema","Package":"github.com/facebook/ent/examples/privacytenant/ent","Schemas":[{"name":"Group","config":{"Table":""},"edges":[{"name":"tenant","type":"Tenant","unique":true,"required":true},{"name":"users","type":"User","ref_name":"groups","inverse":true}],"fields":[{"name":"name","type":{"Type":7,"Ident":"","PkgPath":"","Nillable":false,"RType":null},"default":true,"default_value":"Unknown","default_kind":24,"position":{"Index":0,"MixedIn":false,"MixinIndex":0}}],"policy":[{"Index":0,"MixedIn":true,"MixinIndex":0},{"Index":0,"MixedIn":true,"MixinIndex":1},{"Index":0,"MixedIn":false,"MixinIndex":0}]},{"name":"Tenant","config":{"Table":""},"fields":[{"name":"name","type":{"Type":7,"Ident":"","PkgPath":"","Nillable":false,"RType":null},"validators":1,"position":{"Index":0,"MixedIn":false,"MixinIndex":0}}],"policy":[{"Index":0,"MixedIn":true,"MixinIndex":0},{"Index":0,"MixedIn":false,"MixinIndex":0}]},{"name":"User","config":{"Table":""},"edges":[{"name":"tenant","type":"Tenant","unique":true,"required":true},{"name":"groups","type":"Group"}],"fields":[{"name":"name","type":{"Type":7,"Ident":"","PkgPath":"","Nillable":false,"RType":null},"default":true,"default_value":"Unknown","default_kind":24,"position":{"Index":0,"MixedIn":false,"MixinIndex":0}},{"name":"foods","type":{"Type":3,"Ident":"[]string","PkgPath":"","Nillable":true,"RType":null},"optional":true,"position":{"Index":1,"MixedIn":false,"MixinIndex":0}}],"policy":[{"Index":0,"MixedIn":true,"MixinIndex":0},{"Index":0,"MixedIn":true,"MixinIndex":1}]}],"Features":["privacy","entql","schema/snapshot"]}` diff --git a/examples/privacytenant/ent/migrate/schema.go b/examples/privacytenant/ent/migrate/schema.go index 68a9d9852..56b0b1e5a 100644 --- a/examples/privacytenant/ent/migrate/schema.go +++ b/examples/privacytenant/ent/migrate/schema.go @@ -49,6 +49,7 @@ var ( UsersColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "name", Type: field.TypeString, Default: "Unknown"}, + {Name: "foods", Type: field.TypeJSON, Nullable: true}, {Name: "user_tenant", Type: field.TypeInt, Nullable: true}, } // UsersTable holds the schema information for the "users" table. @@ -59,7 +60,7 @@ var ( ForeignKeys: []*schema.ForeignKey{ { Symbol: "users_tenants_tenant", - Columns: []*schema.Column{UsersColumns[2]}, + Columns: []*schema.Column{UsersColumns[3]}, RefColumns: []*schema.Column{TenantsColumns[0]}, OnDelete: schema.SetNull, diff --git a/examples/privacytenant/ent/mutation.go b/examples/privacytenant/ent/mutation.go index 345fe3ac7..40dab501e 100644 --- a/examples/privacytenant/ent/mutation.go +++ b/examples/privacytenant/ent/mutation.go @@ -780,6 +780,7 @@ type UserMutation struct { typ string id *int name *string + foods *[]string clearedFields map[string]struct{} tenant *int clearedtenant bool @@ -907,6 +908,56 @@ func (m *UserMutation) ResetName() { m.name = nil } +// SetFoods sets the foods field. +func (m *UserMutation) SetFoods(s []string) { + m.foods = &s +} + +// Foods returns the foods value in the mutation. +func (m *UserMutation) Foods() (r []string, exists bool) { + v := m.foods + if v == nil { + return + } + return *v, true +} + +// OldFoods returns the old foods value of the User. +// If the User object wasn't provided to the builder, the object is fetched +// from the database. +// An error is returned if the mutation operation is not UpdateOne, or database query fails. +func (m *UserMutation) OldFoods(ctx context.Context) (v []string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, fmt.Errorf("OldFoods is allowed only on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, fmt.Errorf("OldFoods requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldFoods: %w", err) + } + return oldValue.Foods, nil +} + +// ClearFoods clears the value of foods. +func (m *UserMutation) ClearFoods() { + m.foods = nil + m.clearedFields[user.FieldFoods] = struct{}{} +} + +// FoodsCleared returns if the field foods was cleared in this mutation. +func (m *UserMutation) FoodsCleared() bool { + _, ok := m.clearedFields[user.FieldFoods] + return ok +} + +// ResetFoods reset all changes of the "foods" field. +func (m *UserMutation) ResetFoods() { + m.foods = nil + delete(m.clearedFields, user.FieldFoods) +} + // SetTenantID sets the tenant edge to Tenant by id. func (m *UserMutation) SetTenantID(id int) { m.tenant = &id @@ -1013,10 +1064,13 @@ func (m *UserMutation) Type() string { // this mutation. Note that, in order to get all numeric // fields that were in/decremented, call AddedFields(). func (m *UserMutation) Fields() []string { - fields := make([]string, 0, 1) + fields := make([]string, 0, 2) if m.name != nil { fields = append(fields, user.FieldName) } + if m.foods != nil { + fields = append(fields, user.FieldFoods) + } return fields } @@ -1027,6 +1081,8 @@ func (m *UserMutation) Field(name string) (ent.Value, bool) { switch name { case user.FieldName: return m.Name() + case user.FieldFoods: + return m.Foods() } return nil, false } @@ -1038,6 +1094,8 @@ func (m *UserMutation) OldField(ctx context.Context, name string) (ent.Value, er switch name { case user.FieldName: return m.OldName(ctx) + case user.FieldFoods: + return m.OldFoods(ctx) } return nil, fmt.Errorf("unknown User field %s", name) } @@ -1054,6 +1112,13 @@ func (m *UserMutation) SetField(name string, value ent.Value) error { } m.SetName(v) return nil + case user.FieldFoods: + v, ok := value.([]string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetFoods(v) + return nil } return fmt.Errorf("unknown User field %s", name) } @@ -1083,7 +1148,11 @@ func (m *UserMutation) AddField(name string, value ent.Value) error { // ClearedFields returns all nullable fields that were cleared // during this mutation. func (m *UserMutation) ClearedFields() []string { - return nil + var fields []string + if m.FieldCleared(user.FieldFoods) { + fields = append(fields, user.FieldFoods) + } + return fields } // FieldCleared returns a boolean indicates if this field was @@ -1096,6 +1165,11 @@ func (m *UserMutation) FieldCleared(name string) bool { // ClearField clears the value for the given name. It returns an // error if the field is not defined in the schema. func (m *UserMutation) ClearField(name string) error { + switch name { + case user.FieldFoods: + m.ClearFoods() + return nil + } return fmt.Errorf("unknown User nullable field %s", name) } @@ -1107,6 +1181,9 @@ func (m *UserMutation) ResetField(name string) error { case user.FieldName: m.ResetName() return nil + case user.FieldFoods: + m.ResetFoods() + return nil } return fmt.Errorf("unknown User field %s", name) } diff --git a/examples/privacytenant/ent/schema/user.go b/examples/privacytenant/ent/schema/user.go index 3b0d6d516..154c7c824 100644 --- a/examples/privacytenant/ent/schema/user.go +++ b/examples/privacytenant/ent/schema/user.go @@ -28,6 +28,8 @@ func (User) Fields() []ent.Field { return []ent.Field{ field.String("name"). Default("Unknown"), + field.Strings("foods"). + Optional(), } } diff --git a/examples/privacytenant/ent/user.go b/examples/privacytenant/ent/user.go index 05c0db0ae..b9771dd83 100644 --- a/examples/privacytenant/ent/user.go +++ b/examples/privacytenant/ent/user.go @@ -7,6 +7,7 @@ package ent import ( + "encoding/json" "fmt" "strings" @@ -22,6 +23,8 @@ type User struct { ID int `json:"id,omitempty"` // Name holds the value of the "name" field. Name string `json:"name,omitempty"` + // Foods holds the value of the "foods" field. + Foods []string `json:"foods,omitempty"` // Edges holds the relations/edges for other nodes in the graph. // The values are being populated by the UserQuery when eager-loading is set. Edges UserEdges `json:"edges"` @@ -67,6 +70,8 @@ func (*User) scanValues(columns []string) ([]interface{}, error) { values := make([]interface{}, len(columns)) for i := range columns { switch columns[i] { + case user.FieldFoods: + values[i] = &[]byte{} case user.FieldID: values[i] = &sql.NullInt64{} case user.FieldName: @@ -100,6 +105,15 @@ func (u *User) assignValues(columns []string, values []interface{}) error { } else if value.Valid { u.Name = value.String } + case user.FieldFoods: + + if value, ok := values[i].(*[]byte); !ok { + return fmt.Errorf("unexpected type %T for field foods", values[i]) + } else if value != nil && len(*value) > 0 { + if err := json.Unmarshal(*value, &u.Foods); err != nil { + return fmt.Errorf("unmarshal field foods: %v", err) + } + } case user.ForeignKeys[0]: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for edge-field user_tenant", value) @@ -147,6 +161,8 @@ func (u *User) String() string { builder.WriteString(fmt.Sprintf("id=%v", u.ID)) builder.WriteString(", name=") builder.WriteString(u.Name) + builder.WriteString(", foods=") + builder.WriteString(fmt.Sprintf("%v", u.Foods)) builder.WriteByte(')') return builder.String() } diff --git a/examples/privacytenant/ent/user/user.go b/examples/privacytenant/ent/user/user.go index 9b484a91e..662d315be 100644 --- a/examples/privacytenant/ent/user/user.go +++ b/examples/privacytenant/ent/user/user.go @@ -17,6 +17,8 @@ const ( FieldID = "id" // FieldName holds the string denoting the name field in the database. FieldName = "name" + // FieldFoods holds the string denoting the foods field in the database. + FieldFoods = "foods" // EdgeTenant holds the string denoting the tenant edge name in mutations. EdgeTenant = "tenant" @@ -43,6 +45,7 @@ const ( var Columns = []string{ FieldID, FieldName, + FieldFoods, } // ForeignKeys holds the SQL foreign-keys that are owned by the User type. diff --git a/examples/privacytenant/ent/user/where.go b/examples/privacytenant/ent/user/where.go index 0bb08a628..ba89248f1 100644 --- a/examples/privacytenant/ent/user/where.go +++ b/examples/privacytenant/ent/user/where.go @@ -213,6 +213,20 @@ func NameContainsFold(v string) predicate.User { }) } +// FoodsIsNil applies the IsNil predicate on the "foods" field. +func FoodsIsNil() predicate.User { + return predicate.User(func(s *sql.Selector) { + s.Where(sql.IsNull(s.C(FieldFoods))) + }) +} + +// FoodsNotNil applies the NotNil predicate on the "foods" field. +func FoodsNotNil() predicate.User { + return predicate.User(func(s *sql.Selector) { + s.Where(sql.NotNull(s.C(FieldFoods))) + }) +} + // HasTenant applies the HasEdge predicate on the "tenant" edge. func HasTenant() predicate.User { return predicate.User(func(s *sql.Selector) { diff --git a/examples/privacytenant/ent/user_create.go b/examples/privacytenant/ent/user_create.go index af5f3a4f9..c99ac6484 100644 --- a/examples/privacytenant/ent/user_create.go +++ b/examples/privacytenant/ent/user_create.go @@ -39,6 +39,12 @@ func (uc *UserCreate) SetNillableName(s *string) *UserCreate { return uc } +// SetFoods sets the foods field. +func (uc *UserCreate) SetFoods(s []string) *UserCreate { + uc.mutation.SetFoods(s) + return uc +} + // SetTenantID sets the tenant edge to Tenant by id. func (uc *UserCreate) SetTenantID(id int) *UserCreate { uc.mutation.SetTenantID(id) @@ -166,6 +172,14 @@ func (uc *UserCreate) createSpec() (*User, *sqlgraph.CreateSpec) { }) _node.Name = value } + if value, ok := uc.mutation.Foods(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeJSON, + Value: value, + Column: user.FieldFoods, + }) + _node.Foods = value + } if nodes := uc.mutation.TenantIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, diff --git a/examples/privacytenant/ent/user_update.go b/examples/privacytenant/ent/user_update.go index 005574f29..286eb33ce 100644 --- a/examples/privacytenant/ent/user_update.go +++ b/examples/privacytenant/ent/user_update.go @@ -47,6 +47,18 @@ func (uu *UserUpdate) SetNillableName(s *string) *UserUpdate { return uu } +// SetFoods sets the foods field. +func (uu *UserUpdate) SetFoods(s []string) *UserUpdate { + uu.mutation.SetFoods(s) + return uu +} + +// ClearFoods clears the value of foods. +func (uu *UserUpdate) ClearFoods() *UserUpdate { + uu.mutation.ClearFoods() + return uu +} + // SetTenantID sets the tenant edge to Tenant by id. func (uu *UserUpdate) SetTenantID(id int) *UserUpdate { uu.mutation.SetTenantID(id) @@ -195,6 +207,19 @@ func (uu *UserUpdate) sqlSave(ctx context.Context) (n int, err error) { Column: user.FieldName, }) } + if value, ok := uu.mutation.Foods(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeJSON, + Value: value, + Column: user.FieldFoods, + }) + } + if uu.mutation.FoodsCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeJSON, + Column: user.FieldFoods, + }) + } if uu.mutation.TenantCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, @@ -316,6 +341,18 @@ func (uuo *UserUpdateOne) SetNillableName(s *string) *UserUpdateOne { return uuo } +// SetFoods sets the foods field. +func (uuo *UserUpdateOne) SetFoods(s []string) *UserUpdateOne { + uuo.mutation.SetFoods(s) + return uuo +} + +// ClearFoods clears the value of foods. +func (uuo *UserUpdateOne) ClearFoods() *UserUpdateOne { + uuo.mutation.ClearFoods() + return uuo +} + // SetTenantID sets the tenant edge to Tenant by id. func (uuo *UserUpdateOne) SetTenantID(id int) *UserUpdateOne { uuo.mutation.SetTenantID(id) @@ -462,6 +499,19 @@ func (uuo *UserUpdateOne) sqlSave(ctx context.Context) (_node *User, err error) Column: user.FieldName, }) } + if value, ok := uuo.mutation.Foods(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeJSON, + Value: value, + Column: user.FieldFoods, + }) + } + if uuo.mutation.FoodsCleared() { + _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeJSON, + Column: user.FieldFoods, + }) + } if uuo.mutation.TenantCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, diff --git a/examples/privacytenant/example_test.go b/examples/privacytenant/example_test.go index 0ba37e38d..d861b7212 100644 --- a/examples/privacytenant/example_test.go +++ b/examples/privacytenant/example_test.go @@ -35,8 +35,8 @@ func Example_PrivacyTenant() { // Output: // Tenant(id=1, name=GitHub) // Tenant(id=2, name=GitLab) - // User(id=1, name=a8m) - // User(id=2, name=nati) + // User(id=1, name=a8m, foods=[]) + // User(id=2, name=nati, foods=[Sushi Burritos]) // Group(id=1, name=entgo.io) } @@ -66,7 +66,7 @@ func Do(ctx context.Context, client *ent.Client) error { // Create 2 users connected to the 2 tenants we created above (a8m->GitHub, nati->GitLab). a8m := client.User.Create().SetName("a8m").SetTenant(hub).SaveX(admin) - nati := client.User.Create().SetName("nati").SetTenant(lab).SaveX(admin) + nati := client.User.Create().SetName("nati").SetTenant(lab).SetFoods([]string{"Sushi", "Burritos"}).SaveX(admin) hubView := viewer.NewContext(ctx, viewer.UserViewer{T: hub}) out := client.User.Query().OnlyX(hubView)