diff --git a/entc/gen/internal/bindata.go b/entc/gen/internal/bindata.go index e17cfd321..0c0121c5d 100644 --- a/entc/gen/internal/bindata.go +++ b/entc/gen/internal/bindata.go @@ -632,7 +632,7 @@ func templateDialectSqlByTmpl() (*asset, error) { return a, nil } -var _templateDialectSqlCreateTmpl = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xb4\x58\x6d\x6f\xdb\xc8\x11\xfe\x4c\xfe\x8a\x39\xc1\x0d\x48\x57\xa6\x9c\xa0\x28\x50\xa7\x3a\x20\x67\xc7\xad\x71\x77\x69\x0b\x3b\x87\xa0\x86\x11\x50\xe4\x50\x5a\x88\xda\x65\x76\x97\x8e\x0d\x83\xff\xbd\x98\xd9\x5d\x8a\x7a\xb1\xec\xbe\x7d\x48\x2c\xed\xce\xdb\xce\x3e\xf3\xec\x8c\x9e\x9e\x26\xc7\xf1\xb9\x6a\x1e\xb5\x98\x2f\x2c\xbc\x3b\x7d\xfb\xa7\x93\x46\xa3\x41\x69\xe1\x32\x2f\x70\xa6\xd4\x12\xae\x64\x91\xc1\x87\xba\x06\x16\x32\x40\xfb\xfa\x1e\xcb\x2c\xbe\x59\x08\x03\x46\xb5\xba\x40\x28\x54\x89\x20\x0c\xd4\xa2\x40\x69\xb0\x84\x56\x96\xa8\xc1\x2e\x10\x3e\x34\x79\xb1\x40\x78\x97\x9d\x86\x5d\xa8\x54\x2b\xcb\x58\x48\xde\xff\xe5\xea\xfc\xe3\xa7\xeb\x8f\x50\x89\x1a\xc1\xaf\x69\xa5\x2c\x94\x42\x63\x61\x95\x7e\x04\x55\x81\x1d\x38\xb3\x1a\x31\x8b\x8f\x27\x5d\x17\xc7\x74\x06\x98\x2b\xfb\xd8\xe0\x19\xa0\xb4\x73\x95\x09\x35\x41\x69\xe9\x5f\x31\x99\xa3\xcc\x68\xef\xba\x50\x0d\x42\x50\x81\x12\x2b\x21\x11\x46\xa5\xc8\x6b\x2c\xec\xc4\x7c\xab\x27\x85\xc6\xdc\xe2\x08\xba\x8e\x24\x8e\x66\xad\xa8\xe9\x08\x67\x53\x68\x72\x53\xe4\x35\x1c\x65\x6c\x25\xfb\xc9\xef\x78\x41\x8d\x05\x8a\x7b\x27\xd9\x7f\xee\xd5\xbd\xd0\xaa\xb5\xb9\x15\x4a\xb2\x39\x2d\xa4\x1d\xe8\x8d\xb2\xb0\x3b\x02\x92\x8f\xab\x56\x16\x90\x6c\xd8\xee\x3a\x38\x1e\x46\xd5\x75\x29\x98\x6f\xf5\x75\x7e\x8f\x49\x61\x1f\xa0\x50\xd2\xe2\x83\xcd\xce\xdd\xdf\x14\x12\x16\xcf\x3e\xe5\x2b\x84\xae\x1b\x03\x6a\xad\x74\x0a\x4f\x71\xf4\x55\xaa\x12\xc7\xf0\xd5\x34\x58\x50\x38\x5b\x7e\x32\x97\x87\xeb\x06\x8b\x24\x8d\x23\x51\x91\x2a\xc9\x99\x6f\xf5\x5c\xe7\xcd\x22\x3b\x67\x81\x4f\xaa\x64\xd7\xe3\x1d\x03\xa5\xa6\x4f\xde\x43\xfa\x9e\xf5\x7f\x98\x82\x14\x35\xb9\x27\x8b\x05\x6a\x3d\x06\xb5\x24\xb3\xc2\x5c\xff\xe3\x97\x73\x25\x8d\xd5\xb9\x90\xf6\x23\xc5\x99\xa0\xd6\xe9\x7b\x12\x20\x85\x88\x0c\x4c\x59\x29\x8e\xa2\x2e\x8e\x22\x8d\xb6\xd5\x92\x2c\xf2\xc1\x62\x5a\x7c\x7a\x3a\x01\x51\x41\x2e\x4b\x38\xca\xae\x2e\xb2\xcf\x06\xf5\x05\x5f\x73\x09\x89\xd2\x6e\xf1\xca\x5c\x5b\x2d\xe4\x3c\x7c\xfb\xfc\xf9\xea\x22\xa5\x9c\x47\xac\x3f\x39\x86\x0b\x05\x52\xd9\x85\x90\xf3\x31\xcc\xb0\xc8\x5b\x83\x84\x48\x83\xf0\x0e\x08\x48\x06\x56\xad\xb1\x30\x43\x30\x6d\xd3\xd4\x02\x4b\x98\x3d\x32\x66\x5b\x83\x3a\x83\xe3\x09\x9c\x74\x3e\x1c\xac\x0d\xae\x8d\x8b\x6a\x37\x30\xde\xa4\x8c\xf0\xa5\x64\x57\x17\x30\x9d\xc2\x29\x9f\x9a\x0d\xc8\x5e\xa4\xa4\x5c\x71\x46\xc9\xc6\x6f\x79\xdd\x62\x96\x08\x69\xff\xf8\x87\x94\xf6\xd7\xfa\x7c\x1d\x24\x73\xf3\xd8\x90\xf7\x44\x94\xe9\x8b\x11\x74\x5b\x0e\x87\x9f\x7d\xb2\x3d\x6c\xa4\xa8\xe3\xd7\x43\x74\x88\xa5\x1d\x48\x1e\x6f\x21\x8a\xc4\x18\xa1\xf7\xb9\x86\x24\xf6\x87\x82\x29\xbc\x19\xea\x3d\x15\x4a\x56\x62\x7e\xb6\x8b\x5b\x5e\xa7\x93\x38\x68\x4f\xe1\xcd\x1e\x07\x0c\xa8\x9b\x7c\x56\xa3\xb3\x90\xfd\x3d\x2f\x96\xf9\x9c\x2c\x67\xbc\x3c\x26\x81\xab\x8b\xb3\x81\xf6\xa5\xc0\xba\xec\x95\xa3\x1b\xe6\x9a\x8a\x16\xb3\x61\xb2\x33\x46\x71\x38\x1e\x8b\x9e\xab\xba\x5d\xc9\x5d\x4f\x41\x8d\x35\x72\x69\x83\x02\xff\xdf\xc5\x51\x1a\x07\x3c\x7e\xa8\x6b\xf5\x1d\x1c\x41\xc8\x39\x03\x6d\xcf\xa9\x08\x83\xc4\xda\xf8\x60\x51\x1a\xa1\xa4\x01\xa5\x19\x91\x60\x71\xd5\xd4\xb9\x45\x93\x31\xfb\xb1\xdd\xef\xc2\x2e\xe0\xc8\xae\x9a\xda\x10\xac\x56\xb9\x2d\x16\x37\x5e\x6e\x1f\x29\x4e\x28\xa1\x93\xe3\xd1\x1a\xcc\x3a\x97\x73\x74\x26\xc8\x82\xb7\xe5\xc0\x44\xfb\x0f\xc1\xad\x97\x39\x5a\xab\xee\xc3\xd8\x41\x74\x8a\x0a\x44\x19\xe8\x62\x83\x4c\x07\x99\xfc\xd5\xaf\xfd\x05\x29\x99\xc9\x80\x3d\x06\xa5\x21\x4a\x5e\xd8\xa8\xa2\xb0\xbc\x27\x22\x7f\xc8\x8a\x4f\xd8\x7b\x60\x34\x98\x3e\xb4\x7b\x32\x72\x28\xba\xea\x50\x6c\x1c\x8a\xb7\x38\x85\xbc\x69\x50\x96\xc9\x70\x75\xfc\x7a\x1c\x56\xcf\xa1\x90\xcf\x79\xe6\x23\x7d\x11\x97\xd5\x2e\x2a\x07\x14\xe3\x24\xae\xad\x6e\x0b\xcb\xf1\x50\xdd\xf3\xc1\xe9\xfe\xaa\xec\x93\xa8\x6b\x2a\x23\x97\xdb\xae\xa3\xda\x75\x39\x65\xf7\x07\x13\x8d\x2e\xd1\x1f\xcb\x39\xae\xf3\x4b\x5e\xcd\x73\xb9\xc5\xad\x48\xae\x2e\x0c\xa5\xb7\x46\x99\xb0\x5e\x0a\x3f\x7a\x3a\x5d\xe3\x9e\x6b\xa4\x84\x23\x18\x91\xa3\x11\xb9\x1d\xd1\x63\x66\x46\x60\x75\x8b\x30\xfa\x27\x6a\x35\x82\x91\x14\xb5\x07\x3c\x29\xf7\x75\xb4\x59\x1f\x25\x56\xc8\x56\x32\xa2\x26\xea\x45\x4a\x0f\x5d\x21\xa9\x50\x27\x6d\x53\xe6\x16\x33\x2e\x02\x57\x80\xdb\xd4\x1e\xb0\x8f\xd9\xdf\xbe\xcb\xcb\x9f\xd7\x2e\x4f\xe0\xa8\x62\x54\x1d\x61\x76\xa9\x34\x8a\xb9\xfc\x19\x1f\xc3\xfe\xe0\x3a\x96\xcf\xdf\xc7\xd2\x81\xe6\xc0\xb5\x70\x9e\x6e\x4f\xef\x76\x03\x73\x30\x74\xb7\xb1\x85\x4d\x5e\x1c\x03\x1d\x3d\xdd\xbd\xd2\xcd\x17\x83\x35\x62\xd7\x77\x79\x89\xc3\x2d\xd8\xd7\x59\x5b\x2f\xff\x0f\x7d\x58\x3c\x99\x00\x35\x4c\xfe\x55\x32\x4c\xa6\xc3\xa7\x85\x28\x54\x58\x81\x26\xb4\xa1\x65\x6e\xf3\x59\x6e\x30\x7b\xed\x7b\x77\xa0\x1f\xbb\xbd\x7b\xb6\x23\xa3\x04\x79\x22\x5e\x22\x09\xee\x61\xf8\x31\x83\x7a\xfb\xcd\xf3\xbe\x4d\x9a\xc6\x51\x5f\x28\xc1\xca\xa6\xbb\x97\xd4\xb9\xb4\x94\x1e\x5a\xf8\xd5\x2d\xbd\xac\x5b\x29\x0d\x82\xf3\xce\x85\xfc\x9c\x28\x17\x22\x65\x32\x11\x20\xa4\x1d\xbb\x36\x7f\x27\x55\x5c\xae\x83\x6b\x7f\xce\xdc\xad\xb8\x1b\xd6\x4f\xf6\xd7\xdc\x5c\x60\x95\xb7\xb5\x0d\x35\xe2\x25\xb3\xd2\x2d\x9b\x24\xdd\x45\x39\x35\x1b\xab\xd6\x82\x3f\x2c\x4c\xdd\x27\xbc\xa4\x38\x39\xd8\x3d\xf7\x39\x86\x15\x04\x56\x4f\x21\xf9\xcd\xbd\x01\xeb\x1b\x8d\xa2\x28\x50\x55\x78\x1a\x56\x99\xef\x7f\x82\x9e\xbf\x19\x0e\x89\x88\xee\x87\xf0\x28\x6c\xf6\xb7\xd5\xca\x66\xdc\x14\x57\xc9\xa8\x95\xf8\xd0\x60\x61\xb1\x84\x9e\x09\xa9\x29\x85\xdf\xdd\x8c\xc6\xb0\x72\xa6\xba\x60\xd0\xf7\xed\x21\x09\xc5\x02\x8b\x65\xb2\xdb\x8f\x47\x7b\xfa\xe9\xde\x4c\x50\xee\xdd\x4d\x7b\xcf\xbc\xef\xd8\x43\xdc\x8d\x81\x41\x7c\x2b\xee\x60\xe0\x71\x63\x92\xf0\xb9\x26\xef\x9c\xa8\x10\xa6\x80\x3f\x33\xc0\x02\x00\xd3\x93\xb7\x21\xae\xaf\x1c\x4e\xf0\xa9\xe8\xca\x7f\xff\xf6\xce\x65\x10\x13\x42\xcf\xee\xf4\xb1\x46\x07\x89\x86\x60\x7d\x6a\x5c\x4b\xee\xad\x4f\x26\x70\x25\xef\xd5\x92\x1b\x7c\xc8\x0b\xdb\xe6\x35\xa8\x06\xb5\x3b\xa9\x72\x1c\xc0\xbd\x93\x5d\xe7\xdb\x53\x43\xb1\xc8\x85\xcc\x9c\x21\x9f\xeb\xc1\x88\xf4\x13\x75\x54\xae\x78\x0f\xcf\x48\x6f\xf6\xa9\xf0\x13\xcf\x4f\xd2\x99\x4b\x6b\xb7\xf7\xd6\xfe\x83\x49\x2a\xda\x9e\xa6\xd6\x37\xed\xff\x6c\xa0\xe7\xb5\x28\x09\xc9\xe9\xbb\x31\x4f\xcd\x83\x07\xe9\x4d\x40\x4a\x2f\xb3\xf9\x66\x6d\xda\x29\x95\xa4\xc6\x8c\xde\xe3\xfe\x31\xfc\x6f\x86\xbb\xe8\x7f\x3e\xdf\x05\x1e\xe9\x47\xbc\xe8\xa5\x19\x2b\x5a\xb7\x33\x94\x86\xe1\xac\xb7\x43\x4a\xfd\xc4\x17\xaa\x6a\xef\xd0\x37\xa8\xbf\x43\xa3\xdf\x6b\x22\xeb\xf6\x46\xb1\xf5\x35\x00\xa0\xaf\x79\x1a\x06\xfb\xfe\xb0\x7f\x04\xa8\x98\x03\x05\x2c\x94\x5a\x9a\x14\x4e\xe0\xed\x7b\x10\xf0\xe3\x14\x4e\xdf\x83\x38\x39\x59\x73\xe4\x80\x2e\x58\xf6\x56\xdc\x11\x13\xa4\x61\x2a\x8d\xd6\xa5\x7f\xe7\x88\x80\xfa\x8d\x44\x8c\xa1\xb0\x0f\x29\x4f\xfe\xa2\xda\xe4\x8f\xbe\xe7\xa3\xb9\x7a\x1c\x68\xb0\xb7\x73\xda\x13\xc8\xde\xca\xec\xf9\xe3\x74\xc0\x1e\xbb\xe5\xb7\x5b\x0c\x1d\x07\x33\xcc\x51\x3f\x2d\xfb\xc6\xe3\x8b\xfb\x85\x6c\x89\xfc\x6d\x0c\xb3\xd6\x42\x93\x4b\x51\x18\x07\x6e\xc7\x8b\xa0\x8a\xa2\xd5\xe6\xdf\xea\x39\xbe\xec\x6f\x3a\xb6\x9a\x00\x9e\xad\xfb\x84\x6c\x1f\x3c\xf4\x2e\xeb\x1f\x7d\x06\xe7\xe5\x30\x99\x4c\x86\xa7\xbc\x8f\xbb\x41\x57\xf7\xaf\x00\x00\x00\xff\xff\x55\x6a\x0a\xfe\x4f\x14\x00\x00") +var _templateDialectSqlCreateTmpl = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xb4\x58\x6d\x6f\xdb\xc8\x11\xfe\x4c\xfe\x8a\x39\xc1\x0d\x48\x57\xa6\x9c\xa0\x28\x50\xa7\x3a\x20\x67\x27\xad\x70\xbd\xb4\x80\x9d\xc3\xa1\x86\x11\x50\xe4\x50\x5a\x88\xda\x65\x76\x97\x8e\x0d\x83\xff\xbd\x98\xd9\x5d\x8a\x7a\xb1\xec\x43\xdb\x0f\x89\xa5\xdd\x79\xdb\xd9\x67\x9e\x9d\xd1\xd3\xd3\xe4\x34\xbe\x54\xcd\xa3\x16\x8b\xa5\x85\x77\xe7\x6f\xff\x72\xd6\x68\x34\x28\x2d\x7c\xca\x0b\x9c\x2b\xb5\x82\x99\x2c\x32\xf8\x50\xd7\xc0\x42\x06\x68\x5f\xdf\x63\x99\xc5\x37\x4b\x61\xc0\xa8\x56\x17\x08\x85\x2a\x11\x84\x81\x5a\x14\x28\x0d\x96\xd0\xca\x12\x35\xd8\x25\xc2\x87\x26\x2f\x96\x08\xef\xb2\xf3\xb0\x0b\x95\x6a\x65\x19\x0b\xc9\xfb\xff\x98\x5d\x7e\xfc\x7c\xfd\x11\x2a\x51\x23\xf8\x35\xad\x94\x85\x52\x68\x2c\xac\xd2\x8f\xa0\x2a\xb0\x03\x67\x56\x23\x66\xf1\xe9\xa4\xeb\xe2\x98\xce\x00\x0b\x65\x1f\x1b\xbc\x00\x94\x76\xa1\x32\xa1\x26\x28\x2d\xfd\x2b\x26\x0b\x94\x19\xed\x5d\x17\xaa\x41\x08\x2a\x50\x62\x25\x24\xc2\xa8\x14\x79\x8d\x85\x9d\x98\x6f\xf5\xa4\xd0\x98\x5b\x1c\x41\xd7\x91\xc4\xc9\xbc\x15\x35\x1d\xe1\x62\x0a\x4d\x6e\x8a\xbc\x86\x93\x8c\xad\x64\x3f\xf9\x1d\x2f\xa8\xb1\x40\x71\xef\x24\xfb\xcf\xbd\xba\x17\x5a\xb7\x36\xb7\x42\x49\x36\xa7\x85\xb4\x03\xbd\x51\x16\x76\x47\x40\xf2\x71\xd5\xca\x02\x92\x2d\xdb\x5d\x07\xa7\xc3\xa8\xba\x2e\x05\xf3\xad\xbe\xce\xef\x31\x29\xec\x03\x14\x4a\x5a\x7c\xb0\xd9\xa5\xfb\x9b\x42\xc2\xe2\xd9\xe7\x7c\x8d\xd0\x75\x63\x40\xad\x95\x4e\xe1\x29\x8e\xbe\x4a\x55\xe2\x18\xbe\x9a\x06\x0b\x0a\x67\xc7\x4f\xe6\xf2\x70\xdd\x60\x91\xa4\x71\x24\x2a\x52\x25\x39\xf3\xad\x5e\xe8\xbc\x59\x66\x97\x2c\xf0\x59\x95\xec\x7a\xbc\x67\xa0\xd4\xf4\xc9\x7b\x48\xdf\xb3\xfe\x0f\x53\x90\xa2\x26\xf7\x64\xb1\x37\x35\x33\x97\x4a\x1a\xab\x73\x21\xed\x47\x8a\x30\x41\xed\xa2\x8c\x22\x52\x9b\xc2\x9b\x1d\x81\x27\xd4\x3a\x73\xa2\x29\x9f\xaa\x8b\xa3\x88\xfe\x69\xb4\xad\x96\xe4\x85\x97\x63\x5a\x7c\x7a\x3a\x03\x51\x41\x2e\x4b\x38\xc9\x66\x57\xd9\x17\x83\xfa\x8a\xaf\xbe\x84\x44\x69\xb7\x38\x33\xd7\x56\x0b\xb9\x08\xdf\xbe\x7c\x99\x5d\xa5\x74\x0f\x11\xeb\x4f\x4e\xe1\x4a\x81\x54\x76\x29\xe4\x62\x0c\x73\x2c\xf2\xd6\x20\xa1\xd4\x20\xbc\x03\x02\x97\x81\x75\x6b\x2c\xcc\x11\x4c\xdb\x34\xb5\xc0\x12\xe6\x8f\x8c\xe3\xd6\xa0\xce\xe0\x74\x02\x67\x9d\x0f\x07\x6b\x83\x1b\xe3\xa2\xda\x0f\x8c\x37\x29\x4b\x7c\x51\xd9\xec\x0a\xa6\x53\x38\xe7\x9c\xb0\x01\xd9\x8b\x94\x74\x2d\x9c\x65\xb2\xf1\x6b\x5e\xb7\x98\x25\x42\xda\x3f\xff\x29\xa5\xfd\x8d\x3e\x5f\x11\xc9\xdc\x3c\x36\xe4\x3d\x11\x65\xfa\x62\x04\xdd\x8e\xc3\xe1\x67\x9f\x6c\x0f\x25\x29\xea\xf8\xf5\xb0\x1d\xe2\x6b\x0f\xa6\xa7\x3b\x28\x23\x31\xc6\xc3\x7d\xae\x21\x89\xfd\xa1\x08\x17\x43\xbd\xa7\x42\xc9\x4a\x2c\x2e\xf6\xb1\xcc\xeb\x74\x12\x07\xf7\x29\xbc\x39\xe0\x80\xe1\x76\x93\xcf\x6b\x74\x16\xb2\x7f\xe5\xc5\x2a\x5f\x90\xe5\x8c\x97\xc7\x24\x30\xbb\xba\x18\x68\x7f\x12\x58\x97\xbd\x72\x74\xc3\xfc\x53\xd1\x62\x36\x4c\x76\xc6\xf0\x0d\xc7\x63\xd1\x4b\x55\xb7\x6b\xb9\xef\x29\xa8\xb1\x46\x2e\x6d\x50\xe0\xff\xbb\x38\x4a\xe3\x80\xc7\x0f\x75\xad\xbe\x83\x23\x0d\xb9\x60\xa0\x1d\x38\x15\x61\x90\x98\x1c\x1f\x2c\x4a\x23\x94\x34\xa0\x34\x23\x12\x2c\xae\x9b\x3a\xb7\x68\x32\x66\x44\xb6\xfb\x5d\xd8\x25\x9c\xd8\x75\x53\x1b\x82\xd5\x3a\xb7\xc5\xf2\xc6\xcb\x1d\x22\xca\x09\x25\x74\x72\x3a\xda\x80\x59\xe7\x72\x81\xce\x04\x59\xf0\xb6\x1c\x98\x68\xff\x21\xb8\xf5\x32\x27\x1b\xd5\x43\x18\x3b\x8a\x4e\x51\x81\x28\xc7\xa0\x56\x81\xc1\x7a\x82\x1d\x64\xf2\x17\xbf\xf6\x37\xa4\x64\x26\xe9\x7b\x92\x7f\xda\x29\x0d\x51\xf2\xc2\x56\x15\x85\xe5\x03\x11\xf9\x43\x56\x7c\xc2\xde\x03\xa3\xc1\xf4\xa1\xdd\x93\x91\x63\xd1\x55\xc7\x62\xe3\x50\xbc\xc5\x29\xe4\x4d\x83\xb2\x4c\x86\xab\xe3\xd7\xe3\xb0\x7a\x0e\x85\x7c\xce\x0b\x1f\xe9\x8b\xb8\xac\xf6\x51\x39\xa0\x18\x27\x71\x6d\x75\x5b\x58\x8e\x87\xea\x9e\x0f\x4e\xf7\x57\x65\x9f\x45\x5d\x53\x19\xb9\xdc\x76\x1d\xd5\xae\xcb\x29\xbb\x3f\x9a\x68\x74\x89\xfe\x58\x2e\x70\x93\x5f\xf2\x6a\x9e\xcb\x2d\xee\x44\x32\xbb\x32\x94\xde\x1a\x65\xc2\x7a\x29\xfc\xe8\xe9\x74\x83\x7b\xae\x91\x12\x4e\x60\x44\x8e\x46\xe4\x76\x44\x0f\x9c\x19\x81\xd5\x2d\xc2\xe8\xdf\xa8\xd5\x08\x46\x52\xd4\x1e\xf0\xa4\xdc\xd7\xd1\x76\x7d\x94\x58\x21\x5b\xc9\x88\x9a\xa8\x3f\x29\x3d\x74\x85\xa4\x42\x9d\xb4\x4d\x99\x5b\xcc\xb8\x08\x5c\x01\xee\x52\x7b\xc0\x3e\x66\xff\xfc\x2e\x3f\xfd\xbc\x71\x79\x06\x27\x15\xa3\xea\x04\xb3\x4f\x4a\xa3\x58\xc8\x9f\xf1\x31\xec\x0f\xae\x63\xf5\xfc\x7d\xac\x1c\x68\x8e\x5c\x0b\xe7\xe9\xf6\xfc\x6e\x3f\x30\x07\x43\x77\x1b\x3b\xd8\xe4\xc5\x31\xd0\xd1\xd3\xfd\x2b\xdd\x7e\x31\x58\x23\x76\xbd\x98\x97\x38\xde\x96\x7d\x9d\xb7\xf5\xea\xff\xd0\x9b\xc5\x93\x09\x50\x13\xe5\x5f\x25\xc3\x64\x3a\x7c\x5a\x88\x42\x85\x15\x68\x42\x6b\x5a\xe6\x36\x9f\xe7\x06\xb3\xd7\xbe\x77\x47\x7a\xb4\xdb\xbb\x67\xbb\x34\x4a\x90\x27\xe2\x15\x92\xe0\x01\x86\x1f\x33\xa8\x77\xdf\x3c\xef\xdb\xa4\x69\x1c\xf5\x85\x12\xac\x6c\xbb\x7b\x49\x9d\x4b\x4b\xe9\xa1\x85\x5f\xdc\xd2\xcb\xba\x95\xd2\x20\x38\xef\x5c\xc8\xcf\x89\x72\x21\x52\x26\x13\x01\x42\xda\xb1\x6b\xfd\xf7\x52\xc5\xe5\x3a\xb8\xf6\xe7\xcc\xdd\x8a\xbb\x61\xfd\x64\x7f\xcf\xcd\x15\x56\x79\x5b\xdb\x50\x23\x5e\x32\x2b\xdd\xb2\x49\xd2\x7d\x94\x53\xb3\xb1\x6e\x2d\xf8\xc3\xc2\xd4\x7d\xc2\x4f\x14\x27\x07\x7b\xe0\x3e\xc7\xb0\x86\xc0\xea\x29\x24\xbf\xba\x37\x60\x73\xa3\x51\x14\x05\xaa\x0a\x4f\xc3\x3a\xf3\xfd\x4f\xd0\xf3\x37\xc3\x21\x11\xd1\xfd\x10\x1e\x85\xed\xfe\xb6\x5a\x5b\xd7\x03\x57\xc9\xa8\x95\xf8\xd0\x60\x61\xb1\x84\x9e\x09\xa9\x29\x85\x3f\xdc\x8c\xc6\xb0\x76\xa6\xba\x60\xd0\xf7\xf2\x21\x09\xc5\x12\x8b\x55\xb2\xdf\xa3\x47\x07\xfa\xe9\xde\x4c\x50\xee\xdd\x4d\x7b\xcf\xbc\xef\xd8\x43\xdc\x8d\x81\x41\x7c\x2b\xee\x60\xe0\x71\x6b\xba\xf0\xb9\x26\xef\x9c\xa8\x10\xa6\x80\xbf\x32\xc0\x02\x00\xd3\xb3\xb7\x21\xae\xaf\x1c\x4e\xf0\xa9\xe8\xca\xff\xf8\xf6\xce\x65\x10\x13\x42\xcf\xfe\x44\xb2\x41\x07\x89\x86\x60\x7d\x6a\x5c\x4b\xee\xad\x4f\x26\x30\x93\xf7\x6a\xc5\x0d\x3e\xe4\x85\x6d\xf3\x1a\x54\x83\xda\x9d\x54\x39\x0e\xe0\xde\xc9\x6e\xf2\xed\xa9\xa1\x58\xe6\x42\x66\xce\x90\xcf\xf5\x60\x6c\xfa\x89\x3a\x2a\x57\xbc\xc7\xe7\xa6\x37\x87\x54\xf8\x89\xe7\x27\xe9\xc2\xa5\xb5\x3b\x78\x6b\xaf\x9e\xae\xa2\xdf\x37\x61\x6d\x6e\xdf\xff\xd9\x42\xd4\x6b\x91\x13\x12\xd6\x77\x68\x9e\xae\x07\x8f\xd4\x9b\x80\x9e\x5e\x66\xfb\x1d\xdb\xb6\x53\x2a\x49\xcd\x1a\xbd\xd1\xfd\x03\xf9\xdf\x0c\x7c\xd1\xff\x7c\xe6\x0b\xdc\xd2\x8f\x7d\xd1\x4b\x73\x57\xb4\x69\x71\x28\x0d\xc3\xf9\x6f\x8f\xa8\xfa\x29\x30\x54\xda\xc1\x41\x70\x50\x93\xc7\xc6\xc1\xd7\x44\xd6\x1d\x8c\x62\xe7\x6b\x00\x40\xcf\x03\x34\x20\xf6\x3d\x63\xff\x30\x50\x81\x07\x5a\x58\x2a\xb5\x32\x29\x9c\xc1\xdb\xf7\x20\xe0\xc7\x29\x9c\xbf\x07\x71\x76\xb6\xe1\xcd\x01\x85\xb0\xec\xad\xb8\x23\x76\x48\xc3\xa4\x1a\x6d\xe8\xe0\xce\x91\x03\xf5\x20\x89\x18\x43\x61\x1f\x52\xfe\x35\x40\x54\xdb\x9c\xd2\xf7\x81\x34\x6b\x8f\x03\x35\xf6\x76\xce\x7b\x52\x39\x58\xad\x3d\xa7\x9c\x0f\x18\x65\xbf\x24\xf7\x8b\xa1\xe3\x60\x86\x39\xea\x27\x68\xdf\x8c\xfc\xe6\x7e\x49\x5b\x21\x7f\x1b\xc3\xbc\xb5\xd0\xe4\x52\x14\xc6\x81\xdb\x71\x25\xa8\xa2\x68\xb5\xf9\x5d\x7d\xc8\x6f\x87\x1b\x91\x9d\xc6\x80\xe7\xed\x3e\x21\xbb\x07\x0f\xfd\xcc\xe6\xc7\xa1\xc1\x79\x39\x4c\xa6\x99\xe1\x29\xef\xe3\x6e\xd0\xe9\xfd\x27\x00\x00\xff\xff\xb3\x76\x36\xee\x77\x14\x00\x00") func templateDialectSqlCreateTmplBytes() ([]byte, error) { return bindataRead( @@ -647,7 +647,7 @@ func templateDialectSqlCreateTmpl() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "template/dialect/sql/create.tmpl", size: 5199, mode: os.FileMode(420), modTime: time.Unix(1, 0)} + info := bindataFileInfo{name: "template/dialect/sql/create.tmpl", size: 5239, mode: os.FileMode(420), modTime: time.Unix(1, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -732,7 +732,7 @@ func templateDialectSqlEntqlTmpl() (*asset, error) { return a, nil } -var _templateDialectSqlErrorsTmpl = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x6c\x90\xc1\x6a\xdc\x30\x10\x86\xcf\xab\xa7\xf8\xc9\xa1\x64\x97\xad\x9d\xe6\xd6\xde\xc2\xb2\x2d\x0b\xa1\x50\xd2\x17\x70\xa4\xb1\x2d\xaa\xce\x38\x33\xe3\xc2\x62\xfc\xee\xc5\xeb\x2c\x84\x90\x83\x40\xe8\xfb\x7e\xfd\x23\x4d\x53\xbd\x0b\x07\x19\xce\x9a\xbb\xde\x71\x7f\xf7\xe5\xeb\xe7\x41\xc9\x88\x1d\xdf\x9b\x48\xcf\x22\x7f\x70\xe2\x58\xe1\xa1\x14\x5c\x24\xc3\xc2\xf5\x1f\xa5\x2a\xfc\xee\xb3\xc1\x64\xd4\x48\x88\x92\x08\xd9\x50\x72\x24\x36\x4a\x18\x39\x91\xc2\x7b\xc2\xc3\xd0\xc4\x9e\x70\x5f\xdd\x5d\x29\x5a\x19\x39\x85\xcc\x17\xfe\x78\x3a\x1c\x7f\x3e\x1d\xd1\xe6\x42\x78\x3d\x53\x11\x47\xca\x4a\xd1\x45\xcf\x90\x16\xfe\xa6\xcc\x95\xa8\x0a\xbb\x7a\x9e\x43\x58\xde\x80\x4e\xfc\x3c\xd0\x37\x10\x7b\x27\x55\x96\x9a\xd8\x97\x15\xeb\x8e\xb8\xfa\xa1\xcd\xd0\xe3\x8d\x1e\x47\x73\xf9\x0b\x52\x15\x35\x34\x9c\xae\xdb\xbe\xe1\x54\x48\x0d\xad\x28\xec\xa5\x20\xe5\xa6\x50\x74\x5b\xd3\xd3\x84\x44\x6d\x66\xc2\xcd\x2b\xa8\xed\xa5\xd4\x6b\xf8\x06\xf3\x1c\xda\x91\x23\xb2\x3d\xfd\x7a\x3c\x08\x9b\x6b\x93\xd9\x8f\x0b\xbe\x25\xd5\xb5\x65\x8b\xdb\xdd\x3b\xb8\xc7\xb3\x48\xd9\x62\x0a\x9b\xdc\x2e\xbd\xdd\x32\x71\x75\xb2\x0f\x2e\xb9\x58\x1b\x25\x1f\x95\xf1\xe9\x9d\x30\x91\x6a\xb5\xaa\xdb\xfd\x52\x37\xef\xe1\x3a\x52\xd8\xcc\xe1\x9a\xe1\x5c\xf6\x68\x9b\x62\x14\x2e\xff\x01\xe2\xb4\x8c\xfe\x3f\x00\x00\xff\xff\x3d\xf4\x36\xc4\x0d\x02\x00\x00") +var _templateDialectSqlErrorsTmpl = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x4c\x8f\xc1\x6a\xf3\x30\x10\x84\xef\x7e\x8a\x21\xc7\xc0\x6f\xe7\xcf\xad\xbd\x85\x90\x96\x40\xe9\xa5\x7d\x01\x57\x1a\x5b\xa2\xea\xae\xb3\x92\x0b\xc1\xe4\xdd\x8b\xe3\x04\x72\x58\x18\xf6\xfb\x86\x65\xa7\xa9\x59\x57\x7b\x1d\xce\x16\xfb\x50\xb0\xdd\xfc\x7f\xfa\x37\x18\x33\xa5\xe0\xa5\x75\xfc\x52\xfd\xc6\x51\x5c\x8d\x5d\x4a\xb8\x4a\x19\x33\xb7\x5f\xfa\xba\xfa\x0c\x31\x23\xeb\x68\x8e\x70\xea\x89\x98\x91\xa2\xa3\x64\x7a\x8c\xe2\x69\x28\x81\xd8\x0d\xad\x0b\xc4\xb6\xde\xdc\x29\x3a\x1d\xc5\x57\x51\xae\xfc\xed\xb8\x3f\xbc\x7f\x1c\xd0\xc5\x44\xdc\x76\xa6\x5a\xe0\xa3\xd1\x15\xb5\x33\xb4\x43\x79\x38\x56\x8c\xac\xab\x75\x73\xb9\x54\xd5\xfc\x03\x7a\x2d\xe7\x81\xcf\xa0\x94\x5e\xeb\xa8\x0d\xa5\xcc\xe3\x9a\x9e\x52\xbf\x5a\x3b\x04\x3c\xe8\x6e\xcc\x45\x7f\x40\x33\xb5\x8c\x56\xfc\x3d\x86\x56\x7c\xa2\x65\x74\x6a\xc8\xa7\x04\x1f\xdb\x44\x57\xf2\xd2\x9e\x26\x78\x76\x51\x88\xd5\x0d\x34\xf9\x94\x9a\xa5\xbc\xc2\x62\x50\xfc\x9c\xfe\x02\x00\x00\xff\xff\x4e\x51\xff\xc7\x5c\x01\x00\x00") func templateDialectSqlErrorsTmplBytes() ([]byte, error) { return bindataRead( @@ -747,7 +747,7 @@ func templateDialectSqlErrorsTmpl() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "template/dialect/sql/errors.tmpl", size: 525, mode: os.FileMode(420), modTime: time.Unix(1, 0)} + info := bindataFileInfo{name: "template/dialect/sql/errors.tmpl", size: 348, mode: os.FileMode(420), modTime: time.Unix(1, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -932,7 +932,7 @@ func templateDialectSqlTxTmpl() (*asset, error) { return a, nil } -var _templateDialectSqlUpdateTmpl = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xbc\x58\xeb\x6f\xe3\xb8\x11\xff\x6c\xff\x15\xb3\x82\x1b\xd8\x81\x57\x4e\xf7\x5b\xbd\x70\x81\x5c\x1e\x85\xd1\xdd\xbd\xed\x3a\x77\x1f\x7a\x38\x04\x8a\x38\x92\x09\xcb\xa4\x42\x52\xb9\xa4\x86\xfe\xf7\x62\xf8\x90\x65\xcb\xce\x63\xbb\xbd\x0f\x4e\x24\xce\x83\x33\xbf\x79\x90\xa3\xcd\x66\x72\xda\xbf\x90\xe5\x93\xe2\xf9\xd2\xc0\x87\xb3\xbf\xfe\xed\x7d\xa9\x50\xa3\x30\x70\x9d\xa4\x78\x27\xe5\x0a\xe6\x22\x8d\xe1\xbc\x28\xc0\x32\x69\x20\xba\x7a\x40\x16\xf7\x6f\x96\x5c\x83\x96\x95\x4a\x11\x52\xc9\x10\xb8\x86\x82\xa7\x28\x34\x32\xa8\x04\x43\x05\x66\x89\x70\x5e\x26\xe9\x12\xe1\x43\x7c\x16\xa8\x90\xc9\x4a\xb0\x3e\x17\x96\xfe\x69\x7e\x71\xf5\x65\x71\x05\x19\x2f\x10\xfc\x9a\x92\xd2\x00\xe3\x0a\x53\x23\xd5\x13\xc8\x0c\x4c\x6b\x33\xa3\x10\xe3\xfe\xe9\xa4\xae\xfb\x7d\xf2\x01\x72\x69\x9e\x4a\x9c\x02\x0a\x93\xcb\x98\xcb\x09\x0a\x43\xbf\x74\x92\xa3\x88\x89\xb6\x48\x65\x89\x10\x44\x80\x61\xc6\x05\x42\xc4\x78\x52\x60\x6a\x26\xfa\xbe\x98\x54\x25\x4b\x0c\x46\x50\xd7\xc4\x31\x28\x57\x39\x4c\x67\x30\x88\xad\x68\xfc\x35\x49\x57\x49\x8e\x81\x7a\x57\xf1\x82\x1c\x9c\xce\xa0\x4c\x74\x9a\x14\x0d\xe3\x4f\x9e\xe2\x19\x15\xa6\xc8\x1f\x1c\x67\xf3\xdc\x88\x7b\xa6\x75\x65\x12\xc3\xa5\xb0\xea\x14\x17\xa6\x25\x17\xc5\x81\xda\x98\x26\x05\x12\xe7\x32\xd1\x8b\x2a\xcb\xf8\xe3\x56\x5f\xf4\xb3\x08\x1e\xbc\x87\xc1\x7f\x50\x49\x62\x3c\x83\xba\xde\x6c\x80\x67\x4e\xd4\xbe\x38\xe2\x0c\x22\xc1\x8b\xc8\x2d\xa1\x60\x8d\xa8\x42\x43\x92\x91\x88\x0e\xc9\x12\x75\x06\xd1\xad\x90\x0c\x77\x85\xfb\x59\x25\x52\x18\xee\x78\x5e\xd7\x70\xda\xc6\xac\xae\x47\xa0\xef\x8b\x45\xf2\x80\xc3\xd4\x3c\x42\x2a\x85\xc1\x47\x13\x5f\xb8\xff\xa3\x20\x6e\x48\x72\x67\x6f\xab\x26\xfe\x92\xac\xbd\x21\x58\x68\x7a\xe2\xc2\x34\x16\x8c\x01\x95\xa2\x9f\x54\x23\xd8\xf4\x7b\xb7\xba\xc4\x94\x5c\x39\xd1\xf7\x45\xae\x92\x72\x19\xff\x62\x03\xbd\x28\x31\xdd\xf4\x7b\xbd\x2f\x92\xe1\xb4\x45\xa5\xf7\x40\xeb\xdd\x24\x77\x05\x4e\xc1\x6e\xbb\xcd\x80\xd8\x2e\x8f\x89\xe1\x42\x16\xd5\x5a\xe8\x2e\x8b\x27\x58\xa6\xf9\x65\x7b\x83\x6b\x8e\x05\x6b\x76\xe8\xdd\xd8\xcc\xcd\x68\x31\xb6\x4a\xe6\x97\x31\xad\x11\x1c\xda\x78\x5f\xad\x1a\xbf\x59\x77\xaf\x20\x66\x25\x12\x61\x82\x80\xfd\x4b\x7f\xea\x7e\x8f\xa2\xba\x05\xb2\xdf\xeb\x71\x36\x06\xb9\x22\x64\x76\x32\xb0\xa5\xee\xb3\x5f\xfb\x87\x8d\xc4\x70\x44\x42\x19\xbc\x93\x2b\xb0\x96\x2b\x34\x95\x12\xd0\xe4\x12\x61\x7f\xf2\x6b\x52\x70\x66\xa5\xae\x28\x04\x1b\xb2\x7f\x0a\xd1\xfc\x32\xb2\x81\x99\x42\xb6\x36\xb1\x25\x65\xc3\x68\xcd\xb5\xe6\x22\x87\x76\x54\xe3\xf9\x25\x64\x52\x81\xaf\xc6\x11\x99\x4a\x3f\x1b\x47\x1b\x1c\x32\xed\xd7\xa4\xa8\x10\x66\xc0\x99\x33\xca\xc2\xa7\x83\x33\xad\xcc\x8b\x1d\xe5\x23\x14\x28\x86\xee\x79\x04\x7f\x87\x33\xe7\x42\x4b\xa9\x8f\x17\xcc\x60\x9d\xac\x70\xf8\xdb\xef\xda\x28\x2e\xf2\x31\x9c\x8d\xdb\xb2\xa3\xa3\x62\x49\x59\xa2\x60\xc3\x2e\x6d\xfc\x9a\x78\x59\xbd\xe4\xf7\xed\x18\x32\xdb\x2b\x12\x91\x63\xf0\xcb\x65\x0a\x81\xbf\xaf\xca\xe2\xed\x36\x1a\x66\x23\xcf\x18\x42\x23\x78\x71\x34\x24\xd9\x81\x78\x84\xb6\x57\xd7\x53\xe0\xe2\x81\xe4\x9c\x05\xf0\x97\x7b\x1b\x94\xfb\x0a\xd5\x53\x34\x86\xcc\x86\xc5\x05\xc6\xe1\x0f\xef\x66\xaf\x71\x33\x18\xf8\x56\x04\xb3\xd1\x76\x3f\x9f\x11\x94\xd0\xbe\xe9\x90\x05\xa5\x3e\x94\xca\xa5\x42\xc6\xd3\xc4\xa0\xcf\x80\xb2\x15\x7d\xb7\xcf\xd7\xc0\x01\x33\xa0\xde\x35\xd4\x58\xd8\x53\x07\x4e\xf5\x7d\x11\x2f\xfc\x9b\x87\x96\x40\xe0\xdb\xf0\x94\x21\x34\xa5\xfe\x8d\xff\xde\x88\x8e\x5a\x66\x7a\x4b\x1d\xff\x20\x73\x47\x4a\xa8\xac\x6b\x17\x5e\x5b\x8f\xa1\x42\xa5\x82\xa1\x90\x06\x06\x59\x3c\x5f\x93\x2f\x77\x05\x8e\xe8\xcd\xb5\xad\x4b\xcc\x92\xaa\x30\x5e\x86\x3c\x7f\xa0\x5a\x78\xae\x96\xb3\x4e\x25\x7f\x84\x50\xc4\x01\x06\x67\x49\xbc\xb0\x8d\x7d\x27\x10\x5b\xca\xf8\x78\x13\xeb\xb6\xb1\xec\x58\x13\xeb\xf5\x6c\xf1\x4e\xbd\xdd\x7e\xed\xb9\xd6\x96\x75\x1a\x5b\xaf\x57\xb7\x12\xa2\xe9\x6d\x59\xbc\xa8\xca\x52\x2a\xa3\x83\xc3\xe7\x8c\x05\xa4\x5e\x84\xea\x9c\x31\x64\x6e\xbf\x85\x51\x55\x6a\xac\x8f\x1d\xbc\x76\x01\xa3\x0d\x0e\x03\x76\xce\xd8\xb3\x80\xbd\x05\xb1\x83\x90\xbd\x19\xb3\x00\x5a\x0b\xb5\x50\x40\x87\xde\x1c\xa2\x3f\x97\x84\x4f\x52\xb4\x12\xee\x70\x8e\xed\x62\x76\x51\x60\xa2\x90\x0d\x47\x07\xd3\xcc\x52\x8f\xe0\x66\x69\x3f\x2a\xd5\xfe\x97\xb4\x6a\x23\xb2\xff\xec\xcb\x19\x5d\x39\x5f\xb1\x1c\x7d\x15\x1f\x81\x07\x9b\x12\xf4\xc0\xd8\xb4\x72\xd8\x90\xbe\x3f\xb8\x59\x02\x3e\x1a\xda\x63\x00\x11\x29\x8c\x48\x7d\x1d\x42\x05\x06\xd7\x65\x41\x6d\x6a\xe7\xce\xca\x30\x43\xcb\x1b\x1f\x0c\xa3\x03\xd6\x9a\x77\x18\xf3\x16\x69\x0c\xa4\x69\xe4\x8f\x5b\x9f\x00\xb6\x11\x61\xfc\x8b\xe0\xf7\x55\xb0\xc6\x2e\x33\x3c\xd8\x6f\xbf\xe1\x5a\x3e\xb8\x2a\xc2\xbd\x8c\x98\x5f\x6a\x2a\x24\xea\xc2\x56\xdc\x35\xe2\x93\x13\x77\xa6\xbd\x05\xb0\x67\x11\x8b\xe8\xe0\xd0\x11\x18\x55\x21\x44\xff\x46\x25\xa3\xe6\x7e\xe2\x62\xfc\x7a\x30\xf7\xd0\xfc\x4e\x38\x1b\x3c\x1b\x4d\xcf\x21\xf8\x7a\xe8\x5e\x4c\x9e\x17\xa1\xf8\x11\x69\x75\xa0\x01\x36\x84\x9d\x94\xda\x2f\xa1\xc9\x29\x4d\x95\xf2\x0f\x70\xde\x8b\xdc\x0e\x7e\x07\x2e\xe9\x70\xf7\x44\x83\x9d\xf3\x50\x73\x29\x34\x9d\x91\x95\xa6\xf1\xd2\x5b\xaf\x63\x3b\xd9\x6d\xd1\x18\x98\x75\x59\x58\x7c\xd7\x89\x49\x97\x37\x07\xbd\x74\x57\xcc\x09\xd9\x3c\x39\x8d\x9c\x6f\xad\xe2\x26\x15\xb6\xbe\x9d\xae\x2d\x10\x8f\x0d\x68\x8e\x67\xb0\x15\x3d\xd6\x2f\x76\x6e\xde\xad\xe9\x66\x06\x27\x3b\x23\x4d\x2a\x45\xc6\xf3\x69\xe7\x16\xeb\xd6\xb7\xf7\xe0\x73\xad\x79\x2e\x20\x5c\x77\x49\x57\x9c\xd8\x35\x7b\x52\xe8\x86\x71\x91\x26\x7e\x69\x97\x59\x37\xeb\x2f\x18\xcb\x33\x3b\x50\xcd\xf6\x23\x43\xb9\x45\xd3\xdb\xb8\x63\x2b\x53\xf4\x34\x06\x6b\xc0\xe8\xa3\x15\x7f\x37\xa3\xcb\x28\xa5\xac\xdd\xcc\x8d\x6d\xdb\x76\xe9\x8c\x1a\x1f\xdf\x49\x7f\xf7\x56\xad\x9a\xbb\x0d\x27\x3f\x2a\x15\x0f\x4f\x5b\x13\x9f\xb9\x96\x95\x60\xf6\x1a\xdc\x3a\xeb\x9d\x35\x27\x3b\xe4\x4d\xe7\x28\xf9\x94\xdc\x61\x61\x2f\x7b\xce\x2f\x9e\x41\x8a\x4a\x85\xbd\xb8\x5e\xfc\xeb\x93\x3d\x68\x54\xc2\x85\xb1\x4a\x86\xa8\xba\xfb\x90\x90\x6f\xbe\x87\x26\x2b\x4b\xad\xfb\x6d\x5a\x40\x4d\xf0\xa2\x6f\x3f\x0c\x84\x19\xfc\xc8\x07\x8e\xa6\xaa\x43\xa0\xc3\xf9\xe5\x3e\x5c\x50\xd9\xc2\x7b\xa2\x11\xd7\xee\xc8\x4c\xb4\x70\x04\x7f\xc3\x62\xba\x8d\x91\xeb\x57\xdf\xb0\xb0\x87\xb0\x3f\x49\xe7\xe2\x01\x95\xf6\x83\x33\xc6\x73\xed\x17\x3c\xf9\xc8\x54\xed\x98\x2d\x71\xef\x64\x6e\x4f\xd9\x94\x9d\x18\x7f\xfe\xf0\xd9\x7f\x8b\xe8\x6a\xf8\xfa\xcf\x96\xf8\xf6\x2b\x41\x18\xe9\xba\x21\x74\x62\x6e\x93\xf6\xb0\xb2\xfd\xae\x41\x46\xfc\xc4\x19\x0f\x1e\xd1\x73\xe3\x8c\xca\xd1\x4c\xf7\xc0\x72\xab\x1b\x37\xfd\x13\x72\x6f\xf8\x02\x80\xee\x3e\xf3\xba\xef\x00\x9e\xb9\x0b\xa3\x57\xf1\xd2\x37\x81\x17\xda\x70\x08\xfc\xff\xad\x09\xfb\xa4\xfc\x53\xba\xb0\xb3\xca\xa7\xbb\x6d\x2b\x4e\xc6\xcf\xdd\xab\xed\x60\xe7\x8e\x67\x57\x9d\x2c\xa7\xa4\xa4\x70\x7a\x99\xe6\xb8\xeb\x90\xc6\xb0\xea\x9e\x76\xad\xc7\xff\x06\x00\x00\xff\xff\xdf\x64\x9b\x04\x71\x15\x00\x00") +var _templateDialectSqlUpdateTmpl = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xbc\x58\xd9\x6f\xdb\x3c\x12\x7f\xb6\xff\x8a\xa9\xe0\x0d\xec\xc0\x95\xb3\x7d\x5b\x17\x5e\x20\xcd\xb1\x30\xb6\x17\xea\xb4\x0f\x5b\x14\x81\x22\x8e\x64\xc2\x32\xa9\x90\x54\x9a\xac\xe1\xff\xfd\xc3\xf0\x90\xe4\x2b\x47\xbf\x7e\xdf\x83\x13\x89\x73\x70\xe6\x37\x07\x39\x5a\xad\x46\xc7\xdd\x33\x59\x3e\x28\x9e\xcf\x0d\xbc\x39\xf9\xe7\xbf\x5e\x97\x0a\x35\x0a\x03\x97\x49\x8a\x37\x52\x2e\x60\x2a\xd2\x18\x4e\x8b\x02\x2c\x93\x06\xa2\xab\x3b\x64\x71\xf7\x6a\xce\x35\x68\x59\xa9\x14\x21\x95\x0c\x81\x6b\x28\x78\x8a\x42\x23\x83\x4a\x30\x54\x60\xe6\x08\xa7\x65\x92\xce\x11\xde\xc4\x27\x81\x0a\x99\xac\x04\xeb\x72\x61\xe9\xef\xa7\x67\x17\x1f\x67\x17\x90\xf1\x02\xc1\xaf\x29\x29\x0d\x30\xae\x30\x35\x52\x3d\x80\xcc\xc0\xb4\x36\x33\x0a\x31\xee\x1e\x8f\xd6\xeb\x6e\x97\x7c\x80\x5c\x9a\x87\x12\xc7\x80\xc2\xe4\x32\xe6\x72\x84\xc2\xd0\x2f\x1d\xe5\x28\x62\xa2\xcd\x52\x59\x22\x04\x11\x60\x98\x71\x81\x10\x31\x9e\x14\x98\x9a\x91\xbe\x2d\x46\x55\xc9\x12\x83\x11\xac\xd7\xc4\xd1\x2b\x17\x39\x8c\x27\xd0\x8b\xad\x68\xfc\x39\x49\x17\x49\x8e\x81\x7a\x53\xf1\x82\x1c\x1c\x4f\xa0\x4c\x74\x9a\x14\x35\xe3\x3b\x4f\xf1\x8c\x0a\x53\xe4\x77\x8e\xb3\x7e\xae\xc5\x3d\xd3\xb2\x32\x89\xe1\x52\x58\x75\x8a\x0b\xd3\x92\x8b\xe2\x40\xad\x4d\x93\x02\x89\x73\x9e\xe8\x59\x95\x65\xfc\xbe\xd1\x17\x7d\x12\xc1\x83\xd7\xd0\xfb\x3f\x2a\x49\x8c\x27\xb0\x5e\xaf\x56\xc0\x33\x27\x6a\x5f\x1c\x71\x02\x91\xe0\x45\xe4\x96\x50\xb0\x5a\x54\xa1\x21\xc9\x48\x44\xfb\x64\x89\x3a\x81\xe8\x5a\x48\x86\x9b\xc2\xdd\xac\x12\x29\xf4\x37\x3c\x5f\xaf\xe1\xb8\x8d\xd9\x7a\x3d\x00\x7d\x5b\xcc\x92\x3b\xec\xa7\xe6\x1e\x52\x29\x0c\xde\x9b\xf8\xcc\xfd\x1f\x04\x71\x43\x92\x1b\x7b\x5b\x35\xf1\xc7\x64\xe9\x0d\xc1\x42\xd3\x13\x17\xa6\xb6\x60\x08\xa8\x14\xfd\xa4\x1a\xc0\xaa\xdb\xb9\xd6\x25\xa6\xe4\xca\x91\xbe\x2d\x72\x95\x94\xf3\xf8\xab\x0d\xf4\xac\xc4\x74\xd5\xed\x74\x3e\x4a\x86\xe3\x16\x95\xde\x03\xad\x73\x95\xdc\x14\x38\x06\xbb\x6d\x93\x01\xb1\x5d\x1e\x12\xc3\x99\x2c\xaa\xa5\xd0\xbb\x2c\x9e\x60\x99\xa6\xe7\xed\x0d\x2e\x39\x16\xac\xde\xa1\x73\x65\x33\x37\xa3\xc5\xd8\x2a\x99\x9e\xc7\xb4\x46\x70\x68\xe3\x7d\xb5\x6a\xfc\x66\xbb\x7b\x05\x31\x2b\x91\x08\x13\x04\xec\x5f\xfa\xb3\xee\x76\x28\xaa\x0d\x90\xdd\x4e\x87\xb3\x21\xc8\x05\x21\xb3\x91\x81\x2d\x75\x1f\xfc\xda\x7f\x6c\x24\xfa\x03\x12\xca\xe0\x95\x5c\x80\xb5\x5c\xa1\xa9\x94\x80\x3a\x97\x08\xfb\xa3\x6f\x49\xc1\x99\x95\xba\xa0\x10\xac\xc8\xfe\x31\x44\xd3\xf3\xc8\x06\x66\x0c\xd9\xd2\xc4\x96\x94\xf5\xa3\x25\xd7\x9a\x8b\x1c\xda\x51\x8d\xa7\xe7\x90\x49\x05\xbe\x1a\x07\x64\x2a\xfd\x6c\x1c\x6d\x70\xc8\xb4\x6f\x49\x51\x21\x4c\x80\x33\x67\x94\x85\x4f\x07\x67\x5a\x99\x17\x3b\xca\x5b\x28\x50\xf4\xdd\xf3\x00\xfe\x0d\x27\xce\x85\x96\x52\x1f\x2f\x98\xc0\x32\x59\x60\xff\xfb\x0f\x6d\x14\x17\xf9\x10\x4e\x86\x6d\xd9\xc1\x41\xb1\xa4\x2c\x51\xb0\xfe\x2e\x6d\xf8\x9c\x78\x59\xbd\xe4\xf7\xf5\x10\x32\xdb\x2b\x12\x91\x63\xf0\xcb\x65\x0a\x81\xbf\xad\xca\xe2\xed\x36\xea\x67\x03\xcf\x18\x42\x23\x78\x71\x30\x24\xd9\x9e\x78\x84\xb6\xb7\x5e\x8f\x81\x8b\x3b\x92\x73\x16\xc0\x3f\x6e\x6d\x50\x6e\x2b\x54\x0f\xd1\x10\x32\x1b\x16\x17\x18\x87\x3f\xbc\x9a\x3c\xc7\xcd\x60\xe0\x4b\x11\xcc\x06\xcd\x7e\x3e\x23\x28\xa1\x7d\xd3\x21\x0b\x4a\xbd\x2f\x95\x4b\x85\x8c\xa7\x89\x41\x9f\x01\x65\x2b\xfa\x6e\x9f\xcf\x81\x03\x26\x40\xbd\xab\xaf\xb1\xb0\xa7\x0e\x1c\xeb\xdb\x22\x9e\xf9\x37\x0f\x2d\x81\xc0\x9b\xf0\x94\x21\x34\xa5\xfe\xce\x7f\xd4\xa2\x83\x96\x99\xde\x52\xc7\xdf\xcb\xdc\x91\x12\x2a\xeb\xd2\x85\xd7\xd6\x63\xa8\x50\xa9\xa0\x2f\xa4\x81\x5e\x16\x4f\x97\xe4\xcb\x4d\x81\x03\x7a\x73\x6d\xeb\x1c\xb3\xa4\x2a\x8c\x97\x21\xcf\xef\xa8\x16\x1e\xab\xe5\x6c\xa7\x92\xdf\x42\x28\xe2\x00\x83\xb3\x24\x9e\xd9\xc6\xbe\x11\x88\x86\x32\x3c\xdc\xc4\x76\xdb\x58\x76\xa8\x89\x75\x3a\xb6\x78\xc7\xde\x6e\xbf\xf6\x58\x6b\xcb\x76\x1a\x5b\xa7\xb3\x6e\x25\x44\xdd\xdb\xb2\x78\x56\x95\xa5\x54\x46\x07\x87\x4f\x19\x0b\x48\x3d\x09\xd5\x29\x63\xc8\xdc\x7e\x33\xa3\xaa\xd4\x58\x1f\x77\xf0\xda\x04\x8c\x36\xd8\x0f\xd8\x29\x63\x8f\x02\xf6\x12\xc4\xf6\x42\xf6\x62\xcc\x02\x68\x2d\xd4\x42\x01\xed\x7b\x73\x88\x7e\x2a\x09\x9f\xa4\x68\x25\xdc\xfe\x1c\xdb\xc4\xec\xac\xc0\x44\x21\xeb\x0f\xf6\xa6\x99\xa5\x1e\xc0\xcd\xd2\x7e\x57\xaa\xfd\x99\xb4\x6a\x23\xb2\xfd\xec\xcb\x19\x5d\x39\x5f\xb0\x1c\x7d\x15\x1f\x80\x07\xeb\x12\xf4\xc0\xd8\xb4\x72\xd8\x90\xbe\x9f\xdc\xcc\x01\xef\x0d\xed\xd1\x83\x88\x14\x46\xa4\x7e\x1d\x42\x05\x06\x97\x65\x41\x6d\x6a\xe3\xce\xca\x30\x43\xcb\x1b\xef\x0d\xa3\x03\xd6\x9a\xb7\x1f\xf3\x16\x69\x08\xa4\x69\xe0\x8f\x5b\x9f\x00\xb6\x11\x61\xfc\x55\xf0\xdb\x2a\x58\x63\x97\x19\xee\xed\xb7\x5f\x70\x29\xef\x5c\x15\xe1\x56\x46\x4c\xcf\x35\x15\x12\x75\x61\x2b\xee\x1a\xf1\xd1\x91\x3b\xd3\x5e\x02\xd8\xa3\x88\x45\x74\x70\xe8\x08\x8c\xaa\x10\xa2\xff\xa1\x92\x51\x7d\x3f\x71\x31\x7e\x3e\x98\x5b\x68\xfe\x22\x9c\x35\x9e\xb5\xa6\xc7\x10\x7c\x3e\x74\x4f\x26\xcf\x93\x50\xfc\x8e\xb4\xda\xd3\x00\x6b\xc2\x46\x4a\x6d\x97\xd0\xe8\x98\xa6\x4a\xf9\x13\x9c\xf7\x22\xb7\x83\xdf\x9e\x4b\x3a\xdc\x3c\xd0\x60\xe7\x3c\xd4\x5c\x0a\x4d\x67\x64\xa5\x69\xbc\xf4\xd6\xeb\xd8\x4e\x76\x0d\x1a\x3d\xb3\x2c\x0b\x8b\xef\x32\x31\xe9\xfc\x6a\xaf\x97\xee\x8a\x39\x22\x9b\x47\xc7\x91\xf3\xad\x55\xdc\xa4\xc2\xd6\xb7\xd3\xd5\x00\x71\x5f\x83\xe6\x78\x7a\x8d\xe8\xa1\x7e\xb1\x71\xf3\x6e\x4d\x37\x13\x38\xda\x18\x69\x52\x29\x32\x9e\x8f\x77\x6e\xb1\x6e\xbd\xb9\x07\x9f\x6a\xcd\x73\x01\xe1\xba\x4b\xba\xe2\xc4\xae\xd9\x93\x42\xd7\x8c\xb3\x34\xf1\x4b\x9b\xcc\xba\x5e\x7f\xc2\x58\x9e\xd9\x81\x6a\xb2\x1d\x19\xca\x2d\x9a\xde\x86\x3b\xb6\x32\x45\x4f\x43\xb0\x06\x0c\xde\x5a\xf1\x57\x13\xba\x8c\x52\xca\xda\xcd\xdc\xd8\xd6\xb4\x4b\x67\xd4\xf0\xf0\x4e\xfa\x97\xb7\x6a\xd5\xdc\x75\x38\xf9\x51\xa9\xb8\x7f\xdc\x9a\xf8\xcc\xa5\xac\x04\xb3\xd7\xe0\xd6\x59\xef\xac\x39\xda\x20\xaf\x76\x8e\x92\xf7\xc9\x0d\x16\xf6\xb2\xe7\xfc\xe2\x59\xe3\xc0\x54\xdb\x23\x46\x25\x5c\x18\x2b\xde\x47\x15\xae\x92\x5e\xfb\x16\xc3\x8a\x6c\x73\xac\x03\x8b\x47\x98\x7f\xf6\x4d\x5b\xa8\x94\xbd\x60\xb6\x68\x01\x49\xc1\x8b\xae\xfd\x58\x10\xe6\xf2\x03\x1f\x3d\xea\x4a\x0f\xc1\x0f\x67\x9a\xfb\x98\x41\xa5\x0c\xaf\x89\x46\x5c\x9b\x63\x34\xd1\xc2\xb1\xfc\x05\x8b\x71\xe3\xb6\xeb\x61\x5f\xb0\xb0\x07\xb3\x3f\x5d\xa7\xe2\x0e\x95\xf6\xc3\x34\xc6\x53\xed\x17\x3c\xf9\xc0\xa4\xed\x98\x2d\x71\xeb\xb4\x6e\x4f\xde\x94\xb1\x18\x7f\x78\xf3\xc1\x7f\x9f\xd8\xd5\xf0\xf9\xbf\x2d\xf1\xe6\xcb\x41\x18\xf3\x76\xc3\xea\xc4\xdc\x26\xed\x01\xa6\xf9\xd6\x41\x46\xbc\xe3\x8c\x07\x8f\xe8\xb9\x76\x46\xe5\x68\xc6\x5b\x60\xb9\xd5\x95\xfb\x22\x40\xc8\xbd\xe0\xab\x00\xba\x3b\xce\xf3\xbe\x0d\x78\xe6\x5d\x18\xbd\x8a\xa7\xbe\x13\x3c\xd1\x9a\x43\xe0\xff\xb2\xc6\xec\x93\xf2\x6f\xe9\xcc\xce\x2a\x9f\xee\xb6\xd5\x38\x19\x3f\x8b\x2f\x9a\x61\xcf\x1d\xd9\xae\x76\x59\x4e\x49\x49\xe1\xf4\x32\xf5\x11\xb8\x43\x1a\xc2\x62\xf7\x04\x6c\x3d\xfe\x11\x00\x00\xff\xff\xeb\xa8\xe0\x62\x85\x15\x00\x00") func templateDialectSqlUpdateTmplBytes() ([]byte, error) { return bindataRead( @@ -947,7 +947,7 @@ func templateDialectSqlUpdateTmpl() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "template/dialect/sql/update.tmpl", size: 5489, mode: os.FileMode(420), modTime: time.Unix(1, 0)} + info := bindataFileInfo{name: "template/dialect/sql/update.tmpl", size: 5509, 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/create.tmpl b/entc/gen/template/dialect/sql/create.tmpl index 22d8abb09..993d82562 100644 --- a/entc/gen/template/dialect/sql/create.tmpl +++ b/entc/gen/template/dialect/sql/create.tmpl @@ -14,8 +14,8 @@ in the LICENSE file in the root directory of this source tree. func ({{ $receiver }} *{{ $builder }}) sqlSave(ctx context.Context) (*{{ $.Name }}, error) { _node, _spec := {{ $receiver }}.createSpec() if err := sqlgraph.CreateNode(ctx, {{ $receiver }}.driver, _spec); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } @@ -115,8 +115,8 @@ func ({{ $receiver }} *{{ $builder }}) Save(ctx context.Context) ([]*{{ $.Name } } else { // Invoke the actual operation on the latest mutation in the chain. if err = sqlgraph.BatchCreate(ctx, {{ $receiver }}.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } } } diff --git a/entc/gen/template/dialect/sql/errors.tmpl b/entc/gen/template/dialect/sql/errors.tmpl index 1792d2491..cf6da783a 100644 --- a/entc/gen/template/dialect/sql/errors.tmpl +++ b/entc/gen/template/dialect/sql/errors.tmpl @@ -8,11 +8,4 @@ in the LICENSE file in the root directory of this source tree. {{/* custom errors and errors handlers for sql dialects */}} {{ define "dialect/sql/errors" }} -func isSQLConstraintError(err error) (*ConstraintError, bool) { - if sqlgraph.IsConstraintError(err) { - return &ConstraintError{err.Error(), err}, true - } - return nil, false -} - {{ end }} diff --git a/entc/gen/template/dialect/sql/update.tmpl b/entc/gen/template/dialect/sql/update.tmpl index 4ccbf3953..57e9a0cf2 100644 --- a/entc/gen/template/dialect/sql/update.tmpl +++ b/entc/gen/template/dialect/sql/update.tmpl @@ -120,8 +120,8 @@ func ({{ $receiver }} *{{ $builder }}) sqlSave(ctx context.Context) ({{ $ret }} {{- end }} if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{ {{ $.Package }}.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return {{ $zero }}, err } diff --git a/entc/integration/cascadelete/ent/comment_create.go b/entc/integration/cascadelete/ent/comment_create.go index 65633d2df..c37ee7d15 100644 --- a/entc/integration/cascadelete/ent/comment_create.go +++ b/entc/integration/cascadelete/ent/comment_create.go @@ -110,8 +110,8 @@ func (cc *CommentCreate) check() error { func (cc *CommentCreate) sqlSave(ctx context.Context) (*Comment, error) { _node, _spec := cc.createSpec() if err := sqlgraph.CreateNode(ctx, cc.driver, _spec); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } @@ -192,8 +192,8 @@ func (ccb *CommentCreateBulk) Save(ctx context.Context) ([]*Comment, error) { } else { // Invoke the actual operation on the latest mutation in the chain. if err = sqlgraph.BatchCreate(ctx, ccb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } } } diff --git a/entc/integration/cascadelete/ent/comment_update.go b/entc/integration/cascadelete/ent/comment_update.go index 52b060c57..52e8f2270 100644 --- a/entc/integration/cascadelete/ent/comment_update.go +++ b/entc/integration/cascadelete/ent/comment_update.go @@ -188,8 +188,8 @@ func (cu *CommentUpdate) sqlSave(ctx context.Context) (n int, err error) { if n, err = sqlgraph.UpdateNodes(ctx, cu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{comment.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return 0, err } @@ -387,8 +387,8 @@ func (cuo *CommentUpdateOne) sqlSave(ctx context.Context) (_node *Comment, err e if err = sqlgraph.UpdateNode(ctx, cuo.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{comment.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } diff --git a/entc/integration/cascadelete/ent/ent.go b/entc/integration/cascadelete/ent/ent.go index 032e326d7..b566526a9 100644 --- a/entc/integration/cascadelete/ent/ent.go +++ b/entc/integration/cascadelete/ent/ent.go @@ -12,7 +12,6 @@ import ( "entgo.io/ent" "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/entc/integration/cascadelete/ent/comment" "entgo.io/ent/entc/integration/cascadelete/ent/post" "entgo.io/ent/entc/integration/cascadelete/ent/user" @@ -266,10 +265,3 @@ func IsConstraintError(err error) bool { var e *ConstraintError return errors.As(err, &e) } - -func isSQLConstraintError(err error) (*ConstraintError, bool) { - if sqlgraph.IsConstraintError(err) { - return &ConstraintError{err.Error(), err}, true - } - return nil, false -} diff --git a/entc/integration/cascadelete/ent/post_create.go b/entc/integration/cascadelete/ent/post_create.go index 610ebec8a..06e62e0ee 100644 --- a/entc/integration/cascadelete/ent/post_create.go +++ b/entc/integration/cascadelete/ent/post_create.go @@ -145,8 +145,8 @@ func (pc *PostCreate) check() error { func (pc *PostCreate) sqlSave(ctx context.Context) (*Post, error) { _node, _spec := pc.createSpec() if err := sqlgraph.CreateNode(ctx, pc.driver, _spec); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } @@ -247,8 +247,8 @@ func (pcb *PostCreateBulk) Save(ctx context.Context) ([]*Post, error) { } else { // Invoke the actual operation on the latest mutation in the chain. if err = sqlgraph.BatchCreate(ctx, pcb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } } } diff --git a/entc/integration/cascadelete/ent/post_update.go b/entc/integration/cascadelete/ent/post_update.go index 5c944b018..92731ab63 100644 --- a/entc/integration/cascadelete/ent/post_update.go +++ b/entc/integration/cascadelete/ent/post_update.go @@ -286,8 +286,8 @@ func (pu *PostUpdate) sqlSave(ctx context.Context) (n int, err error) { if n, err = sqlgraph.UpdateNodes(ctx, pu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{post.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return 0, err } @@ -583,8 +583,8 @@ func (puo *PostUpdateOne) sqlSave(ctx context.Context) (_node *Post, err error) if err = sqlgraph.UpdateNode(ctx, puo.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{post.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } diff --git a/entc/integration/cascadelete/ent/user_create.go b/entc/integration/cascadelete/ent/user_create.go index 4030a270f..e7c855aa2 100644 --- a/entc/integration/cascadelete/ent/user_create.go +++ b/entc/integration/cascadelete/ent/user_create.go @@ -125,8 +125,8 @@ func (uc *UserCreate) check() error { func (uc *UserCreate) sqlSave(ctx context.Context) (*User, error) { _node, _spec := uc.createSpec() if err := sqlgraph.CreateNode(ctx, uc.driver, _spec); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } @@ -207,8 +207,8 @@ func (ucb *UserCreateBulk) Save(ctx context.Context) ([]*User, error) { } else { // Invoke the actual operation on the latest mutation in the chain. if err = sqlgraph.BatchCreate(ctx, ucb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } } } diff --git a/entc/integration/cascadelete/ent/user_update.go b/entc/integration/cascadelete/ent/user_update.go index 86a247e2e..642d0e64b 100644 --- a/entc/integration/cascadelete/ent/user_update.go +++ b/entc/integration/cascadelete/ent/user_update.go @@ -219,8 +219,8 @@ func (uu *UserUpdate) sqlSave(ctx context.Context) (n int, err error) { if n, err = sqlgraph.UpdateNodes(ctx, uu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{user.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return 0, err } @@ -450,8 +450,8 @@ func (uuo *UserUpdateOne) sqlSave(ctx context.Context) (_node *User, err error) if err = sqlgraph.UpdateNode(ctx, uuo.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{user.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } diff --git a/entc/integration/config/ent/ent.go b/entc/integration/config/ent/ent.go index 9dd11fb70..b25e48e8f 100644 --- a/entc/integration/config/ent/ent.go +++ b/entc/integration/config/ent/ent.go @@ -12,7 +12,6 @@ import ( "entgo.io/ent" "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/entc/integration/config/ent/user" ) @@ -262,10 +261,3 @@ func IsConstraintError(err error) bool { var e *ConstraintError return errors.As(err, &e) } - -func isSQLConstraintError(err error) (*ConstraintError, bool) { - if sqlgraph.IsConstraintError(err) { - return &ConstraintError{err.Error(), err}, true - } - return nil, false -} diff --git a/entc/integration/config/ent/user_create.go b/entc/integration/config/ent/user_create.go index e4e233cbb..9a996ee69 100644 --- a/entc/integration/config/ent/user_create.go +++ b/entc/integration/config/ent/user_create.go @@ -116,8 +116,8 @@ func (uc *UserCreate) check() error { func (uc *UserCreate) sqlSave(ctx context.Context) (*User, error) { _node, _spec := uc.createSpec() if err := sqlgraph.CreateNode(ctx, uc.driver, _spec); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } @@ -192,8 +192,8 @@ func (ucb *UserCreateBulk) Save(ctx context.Context) ([]*User, error) { } else { // Invoke the actual operation on the latest mutation in the chain. if err = sqlgraph.BatchCreate(ctx, ucb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } } } diff --git a/entc/integration/config/ent/user_update.go b/entc/integration/config/ent/user_update.go index fb9d96463..a2fabd9a4 100644 --- a/entc/integration/config/ent/user_update.go +++ b/entc/integration/config/ent/user_update.go @@ -173,8 +173,8 @@ func (uu *UserUpdate) sqlSave(ctx context.Context) (n int, err error) { if n, err = sqlgraph.UpdateNodes(ctx, uu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{user.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return 0, err } @@ -359,8 +359,8 @@ func (uuo *UserUpdateOne) sqlSave(ctx context.Context) (_node *User, err error) if err = sqlgraph.UpdateNode(ctx, uuo.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{user.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } diff --git a/entc/integration/customid/ent/blob_create.go b/entc/integration/customid/ent/blob_create.go index 0b1ac588e..cb11faacb 100644 --- a/entc/integration/customid/ent/blob_create.go +++ b/entc/integration/customid/ent/blob_create.go @@ -146,8 +146,8 @@ func (bc *BlobCreate) check() error { func (bc *BlobCreate) sqlSave(ctx context.Context) (*Blob, error) { _node, _spec := bc.createSpec() if err := sqlgraph.CreateNode(ctx, bc.driver, _spec); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } @@ -250,8 +250,8 @@ func (bcb *BlobCreateBulk) Save(ctx context.Context) ([]*Blob, error) { } else { // Invoke the actual operation on the latest mutation in the chain. if err = sqlgraph.BatchCreate(ctx, bcb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } } } diff --git a/entc/integration/customid/ent/blob_update.go b/entc/integration/customid/ent/blob_update.go index 664f51a1e..24042d96e 100644 --- a/entc/integration/customid/ent/blob_update.go +++ b/entc/integration/customid/ent/blob_update.go @@ -271,8 +271,8 @@ func (bu *BlobUpdate) sqlSave(ctx context.Context) (n int, err error) { if n, err = sqlgraph.UpdateNodes(ctx, bu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{blob.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return 0, err } @@ -554,8 +554,8 @@ func (buo *BlobUpdateOne) sqlSave(ctx context.Context) (_node *Blob, err error) if err = sqlgraph.UpdateNode(ctx, buo.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{blob.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } diff --git a/entc/integration/customid/ent/car_create.go b/entc/integration/customid/ent/car_create.go index c822c5c05..da3dab4da 100644 --- a/entc/integration/customid/ent/car_create.go +++ b/entc/integration/customid/ent/car_create.go @@ -161,8 +161,8 @@ func (cc *CarCreate) check() error { func (cc *CarCreate) sqlSave(ctx context.Context) (*Car, error) { _node, _spec := cc.createSpec() if err := sqlgraph.CreateNode(ctx, cc.driver, _spec); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } @@ -265,8 +265,8 @@ func (ccb *CarCreateBulk) Save(ctx context.Context) ([]*Car, error) { } else { // Invoke the actual operation on the latest mutation in the chain. if err = sqlgraph.BatchCreate(ctx, ccb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } } } diff --git a/entc/integration/customid/ent/car_update.go b/entc/integration/customid/ent/car_update.go index 6b6b3fd13..373c47a37 100644 --- a/entc/integration/customid/ent/car_update.go +++ b/entc/integration/customid/ent/car_update.go @@ -296,8 +296,8 @@ func (cu *CarUpdate) sqlSave(ctx context.Context) (n int, err error) { if n, err = sqlgraph.UpdateNodes(ctx, cu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{car.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return 0, err } @@ -604,8 +604,8 @@ func (cuo *CarUpdateOne) sqlSave(ctx context.Context) (_node *Car, err error) { if err = sqlgraph.UpdateNode(ctx, cuo.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{car.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } diff --git a/entc/integration/customid/ent/doc_create.go b/entc/integration/customid/ent/doc_create.go index d3d52e75d..ba656df19 100644 --- a/entc/integration/customid/ent/doc_create.go +++ b/entc/integration/customid/ent/doc_create.go @@ -159,8 +159,8 @@ func (dc *DocCreate) check() error { func (dc *DocCreate) sqlSave(ctx context.Context) (*Doc, error) { _node, _spec := dc.createSpec() if err := sqlgraph.CreateNode(ctx, dc.driver, _spec); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } @@ -263,8 +263,8 @@ func (dcb *DocCreateBulk) Save(ctx context.Context) ([]*Doc, error) { } else { // Invoke the actual operation on the latest mutation in the chain. if err = sqlgraph.BatchCreate(ctx, dcb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } } } diff --git a/entc/integration/customid/ent/doc_update.go b/entc/integration/customid/ent/doc_update.go index 42b764eee..193eddd50 100644 --- a/entc/integration/customid/ent/doc_update.go +++ b/entc/integration/customid/ent/doc_update.go @@ -291,8 +291,8 @@ func (du *DocUpdate) sqlSave(ctx context.Context) (n int, err error) { if n, err = sqlgraph.UpdateNodes(ctx, du.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{doc.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return 0, err } @@ -594,8 +594,8 @@ func (duo *DocUpdateOne) sqlSave(ctx context.Context) (_node *Doc, err error) { if err = sqlgraph.UpdateNode(ctx, duo.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{doc.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } diff --git a/entc/integration/customid/ent/ent.go b/entc/integration/customid/ent/ent.go index ba0d4fe0c..18010f630 100644 --- a/entc/integration/customid/ent/ent.go +++ b/entc/integration/customid/ent/ent.go @@ -12,7 +12,6 @@ import ( "entgo.io/ent" "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/entc/integration/customid/ent/blob" "entgo.io/ent/entc/integration/customid/ent/car" "entgo.io/ent/entc/integration/customid/ent/doc" @@ -276,10 +275,3 @@ func IsConstraintError(err error) bool { var e *ConstraintError return errors.As(err, &e) } - -func isSQLConstraintError(err error) (*ConstraintError, bool) { - if sqlgraph.IsConstraintError(err) { - return &ConstraintError{err.Error(), err}, true - } - return nil, false -} diff --git a/entc/integration/customid/ent/group_create.go b/entc/integration/customid/ent/group_create.go index c216ab479..bf9f80c15 100644 --- a/entc/integration/customid/ent/group_create.go +++ b/entc/integration/customid/ent/group_create.go @@ -104,8 +104,8 @@ func (gc *GroupCreate) check() error { func (gc *GroupCreate) sqlSave(ctx context.Context) (*Group, error) { _node, _spec := gc.createSpec() if err := sqlgraph.CreateNode(ctx, gc.driver, _spec); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } @@ -183,8 +183,8 @@ func (gcb *GroupCreateBulk) Save(ctx context.Context) ([]*Group, error) { } else { // Invoke the actual operation on the latest mutation in the chain. if err = sqlgraph.BatchCreate(ctx, gcb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } } } diff --git a/entc/integration/customid/ent/group_update.go b/entc/integration/customid/ent/group_update.go index d2c6d4f5f..82ed13415 100644 --- a/entc/integration/customid/ent/group_update.go +++ b/entc/integration/customid/ent/group_update.go @@ -198,8 +198,8 @@ func (gu *GroupUpdate) sqlSave(ctx context.Context) (n int, err error) { if n, err = sqlgraph.UpdateNodes(ctx, gu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{group.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return 0, err } @@ -408,8 +408,8 @@ func (guo *GroupUpdateOne) sqlSave(ctx context.Context) (_node *Group, err error if err = sqlgraph.UpdateNode(ctx, guo.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{group.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } diff --git a/entc/integration/customid/ent/mixinid_create.go b/entc/integration/customid/ent/mixinid_create.go index efe68a5ac..f9008e93b 100644 --- a/entc/integration/customid/ent/mixinid_create.go +++ b/entc/integration/customid/ent/mixinid_create.go @@ -117,8 +117,8 @@ func (mic *MixinIDCreate) check() error { func (mic *MixinIDCreate) sqlSave(ctx context.Context) (*MixinID, error) { _node, _spec := mic.createSpec() if err := sqlgraph.CreateNode(ctx, mic.driver, _spec); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } @@ -190,8 +190,8 @@ func (micb *MixinIDCreateBulk) Save(ctx context.Context) ([]*MixinID, error) { } else { // Invoke the actual operation on the latest mutation in the chain. if err = sqlgraph.BatchCreate(ctx, micb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } } } diff --git a/entc/integration/customid/ent/mixinid_update.go b/entc/integration/customid/ent/mixinid_update.go index e88cf1e51..e33de2a08 100644 --- a/entc/integration/customid/ent/mixinid_update.go +++ b/entc/integration/customid/ent/mixinid_update.go @@ -133,8 +133,8 @@ func (miu *MixinIDUpdate) sqlSave(ctx context.Context) (n int, err error) { if n, err = sqlgraph.UpdateNodes(ctx, miu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{mixinid.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return 0, err } @@ -279,8 +279,8 @@ func (miuo *MixinIDUpdateOne) sqlSave(ctx context.Context) (_node *MixinID, err if err = sqlgraph.UpdateNode(ctx, miuo.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{mixinid.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } diff --git a/entc/integration/customid/ent/note_create.go b/entc/integration/customid/ent/note_create.go index dbff779e4..f8d2dd5a2 100644 --- a/entc/integration/customid/ent/note_create.go +++ b/entc/integration/customid/ent/note_create.go @@ -159,8 +159,8 @@ func (nc *NoteCreate) check() error { func (nc *NoteCreate) sqlSave(ctx context.Context) (*Note, error) { _node, _spec := nc.createSpec() if err := sqlgraph.CreateNode(ctx, nc.driver, _spec); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } @@ -263,8 +263,8 @@ func (ncb *NoteCreateBulk) Save(ctx context.Context) ([]*Note, error) { } else { // Invoke the actual operation on the latest mutation in the chain. if err = sqlgraph.BatchCreate(ctx, ncb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } } } diff --git a/entc/integration/customid/ent/note_update.go b/entc/integration/customid/ent/note_update.go index 0aba38b10..2748e83e4 100644 --- a/entc/integration/customid/ent/note_update.go +++ b/entc/integration/customid/ent/note_update.go @@ -291,8 +291,8 @@ func (nu *NoteUpdate) sqlSave(ctx context.Context) (n int, err error) { if n, err = sqlgraph.UpdateNodes(ctx, nu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{note.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return 0, err } @@ -594,8 +594,8 @@ func (nuo *NoteUpdateOne) sqlSave(ctx context.Context) (_node *Note, err error) if err = sqlgraph.UpdateNode(ctx, nuo.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{note.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } diff --git a/entc/integration/customid/ent/pet_create.go b/entc/integration/customid/ent/pet_create.go index 3c3f95f78..a292a9aaa 100644 --- a/entc/integration/customid/ent/pet_create.go +++ b/entc/integration/customid/ent/pet_create.go @@ -180,8 +180,8 @@ func (pc *PetCreate) check() error { func (pc *PetCreate) sqlSave(ctx context.Context) (*Pet, error) { _node, _spec := pc.createSpec() if err := sqlgraph.CreateNode(ctx, pc.driver, _spec); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } @@ -315,8 +315,8 @@ func (pcb *PetCreateBulk) Save(ctx context.Context) ([]*Pet, error) { } else { // Invoke the actual operation on the latest mutation in the chain. if err = sqlgraph.BatchCreate(ctx, pcb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } } } diff --git a/entc/integration/customid/ent/pet_update.go b/entc/integration/customid/ent/pet_update.go index af27eb7a4..1765cb707 100644 --- a/entc/integration/customid/ent/pet_update.go +++ b/entc/integration/customid/ent/pet_update.go @@ -409,8 +409,8 @@ func (pu *PetUpdate) sqlSave(ctx context.Context) (n int, err error) { if n, err = sqlgraph.UpdateNodes(ctx, pu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{pet.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return 0, err } @@ -829,8 +829,8 @@ func (puo *PetUpdateOne) sqlSave(ctx context.Context) (_node *Pet, err error) { if err = sqlgraph.UpdateNode(ctx, puo.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{pet.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } diff --git a/entc/integration/customid/ent/user_create.go b/entc/integration/customid/ent/user_create.go index 70ca59a7a..f9c92a989 100644 --- a/entc/integration/customid/ent/user_create.go +++ b/entc/integration/customid/ent/user_create.go @@ -154,8 +154,8 @@ func (uc *UserCreate) check() error { func (uc *UserCreate) sqlSave(ctx context.Context) (*User, error) { _node, _spec := uc.createSpec() if err := sqlgraph.CreateNode(ctx, uc.driver, _spec); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } @@ -291,8 +291,8 @@ func (ucb *UserCreateBulk) Save(ctx context.Context) ([]*User, error) { } else { // Invoke the actual operation on the latest mutation in the chain. if err = sqlgraph.BatchCreate(ctx, ucb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } } } diff --git a/entc/integration/customid/ent/user_update.go b/entc/integration/customid/ent/user_update.go index cd51927ca..f3b27f081 100644 --- a/entc/integration/customid/ent/user_update.go +++ b/entc/integration/customid/ent/user_update.go @@ -439,8 +439,8 @@ func (uu *UserUpdate) sqlSave(ctx context.Context) (n int, err error) { if n, err = sqlgraph.UpdateNodes(ctx, uu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{user.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return 0, err } @@ -889,8 +889,8 @@ func (uuo *UserUpdateOne) sqlSave(ctx context.Context) (_node *User, err error) if err = sqlgraph.UpdateNode(ctx, uuo.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{user.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } diff --git a/entc/integration/edgefield/ent/car_create.go b/entc/integration/edgefield/ent/car_create.go index 4fc98195f..b0f133e51 100644 --- a/entc/integration/edgefield/ent/car_create.go +++ b/entc/integration/edgefield/ent/car_create.go @@ -112,8 +112,8 @@ func (cc *CarCreate) check() error { func (cc *CarCreate) sqlSave(ctx context.Context) (*Car, error) { _node, _spec := cc.createSpec() if err := sqlgraph.CreateNode(ctx, cc.driver, _spec); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } @@ -193,8 +193,8 @@ func (ccb *CarCreateBulk) Save(ctx context.Context) ([]*Car, error) { } else { // Invoke the actual operation on the latest mutation in the chain. if err = sqlgraph.BatchCreate(ctx, ccb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } } } diff --git a/entc/integration/edgefield/ent/car_update.go b/entc/integration/edgefield/ent/car_update.go index 53271e809..8d6e76838 100644 --- a/entc/integration/edgefield/ent/car_update.go +++ b/entc/integration/edgefield/ent/car_update.go @@ -231,8 +231,8 @@ func (cu *CarUpdate) sqlSave(ctx context.Context) (n int, err error) { if n, err = sqlgraph.UpdateNodes(ctx, cu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{car.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return 0, err } @@ -474,8 +474,8 @@ func (cuo *CarUpdateOne) sqlSave(ctx context.Context) (_node *Car, err error) { if err = sqlgraph.UpdateNode(ctx, cuo.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{car.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } diff --git a/entc/integration/edgefield/ent/card_create.go b/entc/integration/edgefield/ent/card_create.go index 9c6171f68..336573866 100644 --- a/entc/integration/edgefield/ent/card_create.go +++ b/entc/integration/edgefield/ent/card_create.go @@ -116,8 +116,8 @@ func (cc *CardCreate) check() error { func (cc *CardCreate) sqlSave(ctx context.Context) (*Card, error) { _node, _spec := cc.createSpec() if err := sqlgraph.CreateNode(ctx, cc.driver, _spec); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } @@ -198,8 +198,8 @@ func (ccb *CardCreateBulk) Save(ctx context.Context) ([]*Card, error) { } else { // Invoke the actual operation on the latest mutation in the chain. if err = sqlgraph.BatchCreate(ctx, ccb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } } } diff --git a/entc/integration/edgefield/ent/card_update.go b/entc/integration/edgefield/ent/card_update.go index 0749604d8..1c8c842c0 100644 --- a/entc/integration/edgefield/ent/card_update.go +++ b/entc/integration/edgefield/ent/card_update.go @@ -207,8 +207,8 @@ func (cu *CardUpdate) sqlSave(ctx context.Context) (n int, err error) { if n, err = sqlgraph.UpdateNodes(ctx, cu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{card.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return 0, err } @@ -426,8 +426,8 @@ func (cuo *CardUpdateOne) sqlSave(ctx context.Context) (_node *Card, err error) if err = sqlgraph.UpdateNode(ctx, cuo.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{card.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } diff --git a/entc/integration/edgefield/ent/ent.go b/entc/integration/edgefield/ent/ent.go index 5d015eacc..b390edbaf 100644 --- a/entc/integration/edgefield/ent/ent.go +++ b/entc/integration/edgefield/ent/ent.go @@ -12,7 +12,6 @@ import ( "entgo.io/ent" "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/entc/integration/edgefield/ent/car" "entgo.io/ent/entc/integration/edgefield/ent/card" "entgo.io/ent/entc/integration/edgefield/ent/info" @@ -276,10 +275,3 @@ func IsConstraintError(err error) bool { var e *ConstraintError return errors.As(err, &e) } - -func isSQLConstraintError(err error) (*ConstraintError, bool) { - if sqlgraph.IsConstraintError(err) { - return &ConstraintError{err.Error(), err}, true - } - return nil, false -} diff --git a/entc/integration/edgefield/ent/info_create.go b/entc/integration/edgefield/ent/info_create.go index 99f427519..5db57ffe5 100644 --- a/entc/integration/edgefield/ent/info_create.go +++ b/entc/integration/edgefield/ent/info_create.go @@ -119,8 +119,8 @@ func (ic *InfoCreate) check() error { func (ic *InfoCreate) sqlSave(ctx context.Context) (*Info, error) { _node, _spec := ic.createSpec() if err := sqlgraph.CreateNode(ctx, ic.driver, _spec); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } @@ -207,8 +207,8 @@ func (icb *InfoCreateBulk) Save(ctx context.Context) ([]*Info, error) { } else { // Invoke the actual operation on the latest mutation in the chain. if err = sqlgraph.BatchCreate(ctx, icb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } } } diff --git a/entc/integration/edgefield/ent/info_update.go b/entc/integration/edgefield/ent/info_update.go index 5f06346bf..9f18c4fde 100644 --- a/entc/integration/edgefield/ent/info_update.go +++ b/entc/integration/edgefield/ent/info_update.go @@ -182,8 +182,8 @@ func (iu *InfoUpdate) sqlSave(ctx context.Context) (n int, err error) { if n, err = sqlgraph.UpdateNodes(ctx, iu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{info.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return 0, err } @@ -375,8 +375,8 @@ func (iuo *InfoUpdateOne) sqlSave(ctx context.Context) (_node *Info, err error) if err = sqlgraph.UpdateNode(ctx, iuo.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{info.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } diff --git a/entc/integration/edgefield/ent/metadata_create.go b/entc/integration/edgefield/ent/metadata_create.go index 6922f2747..627ac20e6 100644 --- a/entc/integration/edgefield/ent/metadata_create.go +++ b/entc/integration/edgefield/ent/metadata_create.go @@ -135,8 +135,8 @@ func (mc *MetadataCreate) check() error { func (mc *MetadataCreate) sqlSave(ctx context.Context) (*Metadata, error) { _node, _spec := mc.createSpec() if err := sqlgraph.CreateNode(ctx, mc.driver, _spec); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } @@ -224,8 +224,8 @@ func (mcb *MetadataCreateBulk) Save(ctx context.Context) ([]*Metadata, error) { } else { // Invoke the actual operation on the latest mutation in the chain. if err = sqlgraph.BatchCreate(ctx, mcb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } } } diff --git a/entc/integration/edgefield/ent/metadata_update.go b/entc/integration/edgefield/ent/metadata_update.go index 6cd71b1ca..60fe4cc9d 100644 --- a/entc/integration/edgefield/ent/metadata_update.go +++ b/entc/integration/edgefield/ent/metadata_update.go @@ -203,8 +203,8 @@ func (mu *MetadataUpdate) sqlSave(ctx context.Context) (n int, err error) { if n, err = sqlgraph.UpdateNodes(ctx, mu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{metadata.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return 0, err } @@ -418,8 +418,8 @@ func (muo *MetadataUpdateOne) sqlSave(ctx context.Context) (_node *Metadata, err if err = sqlgraph.UpdateNode(ctx, muo.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{metadata.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } diff --git a/entc/integration/edgefield/ent/pet_create.go b/entc/integration/edgefield/ent/pet_create.go index fc2fc771a..a436619f7 100644 --- a/entc/integration/edgefield/ent/pet_create.go +++ b/entc/integration/edgefield/ent/pet_create.go @@ -102,8 +102,8 @@ func (pc *PetCreate) check() error { func (pc *PetCreate) sqlSave(ctx context.Context) (*Pet, error) { _node, _spec := pc.createSpec() if err := sqlgraph.CreateNode(ctx, pc.driver, _spec); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } @@ -176,8 +176,8 @@ func (pcb *PetCreateBulk) Save(ctx context.Context) ([]*Pet, error) { } else { // Invoke the actual operation on the latest mutation in the chain. if err = sqlgraph.BatchCreate(ctx, pcb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } } } diff --git a/entc/integration/edgefield/ent/pet_update.go b/entc/integration/edgefield/ent/pet_update.go index 495ff7420..72f686c58 100644 --- a/entc/integration/edgefield/ent/pet_update.go +++ b/entc/integration/edgefield/ent/pet_update.go @@ -174,8 +174,8 @@ func (pu *PetUpdate) sqlSave(ctx context.Context) (n int, err error) { if n, err = sqlgraph.UpdateNodes(ctx, pu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{pet.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return 0, err } @@ -360,8 +360,8 @@ func (puo *PetUpdateOne) sqlSave(ctx context.Context) (_node *Pet, err error) { if err = sqlgraph.UpdateNode(ctx, puo.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{pet.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } diff --git a/entc/integration/edgefield/ent/post_create.go b/entc/integration/edgefield/ent/post_create.go index 2b7866b74..361171d00 100644 --- a/entc/integration/edgefield/ent/post_create.go +++ b/entc/integration/edgefield/ent/post_create.go @@ -112,8 +112,8 @@ func (pc *PostCreate) check() error { func (pc *PostCreate) sqlSave(ctx context.Context) (*Post, error) { _node, _spec := pc.createSpec() if err := sqlgraph.CreateNode(ctx, pc.driver, _spec); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } @@ -194,8 +194,8 @@ func (pcb *PostCreateBulk) Save(ctx context.Context) ([]*Post, error) { } else { // Invoke the actual operation on the latest mutation in the chain. if err = sqlgraph.BatchCreate(ctx, pcb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } } } diff --git a/entc/integration/edgefield/ent/post_update.go b/entc/integration/edgefield/ent/post_update.go index 75710b925..d1a94d632 100644 --- a/entc/integration/edgefield/ent/post_update.go +++ b/entc/integration/edgefield/ent/post_update.go @@ -187,8 +187,8 @@ func (pu *PostUpdate) sqlSave(ctx context.Context) (n int, err error) { if n, err = sqlgraph.UpdateNodes(ctx, pu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{post.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return 0, err } @@ -386,8 +386,8 @@ func (puo *PostUpdateOne) sqlSave(ctx context.Context) (_node *Post, err error) if err = sqlgraph.UpdateNode(ctx, puo.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{post.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } diff --git a/entc/integration/edgefield/ent/rental_create.go b/entc/integration/edgefield/ent/rental_create.go index 6db62d535..c226c03fb 100644 --- a/entc/integration/edgefield/ent/rental_create.go +++ b/entc/integration/edgefield/ent/rental_create.go @@ -146,8 +146,8 @@ func (rc *RentalCreate) check() error { func (rc *RentalCreate) sqlSave(ctx context.Context) (*Rental, error) { _node, _spec := rc.createSpec() if err := sqlgraph.CreateNode(ctx, rc.driver, _spec); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } @@ -249,8 +249,8 @@ func (rcb *RentalCreateBulk) Save(ctx context.Context) ([]*Rental, error) { } else { // Invoke the actual operation on the latest mutation in the chain. if err = sqlgraph.BatchCreate(ctx, rcb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } } } diff --git a/entc/integration/edgefield/ent/rental_update.go b/entc/integration/edgefield/ent/rental_update.go index 8076fd22a..04a67de50 100644 --- a/entc/integration/edgefield/ent/rental_update.go +++ b/entc/integration/edgefield/ent/rental_update.go @@ -253,8 +253,8 @@ func (ru *RentalUpdate) sqlSave(ctx context.Context) (n int, err error) { if n, err = sqlgraph.UpdateNodes(ctx, ru.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{rental.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return 0, err } @@ -515,8 +515,8 @@ func (ruo *RentalUpdateOne) sqlSave(ctx context.Context) (_node *Rental, err err if err = sqlgraph.UpdateNode(ctx, ruo.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{rental.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } diff --git a/entc/integration/edgefield/ent/user_create.go b/entc/integration/edgefield/ent/user_create.go index 6db252cce..3f0c01361 100644 --- a/entc/integration/edgefield/ent/user_create.go +++ b/entc/integration/edgefield/ent/user_create.go @@ -223,8 +223,8 @@ func (uc *UserCreate) check() error { func (uc *UserCreate) sqlSave(ctx context.Context) (*User, error) { _node, _spec := uc.createSpec() if err := sqlgraph.CreateNode(ctx, uc.driver, _spec); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } @@ -431,8 +431,8 @@ func (ucb *UserCreateBulk) Save(ctx context.Context) ([]*User, error) { } else { // Invoke the actual operation on the latest mutation in the chain. if err = sqlgraph.BatchCreate(ctx, ucb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } } } diff --git a/entc/integration/edgefield/ent/user_update.go b/entc/integration/edgefield/ent/user_update.go index 61dcd6d43..1fdeced3d 100644 --- a/entc/integration/edgefield/ent/user_update.go +++ b/entc/integration/edgefield/ent/user_update.go @@ -724,8 +724,8 @@ func (uu *UserUpdate) sqlSave(ctx context.Context) (n int, err error) { if n, err = sqlgraph.UpdateNodes(ctx, uu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{user.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return 0, err } @@ -1456,8 +1456,8 @@ func (uuo *UserUpdateOne) sqlSave(ctx context.Context) (_node *User, err error) if err = sqlgraph.UpdateNode(ctx, uuo.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{user.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } diff --git a/entc/integration/ent/card_create.go b/entc/integration/ent/card_create.go index 21715efbb..43e64a7a7 100644 --- a/entc/integration/ent/card_create.go +++ b/entc/integration/ent/card_create.go @@ -221,8 +221,8 @@ func (cc *CardCreate) check() error { func (cc *CardCreate) sqlSave(ctx context.Context) (*Card, error) { _node, _spec := cc.createSpec() if err := sqlgraph.CreateNode(ctx, cc.driver, _spec); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } @@ -355,8 +355,8 @@ func (ccb *CardCreateBulk) Save(ctx context.Context) ([]*Card, error) { } else { // Invoke the actual operation on the latest mutation in the chain. if err = sqlgraph.BatchCreate(ctx, ccb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } } } diff --git a/entc/integration/ent/card_update.go b/entc/integration/ent/card_update.go index 057647019..8a0234dd4 100644 --- a/entc/integration/ent/card_update.go +++ b/entc/integration/ent/card_update.go @@ -359,8 +359,8 @@ func (cu *CardUpdate) sqlSave(ctx context.Context) (n int, err error) { if n, err = sqlgraph.UpdateNodes(ctx, cu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{card.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return 0, err } @@ -729,8 +729,8 @@ func (cuo *CardUpdateOne) sqlSave(ctx context.Context) (_node *Card, err error) if err = sqlgraph.UpdateNode(ctx, cuo.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{card.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } diff --git a/entc/integration/ent/comment_create.go b/entc/integration/ent/comment_create.go index 935fc6b64..73a3745e0 100644 --- a/entc/integration/ent/comment_create.go +++ b/entc/integration/ent/comment_create.go @@ -115,8 +115,8 @@ func (cc *CommentCreate) check() error { func (cc *CommentCreate) sqlSave(ctx context.Context) (*Comment, error) { _node, _spec := cc.createSpec() if err := sqlgraph.CreateNode(ctx, cc.driver, _spec); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } @@ -193,8 +193,8 @@ func (ccb *CommentCreateBulk) Save(ctx context.Context) ([]*Comment, error) { } else { // Invoke the actual operation on the latest mutation in the chain. if err = sqlgraph.BatchCreate(ctx, ccb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } } } diff --git a/entc/integration/ent/comment_update.go b/entc/integration/ent/comment_update.go index 4dc7e80be..9b4d96c21 100644 --- a/entc/integration/ent/comment_update.go +++ b/entc/integration/ent/comment_update.go @@ -208,8 +208,8 @@ func (cu *CommentUpdate) sqlSave(ctx context.Context) (n int, err error) { if n, err = sqlgraph.UpdateNodes(ctx, cu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{comment.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return 0, err } @@ -429,8 +429,8 @@ func (cuo *CommentUpdateOne) sqlSave(ctx context.Context) (_node *Comment, err e if err = sqlgraph.UpdateNode(ctx, cuo.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{comment.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } diff --git a/entc/integration/ent/ent.go b/entc/integration/ent/ent.go index b9a8e00c0..e9404ad22 100644 --- a/entc/integration/ent/ent.go +++ b/entc/integration/ent/ent.go @@ -12,7 +12,6 @@ import ( "entgo.io/ent" "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/entc/integration/ent/card" "entgo.io/ent/entc/integration/ent/comment" "entgo.io/ent/entc/integration/ent/fieldtype" @@ -288,10 +287,3 @@ func IsConstraintError(err error) bool { var e *ConstraintError return errors.As(err, &e) } - -func isSQLConstraintError(err error) (*ConstraintError, bool) { - if sqlgraph.IsConstraintError(err) { - return &ConstraintError{err.Error(), err}, true - } - return nil, false -} diff --git a/entc/integration/ent/fieldtype_create.go b/entc/integration/ent/fieldtype_create.go index bc86a6a6f..85d591046 100644 --- a/entc/integration/ent/fieldtype_create.go +++ b/entc/integration/ent/fieldtype_create.go @@ -874,8 +874,8 @@ func (ftc *FieldTypeCreate) check() error { func (ftc *FieldTypeCreate) sqlSave(ctx context.Context) (*FieldType, error) { _node, _spec := ftc.createSpec() if err := sqlgraph.CreateNode(ctx, ftc.driver, _spec); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } @@ -1401,8 +1401,8 @@ func (ftcb *FieldTypeCreateBulk) Save(ctx context.Context) ([]*FieldType, error) } else { // Invoke the actual operation on the latest mutation in the chain. if err = sqlgraph.BatchCreate(ctx, ftcb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } } } diff --git a/entc/integration/ent/fieldtype_update.go b/entc/integration/ent/fieldtype_update.go index 7ad75c5e0..103646b22 100644 --- a/entc/integration/ent/fieldtype_update.go +++ b/entc/integration/ent/fieldtype_update.go @@ -2276,8 +2276,8 @@ func (ftu *FieldTypeUpdate) sqlSave(ctx context.Context) (n int, err error) { if n, err = sqlgraph.UpdateNodes(ctx, ftu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{fieldtype.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return 0, err } @@ -4559,8 +4559,8 @@ func (ftuo *FieldTypeUpdateOne) sqlSave(ctx context.Context) (_node *FieldType, if err = sqlgraph.UpdateNode(ctx, ftuo.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{fieldtype.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } diff --git a/entc/integration/ent/file_create.go b/entc/integration/ent/file_create.go index 12e22729e..4ad7806d2 100644 --- a/entc/integration/ent/file_create.go +++ b/entc/integration/ent/file_create.go @@ -221,8 +221,8 @@ func (fc *FileCreate) check() error { func (fc *FileCreate) sqlSave(ctx context.Context) (*File, error) { _node, _spec := fc.createSpec() if err := sqlgraph.CreateNode(ctx, fc.driver, _spec); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } @@ -375,8 +375,8 @@ func (fcb *FileCreateBulk) Save(ctx context.Context) ([]*File, error) { } else { // Invoke the actual operation on the latest mutation in the chain. if err = sqlgraph.BatchCreate(ctx, fcb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } } } diff --git a/entc/integration/ent/file_update.go b/entc/integration/ent/file_update.go index 0432b66ca..913ca8760 100644 --- a/entc/integration/ent/file_update.go +++ b/entc/integration/ent/file_update.go @@ -483,8 +483,8 @@ func (fu *FileUpdate) sqlSave(ctx context.Context) (n int, err error) { if n, err = sqlgraph.UpdateNodes(ctx, fu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{file.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return 0, err } @@ -976,8 +976,8 @@ func (fuo *FileUpdateOne) sqlSave(ctx context.Context) (_node *File, err error) if err = sqlgraph.UpdateNode(ctx, fuo.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{file.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } diff --git a/entc/integration/ent/filetype_create.go b/entc/integration/ent/filetype_create.go index 023dbe55d..832e174b1 100644 --- a/entc/integration/ent/filetype_create.go +++ b/entc/integration/ent/filetype_create.go @@ -165,8 +165,8 @@ func (ftc *FileTypeCreate) check() error { func (ftc *FileTypeCreate) sqlSave(ctx context.Context) (*FileType, error) { _node, _spec := ftc.createSpec() if err := sqlgraph.CreateNode(ctx, ftc.driver, _spec); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } @@ -263,8 +263,8 @@ func (ftcb *FileTypeCreateBulk) Save(ctx context.Context) ([]*FileType, error) { } else { // Invoke the actual operation on the latest mutation in the chain. if err = sqlgraph.BatchCreate(ctx, ftcb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } } } diff --git a/entc/integration/ent/filetype_update.go b/entc/integration/ent/filetype_update.go index c7853b069..249fa9aa5 100644 --- a/entc/integration/ent/filetype_update.go +++ b/entc/integration/ent/filetype_update.go @@ -274,8 +274,8 @@ func (ftu *FileTypeUpdate) sqlSave(ctx context.Context) (n int, err error) { if n, err = sqlgraph.UpdateNodes(ctx, ftu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{filetype.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return 0, err } @@ -560,8 +560,8 @@ func (ftuo *FileTypeUpdateOne) sqlSave(ctx context.Context) (_node *FileType, er if err = sqlgraph.UpdateNode(ctx, ftuo.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{filetype.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } diff --git a/entc/integration/ent/goods_create.go b/entc/integration/ent/goods_create.go index 7902933f4..080abdadd 100644 --- a/entc/integration/ent/goods_create.go +++ b/entc/integration/ent/goods_create.go @@ -82,8 +82,8 @@ func (gc *GoodsCreate) check() error { func (gc *GoodsCreate) sqlSave(ctx context.Context) (*Goods, error) { _node, _spec := gc.createSpec() if err := sqlgraph.CreateNode(ctx, gc.driver, _spec); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } @@ -136,8 +136,8 @@ func (gcb *GoodsCreateBulk) Save(ctx context.Context) ([]*Goods, error) { } else { // Invoke the actual operation on the latest mutation in the chain. if err = sqlgraph.BatchCreate(ctx, gcb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } } } diff --git a/entc/integration/ent/goods_update.go b/entc/integration/ent/goods_update.go index bd7edfe6c..a0e546dd5 100644 --- a/entc/integration/ent/goods_update.go +++ b/entc/integration/ent/goods_update.go @@ -107,8 +107,8 @@ func (gu *GoodsUpdate) sqlSave(ctx context.Context) (n int, err error) { if n, err = sqlgraph.UpdateNodes(ctx, gu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{goods.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return 0, err } @@ -227,8 +227,8 @@ func (guo *GoodsUpdateOne) sqlSave(ctx context.Context) (_node *Goods, err error if err = sqlgraph.UpdateNode(ctx, guo.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{goods.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } diff --git a/entc/integration/ent/group_create.go b/entc/integration/ent/group_create.go index 88529ba99..d0525c193 100644 --- a/entc/integration/ent/group_create.go +++ b/entc/integration/ent/group_create.go @@ -237,8 +237,8 @@ func (gc *GroupCreate) check() error { func (gc *GroupCreate) sqlSave(ctx context.Context) (*Group, error) { _node, _spec := gc.createSpec() if err := sqlgraph.CreateNode(ctx, gc.driver, _spec); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } @@ -409,8 +409,8 @@ func (gcb *GroupCreateBulk) Save(ctx context.Context) ([]*Group, error) { } else { // Invoke the actual operation on the latest mutation in the chain. if err = sqlgraph.BatchCreate(ctx, gcb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } } } diff --git a/entc/integration/ent/group_update.go b/entc/integration/ent/group_update.go index 746f3d5a4..136640ade 100644 --- a/entc/integration/ent/group_update.go +++ b/entc/integration/ent/group_update.go @@ -590,8 +590,8 @@ func (gu *GroupUpdate) sqlSave(ctx context.Context) (n int, err error) { if n, err = sqlgraph.UpdateNodes(ctx, gu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{group.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return 0, err } @@ -1188,8 +1188,8 @@ func (guo *GroupUpdateOne) sqlSave(ctx context.Context) (_node *Group, err error if err = sqlgraph.UpdateNode(ctx, guo.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{group.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } diff --git a/entc/integration/ent/groupinfo_create.go b/entc/integration/ent/groupinfo_create.go index f46f822c0..7420b3066 100644 --- a/entc/integration/ent/groupinfo_create.go +++ b/entc/integration/ent/groupinfo_create.go @@ -134,8 +134,8 @@ func (gic *GroupInfoCreate) check() error { func (gic *GroupInfoCreate) sqlSave(ctx context.Context) (*GroupInfo, error) { _node, _spec := gic.createSpec() if err := sqlgraph.CreateNode(ctx, gic.driver, _spec); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } @@ -224,8 +224,8 @@ func (gicb *GroupInfoCreateBulk) Save(ctx context.Context) ([]*GroupInfo, error) } else { // Invoke the actual operation on the latest mutation in the chain. if err = sqlgraph.BatchCreate(ctx, gicb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } } } diff --git a/entc/integration/ent/groupinfo_update.go b/entc/integration/ent/groupinfo_update.go index e6921b48d..57a6caaf5 100644 --- a/entc/integration/ent/groupinfo_update.go +++ b/entc/integration/ent/groupinfo_update.go @@ -246,8 +246,8 @@ func (giu *GroupInfoUpdate) sqlSave(ctx context.Context) (n int, err error) { if n, err = sqlgraph.UpdateNodes(ctx, giu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{groupinfo.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return 0, err } @@ -504,8 +504,8 @@ func (giuo *GroupInfoUpdateOne) sqlSave(ctx context.Context) (_node *GroupInfo, if err = sqlgraph.UpdateNode(ctx, giuo.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{groupinfo.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } diff --git a/entc/integration/ent/item_create.go b/entc/integration/ent/item_create.go index e50995475..5cff23aaf 100644 --- a/entc/integration/ent/item_create.go +++ b/entc/integration/ent/item_create.go @@ -93,8 +93,8 @@ func (ic *ItemCreate) check() error { func (ic *ItemCreate) sqlSave(ctx context.Context) (*Item, error) { _node, _spec := ic.createSpec() if err := sqlgraph.CreateNode(ctx, ic.driver, _spec); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } @@ -149,8 +149,8 @@ func (icb *ItemCreateBulk) Save(ctx context.Context) ([]*Item, error) { } else { // Invoke the actual operation on the latest mutation in the chain. if err = sqlgraph.BatchCreate(ctx, icb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } } } diff --git a/entc/integration/ent/item_update.go b/entc/integration/ent/item_update.go index 5dbd8728c..107a3c6d3 100644 --- a/entc/integration/ent/item_update.go +++ b/entc/integration/ent/item_update.go @@ -107,8 +107,8 @@ func (iu *ItemUpdate) sqlSave(ctx context.Context) (n int, err error) { if n, err = sqlgraph.UpdateNodes(ctx, iu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{item.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return 0, err } @@ -227,8 +227,8 @@ func (iuo *ItemUpdateOne) sqlSave(ctx context.Context) (_node *Item, err error) if err = sqlgraph.UpdateNode(ctx, iuo.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{item.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } diff --git a/entc/integration/ent/node_create.go b/entc/integration/ent/node_create.go index 83638a80b..b7fce0f71 100644 --- a/entc/integration/ent/node_create.go +++ b/entc/integration/ent/node_create.go @@ -134,8 +134,8 @@ func (nc *NodeCreate) check() error { func (nc *NodeCreate) sqlSave(ctx context.Context) (*Node, error) { _node, _spec := nc.createSpec() if err := sqlgraph.CreateNode(ctx, nc.driver, _spec); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } @@ -235,8 +235,8 @@ func (ncb *NodeCreateBulk) Save(ctx context.Context) ([]*Node, error) { } else { // Invoke the actual operation on the latest mutation in the chain. if err = sqlgraph.BatchCreate(ctx, ncb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } } } diff --git a/entc/integration/ent/node_update.go b/entc/integration/ent/node_update.go index 08abcc8ab..f7f7aa348 100644 --- a/entc/integration/ent/node_update.go +++ b/entc/integration/ent/node_update.go @@ -274,8 +274,8 @@ func (nu *NodeUpdate) sqlSave(ctx context.Context) (n int, err error) { if n, err = sqlgraph.UpdateNodes(ctx, nu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{node.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return 0, err } @@ -561,8 +561,8 @@ func (nuo *NodeUpdateOne) sqlSave(ctx context.Context) (_node *Node, err error) if err = sqlgraph.UpdateNode(ctx, nuo.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{node.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } diff --git a/entc/integration/ent/pet_create.go b/entc/integration/ent/pet_create.go index 7b31dcdae..12ea3f72b 100644 --- a/entc/integration/ent/pet_create.go +++ b/entc/integration/ent/pet_create.go @@ -164,8 +164,8 @@ func (pc *PetCreate) check() error { func (pc *PetCreate) sqlSave(ctx context.Context) (*Pet, error) { _node, _spec := pc.createSpec() if err := sqlgraph.CreateNode(ctx, pc.driver, _spec); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } @@ -283,8 +283,8 @@ func (pcb *PetCreateBulk) Save(ctx context.Context) ([]*Pet, error) { } else { // Invoke the actual operation on the latest mutation in the chain. if err = sqlgraph.BatchCreate(ctx, pcb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } } } diff --git a/entc/integration/ent/pet_update.go b/entc/integration/ent/pet_update.go index 9cd4e2599..9d148bc26 100644 --- a/entc/integration/ent/pet_update.go +++ b/entc/integration/ent/pet_update.go @@ -302,8 +302,8 @@ func (pu *PetUpdate) sqlSave(ctx context.Context) (n int, err error) { if n, err = sqlgraph.UpdateNodes(ctx, pu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{pet.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return 0, err } @@ -615,8 +615,8 @@ func (puo *PetUpdateOne) sqlSave(ctx context.Context) (_node *Pet, err error) { if err = sqlgraph.UpdateNode(ctx, puo.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{pet.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } diff --git a/entc/integration/ent/spec_create.go b/entc/integration/ent/spec_create.go index a7b2bd32a..f407a1fa3 100644 --- a/entc/integration/ent/spec_create.go +++ b/entc/integration/ent/spec_create.go @@ -98,8 +98,8 @@ func (sc *SpecCreate) check() error { func (sc *SpecCreate) sqlSave(ctx context.Context) (*Spec, error) { _node, _spec := sc.createSpec() if err := sqlgraph.CreateNode(ctx, sc.driver, _spec); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } @@ -171,8 +171,8 @@ func (scb *SpecCreateBulk) Save(ctx context.Context) ([]*Spec, error) { } else { // Invoke the actual operation on the latest mutation in the chain. if err = sqlgraph.BatchCreate(ctx, scb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } } } diff --git a/entc/integration/ent/spec_update.go b/entc/integration/ent/spec_update.go index 4d58f5365..70146bf07 100644 --- a/entc/integration/ent/spec_update.go +++ b/entc/integration/ent/spec_update.go @@ -198,8 +198,8 @@ func (su *SpecUpdate) sqlSave(ctx context.Context) (n int, err error) { if n, err = sqlgraph.UpdateNodes(ctx, su.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{spec.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return 0, err } @@ -408,8 +408,8 @@ func (suo *SpecUpdateOne) sqlSave(ctx context.Context) (_node *Spec, err error) if err = sqlgraph.UpdateNode(ctx, suo.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{spec.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } diff --git a/entc/integration/ent/task_create.go b/entc/integration/ent/task_create.go index af985ff3d..bb80e0e79 100644 --- a/entc/integration/ent/task_create.go +++ b/entc/integration/ent/task_create.go @@ -115,8 +115,8 @@ func (tc *TaskCreate) check() error { func (tc *TaskCreate) sqlSave(ctx context.Context) (*Task, error) { _node, _spec := tc.createSpec() if err := sqlgraph.CreateNode(ctx, tc.driver, _spec); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } @@ -178,8 +178,8 @@ func (tcb *TaskCreateBulk) Save(ctx context.Context) ([]*Task, error) { } else { // Invoke the actual operation on the latest mutation in the chain. if err = sqlgraph.BatchCreate(ctx, tcb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } } } diff --git a/entc/integration/ent/task_update.go b/entc/integration/ent/task_update.go index 633000798..cf70343b7 100644 --- a/entc/integration/ent/task_update.go +++ b/entc/integration/ent/task_update.go @@ -159,8 +159,8 @@ func (tu *TaskUpdate) sqlSave(ctx context.Context) (n int, err error) { if n, err = sqlgraph.UpdateNodes(ctx, tu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{task.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return 0, err } @@ -330,8 +330,8 @@ func (tuo *TaskUpdateOne) sqlSave(ctx context.Context) (_node *Task, err error) if err = sqlgraph.UpdateNode(ctx, tuo.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{task.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } diff --git a/entc/integration/ent/user_create.go b/entc/integration/ent/user_create.go index 17579a059..f947316ec 100644 --- a/entc/integration/ent/user_create.go +++ b/entc/integration/ent/user_create.go @@ -431,8 +431,8 @@ func (uc *UserCreate) check() error { func (uc *UserCreate) sqlSave(ctx context.Context) (*User, error) { _node, _spec := uc.createSpec() if err := sqlgraph.CreateNode(ctx, uc.driver, _spec); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } @@ -777,8 +777,8 @@ func (ucb *UserCreateBulk) Save(ctx context.Context) ([]*User, error) { } else { // Invoke the actual operation on the latest mutation in the chain. if err = sqlgraph.BatchCreate(ctx, ucb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } } } diff --git a/entc/integration/ent/user_update.go b/entc/integration/ent/user_update.go index 036e1b932..4fe01115d 100644 --- a/entc/integration/ent/user_update.go +++ b/entc/integration/ent/user_update.go @@ -1296,8 +1296,8 @@ func (uu *UserUpdate) sqlSave(ctx context.Context) (n int, err error) { if n, err = sqlgraph.UpdateNodes(ctx, uu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{user.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return 0, err } @@ -2601,8 +2601,8 @@ func (uuo *UserUpdateOne) sqlSave(ctx context.Context) (_node *User, err error) if err = sqlgraph.UpdateNode(ctx, uuo.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{user.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } diff --git a/entc/integration/hooks/ent/card_create.go b/entc/integration/hooks/ent/card_create.go index 775acefe9..3fc14443d 100644 --- a/entc/integration/hooks/ent/card_create.go +++ b/entc/integration/hooks/ent/card_create.go @@ -179,8 +179,8 @@ func (cc *CardCreate) check() error { func (cc *CardCreate) sqlSave(ctx context.Context) (*Card, error) { _node, _spec := cc.createSpec() if err := sqlgraph.CreateNode(ctx, cc.driver, _spec); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } @@ -286,8 +286,8 @@ func (ccb *CardCreateBulk) Save(ctx context.Context) ([]*Card, error) { } else { // Invoke the actual operation on the latest mutation in the chain. if err = sqlgraph.BatchCreate(ctx, ccb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } } } diff --git a/entc/integration/hooks/ent/card_update.go b/entc/integration/hooks/ent/card_update.go index 9c12a8a82..44b83841a 100644 --- a/entc/integration/hooks/ent/card_update.go +++ b/entc/integration/hooks/ent/card_update.go @@ -236,8 +236,8 @@ func (cu *CardUpdate) sqlSave(ctx context.Context) (n int, err error) { if n, err = sqlgraph.UpdateNodes(ctx, cu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{card.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return 0, err } @@ -483,8 +483,8 @@ func (cuo *CardUpdateOne) sqlSave(ctx context.Context) (_node *Card, err error) if err = sqlgraph.UpdateNode(ctx, cuo.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{card.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } diff --git a/entc/integration/hooks/ent/ent.go b/entc/integration/hooks/ent/ent.go index 8abda5f36..80ca85aa4 100644 --- a/entc/integration/hooks/ent/ent.go +++ b/entc/integration/hooks/ent/ent.go @@ -12,7 +12,6 @@ import ( "entgo.io/ent" "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/entc/integration/hooks/ent/card" "entgo.io/ent/entc/integration/hooks/ent/user" ) @@ -264,10 +263,3 @@ func IsConstraintError(err error) bool { var e *ConstraintError return errors.As(err, &e) } - -func isSQLConstraintError(err error) (*ConstraintError, bool) { - if sqlgraph.IsConstraintError(err) { - return &ConstraintError{err.Error(), err}, true - } - return nil, false -} diff --git a/entc/integration/hooks/ent/user_create.go b/entc/integration/hooks/ent/user_create.go index f91eaa918..5b1286a8c 100644 --- a/entc/integration/hooks/ent/user_create.go +++ b/entc/integration/hooks/ent/user_create.go @@ -182,8 +182,8 @@ func (uc *UserCreate) check() error { func (uc *UserCreate) sqlSave(ctx context.Context) (*User, error) { _node, _spec := uc.createSpec() if err := sqlgraph.CreateNode(ctx, uc.driver, _spec); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } @@ -319,8 +319,8 @@ func (ucb *UserCreateBulk) Save(ctx context.Context) ([]*User, error) { } else { // Invoke the actual operation on the latest mutation in the chain. if err = sqlgraph.BatchCreate(ctx, ucb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } } } diff --git a/entc/integration/hooks/ent/user_update.go b/entc/integration/hooks/ent/user_update.go index f442c9c56..736318c87 100644 --- a/entc/integration/hooks/ent/user_update.go +++ b/entc/integration/hooks/ent/user_update.go @@ -443,8 +443,8 @@ func (uu *UserUpdate) sqlSave(ctx context.Context) (n int, err error) { if n, err = sqlgraph.UpdateNodes(ctx, uu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{user.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return 0, err } @@ -898,8 +898,8 @@ func (uuo *UserUpdateOne) sqlSave(ctx context.Context) (_node *User, err error) if err = sqlgraph.UpdateNode(ctx, uuo.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{user.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } diff --git a/entc/integration/idtype/ent/ent.go b/entc/integration/idtype/ent/ent.go index 9be169e2a..f15722c09 100644 --- a/entc/integration/idtype/ent/ent.go +++ b/entc/integration/idtype/ent/ent.go @@ -12,7 +12,6 @@ import ( "entgo.io/ent" "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/entc/integration/idtype/ent/user" ) @@ -262,10 +261,3 @@ func IsConstraintError(err error) bool { var e *ConstraintError return errors.As(err, &e) } - -func isSQLConstraintError(err error) (*ConstraintError, bool) { - if sqlgraph.IsConstraintError(err) { - return &ConstraintError{err.Error(), err}, true - } - return nil, false -} diff --git a/entc/integration/idtype/ent/user_create.go b/entc/integration/idtype/ent/user_create.go index 07078dee2..a0b06d105 100644 --- a/entc/integration/idtype/ent/user_create.go +++ b/entc/integration/idtype/ent/user_create.go @@ -141,8 +141,8 @@ func (uc *UserCreate) check() error { func (uc *UserCreate) sqlSave(ctx context.Context) (*User, error) { _node, _spec := uc.createSpec() if err := sqlgraph.CreateNode(ctx, uc.driver, _spec); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } @@ -261,8 +261,8 @@ func (ucb *UserCreateBulk) Save(ctx context.Context) ([]*User, error) { } else { // Invoke the actual operation on the latest mutation in the chain. if err = sqlgraph.BatchCreate(ctx, ucb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } } } diff --git a/entc/integration/idtype/ent/user_update.go b/entc/integration/idtype/ent/user_update.go index 82df0aa6e..f1dc4be56 100644 --- a/entc/integration/idtype/ent/user_update.go +++ b/entc/integration/idtype/ent/user_update.go @@ -360,8 +360,8 @@ func (uu *UserUpdate) sqlSave(ctx context.Context) (n int, err error) { if n, err = sqlgraph.UpdateNodes(ctx, uu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{user.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return 0, err } @@ -733,8 +733,8 @@ func (uuo *UserUpdateOne) sqlSave(ctx context.Context) (_node *User, err error) if err = sqlgraph.UpdateNode(ctx, uuo.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{user.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } diff --git a/entc/integration/json/ent/ent.go b/entc/integration/json/ent/ent.go index 2f526b487..8c896f62f 100644 --- a/entc/integration/json/ent/ent.go +++ b/entc/integration/json/ent/ent.go @@ -12,7 +12,6 @@ import ( "entgo.io/ent" "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/entc/integration/json/ent/user" ) @@ -262,10 +261,3 @@ func IsConstraintError(err error) bool { var e *ConstraintError return errors.As(err, &e) } - -func isSQLConstraintError(err error) (*ConstraintError, bool) { - if sqlgraph.IsConstraintError(err) { - return &ConstraintError{err.Error(), err}, true - } - return nil, false -} diff --git a/entc/integration/json/ent/user_create.go b/entc/integration/json/ent/user_create.go index 4ca6a887d..2af0fb067 100644 --- a/entc/integration/json/ent/user_create.go +++ b/entc/integration/json/ent/user_create.go @@ -128,8 +128,8 @@ func (uc *UserCreate) check() error { func (uc *UserCreate) sqlSave(ctx context.Context) (*User, error) { _node, _spec := uc.createSpec() if err := sqlgraph.CreateNode(ctx, uc.driver, _spec); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } @@ -238,8 +238,8 @@ func (ucb *UserCreateBulk) Save(ctx context.Context) ([]*User, error) { } else { // Invoke the actual operation on the latest mutation in the chain. if err = sqlgraph.BatchCreate(ctx, ucb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } } } diff --git a/entc/integration/json/ent/user_update.go b/entc/integration/json/ent/user_update.go index 691bc9d84..7995178d8 100644 --- a/entc/integration/json/ent/user_update.go +++ b/entc/integration/json/ent/user_update.go @@ -286,8 +286,8 @@ func (uu *UserUpdate) sqlSave(ctx context.Context) (n int, err error) { if n, err = sqlgraph.UpdateNodes(ctx, uu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{user.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return 0, err } @@ -581,8 +581,8 @@ func (uuo *UserUpdateOne) sqlSave(ctx context.Context) (_node *User, err error) if err = sqlgraph.UpdateNode(ctx, uuo.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{user.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } diff --git a/entc/integration/migrate/entv1/car_create.go b/entc/integration/migrate/entv1/car_create.go index 94c67a194..52a961eeb 100644 --- a/entc/integration/migrate/entv1/car_create.go +++ b/entc/integration/migrate/entv1/car_create.go @@ -102,8 +102,8 @@ func (cc *CarCreate) check() error { func (cc *CarCreate) sqlSave(ctx context.Context) (*Car, error) { _node, _spec := cc.createSpec() if err := sqlgraph.CreateNode(ctx, cc.driver, _spec); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } @@ -176,8 +176,8 @@ func (ccb *CarCreateBulk) Save(ctx context.Context) ([]*Car, error) { } else { // Invoke the actual operation on the latest mutation in the chain. if err = sqlgraph.BatchCreate(ctx, ccb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } } } diff --git a/entc/integration/migrate/entv1/car_update.go b/entc/integration/migrate/entv1/car_update.go index 63cb1ec63..49c30170c 100644 --- a/entc/integration/migrate/entv1/car_update.go +++ b/entc/integration/migrate/entv1/car_update.go @@ -168,8 +168,8 @@ func (cu *CarUpdate) sqlSave(ctx context.Context) (n int, err error) { if n, err = sqlgraph.UpdateNodes(ctx, cu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{car.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return 0, err } @@ -348,8 +348,8 @@ func (cuo *CarUpdateOne) sqlSave(ctx context.Context) (_node *Car, err error) { if err = sqlgraph.UpdateNode(ctx, cuo.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{car.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } diff --git a/entc/integration/migrate/entv1/conversion_create.go b/entc/integration/migrate/entv1/conversion_create.go index 0b804ae19..cb9c1b04e 100644 --- a/entc/integration/migrate/entv1/conversion_create.go +++ b/entc/integration/migrate/entv1/conversion_create.go @@ -208,8 +208,8 @@ func (cc *ConversionCreate) check() error { func (cc *ConversionCreate) sqlSave(ctx context.Context) (*Conversion, error) { _node, _spec := cc.createSpec() if err := sqlgraph.CreateNode(ctx, cc.driver, _spec); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } @@ -334,8 +334,8 @@ func (ccb *ConversionCreateBulk) Save(ctx context.Context) ([]*Conversion, error } else { // Invoke the actual operation on the latest mutation in the chain. if err = sqlgraph.BatchCreate(ctx, ccb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } } } diff --git a/entc/integration/migrate/entv1/conversion_update.go b/entc/integration/migrate/entv1/conversion_update.go index 4ffcbfcfd..e5f9b8cb5 100644 --- a/entc/integration/migrate/entv1/conversion_update.go +++ b/entc/integration/migrate/entv1/conversion_update.go @@ -516,8 +516,8 @@ func (cu *ConversionUpdate) sqlSave(ctx context.Context) (n int, err error) { if n, err = sqlgraph.UpdateNodes(ctx, cu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{conversion.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return 0, err } @@ -1045,8 +1045,8 @@ func (cuo *ConversionUpdateOne) sqlSave(ctx context.Context) (_node *Conversion, if err = sqlgraph.UpdateNode(ctx, cuo.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{conversion.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } diff --git a/entc/integration/migrate/entv1/customtype_create.go b/entc/integration/migrate/entv1/customtype_create.go index 284b28de6..05deeca1f 100644 --- a/entc/integration/migrate/entv1/customtype_create.go +++ b/entc/integration/migrate/entv1/customtype_create.go @@ -96,8 +96,8 @@ func (ctc *CustomTypeCreate) check() error { func (ctc *CustomTypeCreate) sqlSave(ctx context.Context) (*CustomType, error) { _node, _spec := ctc.createSpec() if err := sqlgraph.CreateNode(ctx, ctc.driver, _spec); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } @@ -158,8 +158,8 @@ func (ctcb *CustomTypeCreateBulk) Save(ctx context.Context) ([]*CustomType, erro } else { // Invoke the actual operation on the latest mutation in the chain. if err = sqlgraph.BatchCreate(ctx, ctcb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } } } diff --git a/entc/integration/migrate/entv1/customtype_update.go b/entc/integration/migrate/entv1/customtype_update.go index 077da9f18..beb5f26f0 100644 --- a/entc/integration/migrate/entv1/customtype_update.go +++ b/entc/integration/migrate/entv1/customtype_update.go @@ -140,8 +140,8 @@ func (ctu *CustomTypeUpdate) sqlSave(ctx context.Context) (n int, err error) { if n, err = sqlgraph.UpdateNodes(ctx, ctu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{customtype.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return 0, err } @@ -293,8 +293,8 @@ func (ctuo *CustomTypeUpdateOne) sqlSave(ctx context.Context) (_node *CustomType if err = sqlgraph.UpdateNode(ctx, ctuo.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{customtype.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } diff --git a/entc/integration/migrate/entv1/ent.go b/entc/integration/migrate/entv1/ent.go index c3b46fdeb..ab2b4fb77 100644 --- a/entc/integration/migrate/entv1/ent.go +++ b/entc/integration/migrate/entv1/ent.go @@ -12,7 +12,6 @@ import ( "entgo.io/ent" "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/entc/integration/migrate/entv1/car" "entgo.io/ent/entc/integration/migrate/entv1/conversion" "entgo.io/ent/entc/integration/migrate/entv1/customtype" @@ -268,10 +267,3 @@ func IsConstraintError(err error) bool { var e *ConstraintError return errors.As(err, &e) } - -func isSQLConstraintError(err error) (*ConstraintError, bool) { - if sqlgraph.IsConstraintError(err) { - return &ConstraintError{err.Error(), err}, true - } - return nil, false -} diff --git a/entc/integration/migrate/entv1/user_create.go b/entc/integration/migrate/entv1/user_create.go index b1638fae2..493d13567 100644 --- a/entc/integration/migrate/entv1/user_create.go +++ b/entc/integration/migrate/entv1/user_create.go @@ -294,8 +294,8 @@ func (uc *UserCreate) check() error { func (uc *UserCreate) sqlSave(ctx context.Context) (*User, error) { _node, _spec := uc.createSpec() if err := sqlgraph.CreateNode(ctx, uc.driver, _spec); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } @@ -512,8 +512,8 @@ func (ucb *UserCreateBulk) Save(ctx context.Context) ([]*User, error) { } else { // Invoke the actual operation on the latest mutation in the chain. if err = sqlgraph.BatchCreate(ctx, ucb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } } } diff --git a/entc/integration/migrate/entv1/user_update.go b/entc/integration/migrate/entv1/user_update.go index 002ec1ae7..8308726d3 100644 --- a/entc/integration/migrate/entv1/user_update.go +++ b/entc/integration/migrate/entv1/user_update.go @@ -680,8 +680,8 @@ func (uu *UserUpdate) sqlSave(ctx context.Context) (n int, err error) { if n, err = sqlgraph.UpdateNodes(ctx, uu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{user.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return 0, err } @@ -1372,8 +1372,8 @@ func (uuo *UserUpdateOne) sqlSave(ctx context.Context) (_node *User, err error) if err = sqlgraph.UpdateNode(ctx, uuo.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{user.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } diff --git a/entc/integration/migrate/entv2/car_create.go b/entc/integration/migrate/entv2/car_create.go index 5e806c079..1b6c3c0dd 100644 --- a/entc/integration/migrate/entv2/car_create.go +++ b/entc/integration/migrate/entv2/car_create.go @@ -102,8 +102,8 @@ func (cc *CarCreate) check() error { func (cc *CarCreate) sqlSave(ctx context.Context) (*Car, error) { _node, _spec := cc.createSpec() if err := sqlgraph.CreateNode(ctx, cc.driver, _spec); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } @@ -176,8 +176,8 @@ func (ccb *CarCreateBulk) Save(ctx context.Context) ([]*Car, error) { } else { // Invoke the actual operation on the latest mutation in the chain. if err = sqlgraph.BatchCreate(ctx, ccb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } } } diff --git a/entc/integration/migrate/entv2/car_update.go b/entc/integration/migrate/entv2/car_update.go index 97b37dbd9..698797810 100644 --- a/entc/integration/migrate/entv2/car_update.go +++ b/entc/integration/migrate/entv2/car_update.go @@ -168,8 +168,8 @@ func (cu *CarUpdate) sqlSave(ctx context.Context) (n int, err error) { if n, err = sqlgraph.UpdateNodes(ctx, cu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{car.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return 0, err } @@ -348,8 +348,8 @@ func (cuo *CarUpdateOne) sqlSave(ctx context.Context) (_node *Car, err error) { if err = sqlgraph.UpdateNode(ctx, cuo.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{car.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } diff --git a/entc/integration/migrate/entv2/conversion_create.go b/entc/integration/migrate/entv2/conversion_create.go index 3e86058f5..85cd31605 100644 --- a/entc/integration/migrate/entv2/conversion_create.go +++ b/entc/integration/migrate/entv2/conversion_create.go @@ -208,8 +208,8 @@ func (cc *ConversionCreate) check() error { func (cc *ConversionCreate) sqlSave(ctx context.Context) (*Conversion, error) { _node, _spec := cc.createSpec() if err := sqlgraph.CreateNode(ctx, cc.driver, _spec); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } @@ -334,8 +334,8 @@ func (ccb *ConversionCreateBulk) Save(ctx context.Context) ([]*Conversion, error } else { // Invoke the actual operation on the latest mutation in the chain. if err = sqlgraph.BatchCreate(ctx, ccb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } } } diff --git a/entc/integration/migrate/entv2/conversion_update.go b/entc/integration/migrate/entv2/conversion_update.go index 209bbd1f3..955f104c8 100644 --- a/entc/integration/migrate/entv2/conversion_update.go +++ b/entc/integration/migrate/entv2/conversion_update.go @@ -404,8 +404,8 @@ func (cu *ConversionUpdate) sqlSave(ctx context.Context) (n int, err error) { if n, err = sqlgraph.UpdateNodes(ctx, cu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{conversion.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return 0, err } @@ -821,8 +821,8 @@ func (cuo *ConversionUpdateOne) sqlSave(ctx context.Context) (_node *Conversion, if err = sqlgraph.UpdateNode(ctx, cuo.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{conversion.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } diff --git a/entc/integration/migrate/entv2/customtype_create.go b/entc/integration/migrate/entv2/customtype_create.go index 201eda468..491444f58 100644 --- a/entc/integration/migrate/entv2/customtype_create.go +++ b/entc/integration/migrate/entv2/customtype_create.go @@ -96,8 +96,8 @@ func (ctc *CustomTypeCreate) check() error { func (ctc *CustomTypeCreate) sqlSave(ctx context.Context) (*CustomType, error) { _node, _spec := ctc.createSpec() if err := sqlgraph.CreateNode(ctx, ctc.driver, _spec); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } @@ -158,8 +158,8 @@ func (ctcb *CustomTypeCreateBulk) Save(ctx context.Context) ([]*CustomType, erro } else { // Invoke the actual operation on the latest mutation in the chain. if err = sqlgraph.BatchCreate(ctx, ctcb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } } } diff --git a/entc/integration/migrate/entv2/customtype_update.go b/entc/integration/migrate/entv2/customtype_update.go index c65ec296c..81ab4f98f 100644 --- a/entc/integration/migrate/entv2/customtype_update.go +++ b/entc/integration/migrate/entv2/customtype_update.go @@ -140,8 +140,8 @@ func (ctu *CustomTypeUpdate) sqlSave(ctx context.Context) (n int, err error) { if n, err = sqlgraph.UpdateNodes(ctx, ctu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{customtype.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return 0, err } @@ -293,8 +293,8 @@ func (ctuo *CustomTypeUpdateOne) sqlSave(ctx context.Context) (_node *CustomType if err = sqlgraph.UpdateNode(ctx, ctuo.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{customtype.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } diff --git a/entc/integration/migrate/entv2/ent.go b/entc/integration/migrate/entv2/ent.go index f9dee9425..91faa897e 100644 --- a/entc/integration/migrate/entv2/ent.go +++ b/entc/integration/migrate/entv2/ent.go @@ -12,7 +12,6 @@ import ( "entgo.io/ent" "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/entc/integration/migrate/entv2/car" "entgo.io/ent/entc/integration/migrate/entv2/conversion" "entgo.io/ent/entc/integration/migrate/entv2/customtype" @@ -274,10 +273,3 @@ func IsConstraintError(err error) bool { var e *ConstraintError return errors.As(err, &e) } - -func isSQLConstraintError(err error) (*ConstraintError, bool) { - if sqlgraph.IsConstraintError(err) { - return &ConstraintError{err.Error(), err}, true - } - return nil, false -} diff --git a/entc/integration/migrate/entv2/group_create.go b/entc/integration/migrate/entv2/group_create.go index 5788205e3..99861eb1c 100644 --- a/entc/integration/migrate/entv2/group_create.go +++ b/entc/integration/migrate/entv2/group_create.go @@ -82,8 +82,8 @@ func (gc *GroupCreate) check() error { func (gc *GroupCreate) sqlSave(ctx context.Context) (*Group, error) { _node, _spec := gc.createSpec() if err := sqlgraph.CreateNode(ctx, gc.driver, _spec); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } @@ -136,8 +136,8 @@ func (gcb *GroupCreateBulk) Save(ctx context.Context) ([]*Group, error) { } else { // Invoke the actual operation on the latest mutation in the chain. if err = sqlgraph.BatchCreate(ctx, gcb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } } } diff --git a/entc/integration/migrate/entv2/group_update.go b/entc/integration/migrate/entv2/group_update.go index 1b7985f80..298d3d849 100644 --- a/entc/integration/migrate/entv2/group_update.go +++ b/entc/integration/migrate/entv2/group_update.go @@ -107,8 +107,8 @@ func (gu *GroupUpdate) sqlSave(ctx context.Context) (n int, err error) { if n, err = sqlgraph.UpdateNodes(ctx, gu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{group.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return 0, err } @@ -227,8 +227,8 @@ func (guo *GroupUpdateOne) sqlSave(ctx context.Context) (_node *Group, err error if err = sqlgraph.UpdateNode(ctx, guo.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{group.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } diff --git a/entc/integration/migrate/entv2/media_create.go b/entc/integration/migrate/entv2/media_create.go index 4e344c054..aee6ba749 100644 --- a/entc/integration/migrate/entv2/media_create.go +++ b/entc/integration/migrate/entv2/media_create.go @@ -124,8 +124,8 @@ func (mc *MediaCreate) check() error { func (mc *MediaCreate) sqlSave(ctx context.Context) (*Media, error) { _node, _spec := mc.createSpec() if err := sqlgraph.CreateNode(ctx, mc.driver, _spec); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } @@ -202,8 +202,8 @@ func (mcb *MediaCreateBulk) Save(ctx context.Context) ([]*Media, error) { } else { // Invoke the actual operation on the latest mutation in the chain. if err = sqlgraph.BatchCreate(ctx, mcb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } } } diff --git a/entc/integration/migrate/entv2/media_update.go b/entc/integration/migrate/entv2/media_update.go index 1e5be7867..7a37572a7 100644 --- a/entc/integration/migrate/entv2/media_update.go +++ b/entc/integration/migrate/entv2/media_update.go @@ -206,8 +206,8 @@ func (mu *MediaUpdate) sqlSave(ctx context.Context) (n int, err error) { if n, err = sqlgraph.UpdateNodes(ctx, mu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{media.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return 0, err } @@ -425,8 +425,8 @@ func (muo *MediaUpdateOne) sqlSave(ctx context.Context) (_node *Media, err error if err = sqlgraph.UpdateNode(ctx, muo.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{media.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } diff --git a/entc/integration/migrate/entv2/pet_create.go b/entc/integration/migrate/entv2/pet_create.go index e27974aea..a40c6932e 100644 --- a/entc/integration/migrate/entv2/pet_create.go +++ b/entc/integration/migrate/entv2/pet_create.go @@ -102,8 +102,8 @@ func (pc *PetCreate) check() error { func (pc *PetCreate) sqlSave(ctx context.Context) (*Pet, error) { _node, _spec := pc.createSpec() if err := sqlgraph.CreateNode(ctx, pc.driver, _spec); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } @@ -176,8 +176,8 @@ func (pcb *PetCreateBulk) Save(ctx context.Context) ([]*Pet, error) { } else { // Invoke the actual operation on the latest mutation in the chain. if err = sqlgraph.BatchCreate(ctx, pcb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } } } diff --git a/entc/integration/migrate/entv2/pet_update.go b/entc/integration/migrate/entv2/pet_update.go index 5cadb77d9..07c8e8a04 100644 --- a/entc/integration/migrate/entv2/pet_update.go +++ b/entc/integration/migrate/entv2/pet_update.go @@ -168,8 +168,8 @@ func (pu *PetUpdate) sqlSave(ctx context.Context) (n int, err error) { if n, err = sqlgraph.UpdateNodes(ctx, pu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{pet.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return 0, err } @@ -348,8 +348,8 @@ func (puo *PetUpdateOne) sqlSave(ctx context.Context) (_node *Pet, err error) { if err = sqlgraph.UpdateNode(ctx, puo.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{pet.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } diff --git a/entc/integration/migrate/entv2/user_create.go b/entc/integration/migrate/entv2/user_create.go index 7ad60e30b..6f280248f 100644 --- a/entc/integration/migrate/entv2/user_create.go +++ b/entc/integration/migrate/entv2/user_create.go @@ -384,8 +384,8 @@ func (uc *UserCreate) check() error { func (uc *UserCreate) sqlSave(ctx context.Context) (*User, error) { _node, _spec := uc.createSpec() if err := sqlgraph.CreateNode(ctx, uc.driver, _spec); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } @@ -622,8 +622,8 @@ func (ucb *UserCreateBulk) Save(ctx context.Context) ([]*User, error) { } else { // Invoke the actual operation on the latest mutation in the chain. if err = sqlgraph.BatchCreate(ctx, ucb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } } } diff --git a/entc/integration/migrate/entv2/user_update.go b/entc/integration/migrate/entv2/user_update.go index 94a91cfc6..a4663073e 100644 --- a/entc/integration/migrate/entv2/user_update.go +++ b/entc/integration/migrate/entv2/user_update.go @@ -754,8 +754,8 @@ func (uu *UserUpdate) sqlSave(ctx context.Context) (n int, err error) { if n, err = sqlgraph.UpdateNodes(ctx, uu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{user.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return 0, err } @@ -1518,8 +1518,8 @@ func (uuo *UserUpdateOne) sqlSave(ctx context.Context) (_node *User, err error) if err = sqlgraph.UpdateNode(ctx, uuo.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{user.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } diff --git a/entc/integration/multischema/ent/ent.go b/entc/integration/multischema/ent/ent.go index 2deadcaac..8890c8b46 100644 --- a/entc/integration/multischema/ent/ent.go +++ b/entc/integration/multischema/ent/ent.go @@ -12,7 +12,6 @@ import ( "entgo.io/ent" "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/entc/integration/multischema/ent/group" "entgo.io/ent/entc/integration/multischema/ent/pet" "entgo.io/ent/entc/integration/multischema/ent/user" @@ -266,10 +265,3 @@ func IsConstraintError(err error) bool { var e *ConstraintError return errors.As(err, &e) } - -func isSQLConstraintError(err error) (*ConstraintError, bool) { - if sqlgraph.IsConstraintError(err) { - return &ConstraintError{err.Error(), err}, true - } - return nil, false -} diff --git a/entc/integration/multischema/ent/group_create.go b/entc/integration/multischema/ent/group_create.go index 0459e8b6d..f078eb21a 100644 --- a/entc/integration/multischema/ent/group_create.go +++ b/entc/integration/multischema/ent/group_create.go @@ -125,8 +125,8 @@ func (gc *GroupCreate) check() error { func (gc *GroupCreate) sqlSave(ctx context.Context) (*Group, error) { _node, _spec := gc.createSpec() if err := sqlgraph.CreateNode(ctx, gc.driver, _spec); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } @@ -209,8 +209,8 @@ func (gcb *GroupCreateBulk) Save(ctx context.Context) ([]*Group, error) { } else { // Invoke the actual operation on the latest mutation in the chain. if err = sqlgraph.BatchCreate(ctx, gcb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } } } diff --git a/entc/integration/multischema/ent/group_update.go b/entc/integration/multischema/ent/group_update.go index 55dae7020..0613a2982 100644 --- a/entc/integration/multischema/ent/group_update.go +++ b/entc/integration/multischema/ent/group_update.go @@ -225,8 +225,8 @@ func (gu *GroupUpdate) sqlSave(ctx context.Context) (n int, err error) { if n, err = sqlgraph.UpdateNodes(ctx, gu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{group.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return 0, err } @@ -461,8 +461,8 @@ func (guo *GroupUpdateOne) sqlSave(ctx context.Context) (_node *Group, err error if err = sqlgraph.UpdateNode(ctx, guo.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{group.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } diff --git a/entc/integration/multischema/ent/pet_create.go b/entc/integration/multischema/ent/pet_create.go index d5ce52cc1..10c966b55 100644 --- a/entc/integration/multischema/ent/pet_create.go +++ b/entc/integration/multischema/ent/pet_create.go @@ -129,8 +129,8 @@ func (pc *PetCreate) check() error { func (pc *PetCreate) sqlSave(ctx context.Context) (*Pet, error) { _node, _spec := pc.createSpec() if err := sqlgraph.CreateNode(ctx, pc.driver, _spec); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } @@ -214,8 +214,8 @@ func (pcb *PetCreateBulk) Save(ctx context.Context) ([]*Pet, error) { } else { // Invoke the actual operation on the latest mutation in the chain. if err = sqlgraph.BatchCreate(ctx, pcb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } } } diff --git a/entc/integration/multischema/ent/pet_update.go b/entc/integration/multischema/ent/pet_update.go index 18736600e..dae6222aa 100644 --- a/entc/integration/multischema/ent/pet_update.go +++ b/entc/integration/multischema/ent/pet_update.go @@ -194,8 +194,8 @@ func (pu *PetUpdate) sqlSave(ctx context.Context) (n int, err error) { if n, err = sqlgraph.UpdateNodes(ctx, pu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{pet.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return 0, err } @@ -399,8 +399,8 @@ func (puo *PetUpdateOne) sqlSave(ctx context.Context) (_node *Pet, err error) { if err = sqlgraph.UpdateNode(ctx, puo.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{pet.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } diff --git a/entc/integration/multischema/ent/user_create.go b/entc/integration/multischema/ent/user_create.go index baf795f03..08f4f76ee 100644 --- a/entc/integration/multischema/ent/user_create.go +++ b/entc/integration/multischema/ent/user_create.go @@ -141,8 +141,8 @@ func (uc *UserCreate) check() error { func (uc *UserCreate) sqlSave(ctx context.Context) (*User, error) { _node, _spec := uc.createSpec() if err := sqlgraph.CreateNode(ctx, uc.driver, _spec); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } @@ -245,8 +245,8 @@ func (ucb *UserCreateBulk) Save(ctx context.Context) ([]*User, error) { } else { // Invoke the actual operation on the latest mutation in the chain. if err = sqlgraph.BatchCreate(ctx, ucb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } } } diff --git a/entc/integration/multischema/ent/user_update.go b/entc/integration/multischema/ent/user_update.go index 741140017..dfd371a33 100644 --- a/entc/integration/multischema/ent/user_update.go +++ b/entc/integration/multischema/ent/user_update.go @@ -319,8 +319,8 @@ func (uu *UserUpdate) sqlSave(ctx context.Context) (n int, err error) { if n, err = sqlgraph.UpdateNodes(ctx, uu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{user.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return 0, err } @@ -648,8 +648,8 @@ func (uuo *UserUpdateOne) sqlSave(ctx context.Context) (_node *User, err error) if err = sqlgraph.UpdateNode(ctx, uuo.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{user.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } diff --git a/entc/integration/privacy/ent/ent.go b/entc/integration/privacy/ent/ent.go index cb093846a..3a6a53ef5 100644 --- a/entc/integration/privacy/ent/ent.go +++ b/entc/integration/privacy/ent/ent.go @@ -12,7 +12,6 @@ import ( "entgo.io/ent" "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/entc/integration/privacy/ent/task" "entgo.io/ent/entc/integration/privacy/ent/team" "entgo.io/ent/entc/integration/privacy/ent/user" @@ -266,10 +265,3 @@ func IsConstraintError(err error) bool { var e *ConstraintError return errors.As(err, &e) } - -func isSQLConstraintError(err error) (*ConstraintError, bool) { - if sqlgraph.IsConstraintError(err) { - return &ConstraintError{err.Error(), err}, true - } - return nil, false -} diff --git a/entc/integration/privacy/ent/task_create.go b/entc/integration/privacy/ent/task_create.go index 02cf62387..c2d2557ef 100644 --- a/entc/integration/privacy/ent/task_create.go +++ b/entc/integration/privacy/ent/task_create.go @@ -185,8 +185,8 @@ func (tc *TaskCreate) check() error { func (tc *TaskCreate) sqlSave(ctx context.Context) (*Task, error) { _node, _spec := tc.createSpec() if err := sqlgraph.CreateNode(ctx, tc.driver, _spec); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } @@ -311,8 +311,8 @@ func (tcb *TaskCreateBulk) Save(ctx context.Context) ([]*Task, error) { } else { // Invoke the actual operation on the latest mutation in the chain. if err = sqlgraph.BatchCreate(ctx, tcb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } } } diff --git a/entc/integration/privacy/ent/task_update.go b/entc/integration/privacy/ent/task_update.go index 408485264..801f45165 100644 --- a/entc/integration/privacy/ent/task_update.go +++ b/entc/integration/privacy/ent/task_update.go @@ -373,8 +373,8 @@ func (tu *TaskUpdate) sqlSave(ctx context.Context) (n int, err error) { if n, err = sqlgraph.UpdateNodes(ctx, tu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{task.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return 0, err } @@ -756,8 +756,8 @@ func (tuo *TaskUpdateOne) sqlSave(ctx context.Context) (_node *Task, err error) if err = sqlgraph.UpdateNode(ctx, tuo.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{task.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } diff --git a/entc/integration/privacy/ent/team_create.go b/entc/integration/privacy/ent/team_create.go index 58aa5d37f..57c6daf0d 100644 --- a/entc/integration/privacy/ent/team_create.go +++ b/entc/integration/privacy/ent/team_create.go @@ -129,8 +129,8 @@ func (tc *TeamCreate) check() error { func (tc *TeamCreate) sqlSave(ctx context.Context) (*Team, error) { _node, _spec := tc.createSpec() if err := sqlgraph.CreateNode(ctx, tc.driver, _spec); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } @@ -229,8 +229,8 @@ func (tcb *TeamCreateBulk) Save(ctx context.Context) ([]*Team, error) { } else { // Invoke the actual operation on the latest mutation in the chain. if err = sqlgraph.BatchCreate(ctx, tcb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } } } diff --git a/entc/integration/privacy/ent/team_update.go b/entc/integration/privacy/ent/team_update.go index 9d15731d2..00cef9a07 100644 --- a/entc/integration/privacy/ent/team_update.go +++ b/entc/integration/privacy/ent/team_update.go @@ -318,8 +318,8 @@ func (tu *TeamUpdate) sqlSave(ctx context.Context) (n int, err error) { if n, err = sqlgraph.UpdateNodes(ctx, tu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{team.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return 0, err } @@ -647,8 +647,8 @@ func (tuo *TeamUpdateOne) sqlSave(ctx context.Context) (_node *Team, err error) if err = sqlgraph.UpdateNode(ctx, tuo.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{team.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } diff --git a/entc/integration/privacy/ent/user_create.go b/entc/integration/privacy/ent/user_create.go index 30ab8c21f..d9c4b76a9 100644 --- a/entc/integration/privacy/ent/user_create.go +++ b/entc/integration/privacy/ent/user_create.go @@ -143,8 +143,8 @@ func (uc *UserCreate) check() error { func (uc *UserCreate) sqlSave(ctx context.Context) (*User, error) { _node, _spec := uc.createSpec() if err := sqlgraph.CreateNode(ctx, uc.driver, _spec); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } @@ -251,8 +251,8 @@ func (ucb *UserCreateBulk) Save(ctx context.Context) ([]*User, error) { } else { // Invoke the actual operation on the latest mutation in the chain. if err = sqlgraph.BatchCreate(ctx, ucb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } } } diff --git a/entc/integration/privacy/ent/user_update.go b/entc/integration/privacy/ent/user_update.go index 046ab9659..a94900907 100644 --- a/entc/integration/privacy/ent/user_update.go +++ b/entc/integration/privacy/ent/user_update.go @@ -336,8 +336,8 @@ func (uu *UserUpdate) sqlSave(ctx context.Context) (n int, err error) { if n, err = sqlgraph.UpdateNodes(ctx, uu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{user.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return 0, err } @@ -683,8 +683,8 @@ func (uuo *UserUpdateOne) sqlSave(ctx context.Context) (_node *User, err error) if err = sqlgraph.UpdateNode(ctx, uuo.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{user.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } diff --git a/entc/integration/template/ent/ent.go b/entc/integration/template/ent/ent.go index b584dad45..bd4c1667b 100644 --- a/entc/integration/template/ent/ent.go +++ b/entc/integration/template/ent/ent.go @@ -12,7 +12,6 @@ import ( "entgo.io/ent" "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/entc/integration/template/ent/group" "entgo.io/ent/entc/integration/template/ent/pet" "entgo.io/ent/entc/integration/template/ent/user" @@ -266,10 +265,3 @@ func IsConstraintError(err error) bool { var e *ConstraintError return errors.As(err, &e) } - -func isSQLConstraintError(err error) (*ConstraintError, bool) { - if sqlgraph.IsConstraintError(err) { - return &ConstraintError{err.Error(), err}, true - } - return nil, false -} diff --git a/entc/integration/template/ent/group_create.go b/entc/integration/template/ent/group_create.go index af5fbc863..3bd2f7170 100644 --- a/entc/integration/template/ent/group_create.go +++ b/entc/integration/template/ent/group_create.go @@ -92,8 +92,8 @@ func (gc *GroupCreate) check() error { func (gc *GroupCreate) sqlSave(ctx context.Context) (*Group, error) { _node, _spec := gc.createSpec() if err := sqlgraph.CreateNode(ctx, gc.driver, _spec); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } @@ -154,8 +154,8 @@ func (gcb *GroupCreateBulk) Save(ctx context.Context) ([]*Group, error) { } else { // Invoke the actual operation on the latest mutation in the chain. if err = sqlgraph.BatchCreate(ctx, gcb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } } } diff --git a/entc/integration/template/ent/group_update.go b/entc/integration/template/ent/group_update.go index 097b73bb4..2aea39964 100644 --- a/entc/integration/template/ent/group_update.go +++ b/entc/integration/template/ent/group_update.go @@ -134,8 +134,8 @@ func (gu *GroupUpdate) sqlSave(ctx context.Context) (n int, err error) { if n, err = sqlgraph.UpdateNodes(ctx, gu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{group.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return 0, err } @@ -281,8 +281,8 @@ func (guo *GroupUpdateOne) sqlSave(ctx context.Context) (_node *Group, err error if err = sqlgraph.UpdateNode(ctx, guo.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{group.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } diff --git a/entc/integration/template/ent/pet_create.go b/entc/integration/template/ent/pet_create.go index 48da82ed9..eea65a6cd 100644 --- a/entc/integration/template/ent/pet_create.go +++ b/entc/integration/template/ent/pet_create.go @@ -127,8 +127,8 @@ func (pc *PetCreate) check() error { func (pc *PetCreate) sqlSave(ctx context.Context) (*Pet, error) { _node, _spec := pc.createSpec() if err := sqlgraph.CreateNode(ctx, pc.driver, _spec); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } @@ -217,8 +217,8 @@ func (pcb *PetCreateBulk) Save(ctx context.Context) ([]*Pet, error) { } else { // Invoke the actual operation on the latest mutation in the chain. if err = sqlgraph.BatchCreate(ctx, pcb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } } } diff --git a/entc/integration/template/ent/pet_update.go b/entc/integration/template/ent/pet_update.go index 6ec7b8584..58056b689 100644 --- a/entc/integration/template/ent/pet_update.go +++ b/entc/integration/template/ent/pet_update.go @@ -229,8 +229,8 @@ func (pu *PetUpdate) sqlSave(ctx context.Context) (n int, err error) { if n, err = sqlgraph.UpdateNodes(ctx, pu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{pet.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return 0, err } @@ -469,8 +469,8 @@ func (puo *PetUpdateOne) sqlSave(ctx context.Context) (_node *Pet, err error) { if err = sqlgraph.UpdateNode(ctx, puo.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{pet.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } diff --git a/entc/integration/template/ent/user_create.go b/entc/integration/template/ent/user_create.go index acd898abe..48279937a 100644 --- a/entc/integration/template/ent/user_create.go +++ b/entc/integration/template/ent/user_create.go @@ -123,8 +123,8 @@ func (uc *UserCreate) check() error { func (uc *UserCreate) sqlSave(ctx context.Context) (*User, error) { _node, _spec := uc.createSpec() if err := sqlgraph.CreateNode(ctx, uc.driver, _spec); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } @@ -223,8 +223,8 @@ func (ucb *UserCreateBulk) Save(ctx context.Context) ([]*User, error) { } else { // Invoke the actual operation on the latest mutation in the chain. if err = sqlgraph.BatchCreate(ctx, ucb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } } } diff --git a/entc/integration/template/ent/user_update.go b/entc/integration/template/ent/user_update.go index 7073ed938..acbd15720 100644 --- a/entc/integration/template/ent/user_update.go +++ b/entc/integration/template/ent/user_update.go @@ -301,8 +301,8 @@ func (uu *UserUpdate) sqlSave(ctx context.Context) (n int, err error) { if n, err = sqlgraph.UpdateNodes(ctx, uu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{user.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return 0, err } @@ -614,8 +614,8 @@ func (uuo *UserUpdateOne) sqlSave(ctx context.Context) (_node *User, err error) if err = sqlgraph.UpdateNode(ctx, uuo.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{user.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } diff --git a/examples/edgeindex/ent/city_create.go b/examples/edgeindex/ent/city_create.go index 03efd7c58..d850c4204 100644 --- a/examples/edgeindex/ent/city_create.go +++ b/examples/edgeindex/ent/city_create.go @@ -108,8 +108,8 @@ func (cc *CityCreate) check() error { func (cc *CityCreate) sqlSave(ctx context.Context) (*City, error) { _node, _spec := cc.createSpec() if err := sqlgraph.CreateNode(ctx, cc.driver, _spec); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } @@ -189,8 +189,8 @@ func (ccb *CityCreateBulk) Save(ctx context.Context) ([]*City, error) { } else { // Invoke the actual operation on the latest mutation in the chain. if err = sqlgraph.BatchCreate(ctx, ccb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } } } diff --git a/examples/edgeindex/ent/city_update.go b/examples/edgeindex/ent/city_update.go index e0e00b153..dd0576b40 100644 --- a/examples/edgeindex/ent/city_update.go +++ b/examples/edgeindex/ent/city_update.go @@ -211,8 +211,8 @@ func (cu *CityUpdate) sqlSave(ctx context.Context) (n int, err error) { if n, err = sqlgraph.UpdateNodes(ctx, cu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{city.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return 0, err } @@ -434,8 +434,8 @@ func (cuo *CityUpdateOne) sqlSave(ctx context.Context) (_node *City, err error) if err = sqlgraph.UpdateNode(ctx, cuo.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{city.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } diff --git a/examples/edgeindex/ent/ent.go b/examples/edgeindex/ent/ent.go index 2286f7336..e4cbc5cfe 100644 --- a/examples/edgeindex/ent/ent.go +++ b/examples/edgeindex/ent/ent.go @@ -12,7 +12,6 @@ import ( "entgo.io/ent" "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/examples/edgeindex/ent/city" "entgo.io/ent/examples/edgeindex/ent/street" ) @@ -264,10 +263,3 @@ func IsConstraintError(err error) bool { var e *ConstraintError return errors.As(err, &e) } - -func isSQLConstraintError(err error) (*ConstraintError, bool) { - if sqlgraph.IsConstraintError(err) { - return &ConstraintError{err.Error(), err}, true - } - return nil, false -} diff --git a/examples/edgeindex/ent/street_create.go b/examples/edgeindex/ent/street_create.go index 09818392c..3c3266218 100644 --- a/examples/edgeindex/ent/street_create.go +++ b/examples/edgeindex/ent/street_create.go @@ -112,8 +112,8 @@ func (sc *StreetCreate) check() error { func (sc *StreetCreate) sqlSave(ctx context.Context) (*Street, error) { _node, _spec := sc.createSpec() if err := sqlgraph.CreateNode(ctx, sc.driver, _spec); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } @@ -194,8 +194,8 @@ func (scb *StreetCreateBulk) Save(ctx context.Context) ([]*Street, error) { } else { // Invoke the actual operation on the latest mutation in the chain. if err = sqlgraph.BatchCreate(ctx, scb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } } } diff --git a/examples/edgeindex/ent/street_update.go b/examples/edgeindex/ent/street_update.go index 116ce8462..c0b179f49 100644 --- a/examples/edgeindex/ent/street_update.go +++ b/examples/edgeindex/ent/street_update.go @@ -181,8 +181,8 @@ func (su *StreetUpdate) sqlSave(ctx context.Context) (n int, err error) { if n, err = sqlgraph.UpdateNodes(ctx, su.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{street.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return 0, err } @@ -374,8 +374,8 @@ func (suo *StreetUpdateOne) sqlSave(ctx context.Context) (_node *Street, err err if err = sqlgraph.UpdateNode(ctx, suo.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{street.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } diff --git a/examples/entcpkg/ent/ent.go b/examples/entcpkg/ent/ent.go index 3625b0536..cc3f8fe13 100644 --- a/examples/entcpkg/ent/ent.go +++ b/examples/entcpkg/ent/ent.go @@ -12,7 +12,6 @@ import ( "entgo.io/ent" "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/examples/entcpkg/ent/user" ) @@ -262,10 +261,3 @@ func IsConstraintError(err error) bool { var e *ConstraintError return errors.As(err, &e) } - -func isSQLConstraintError(err error) (*ConstraintError, bool) { - if sqlgraph.IsConstraintError(err) { - return &ConstraintError{err.Error(), err}, true - } - return nil, false -} diff --git a/examples/entcpkg/ent/user_create.go b/examples/entcpkg/ent/user_create.go index e6ba7fca4..6b38925fe 100644 --- a/examples/entcpkg/ent/user_create.go +++ b/examples/entcpkg/ent/user_create.go @@ -110,8 +110,8 @@ func (uc *UserCreate) check() error { func (uc *UserCreate) sqlSave(ctx context.Context) (*User, error) { _node, _spec := uc.createSpec() if err := sqlgraph.CreateNode(ctx, uc.driver, _spec); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } @@ -180,8 +180,8 @@ func (ucb *UserCreateBulk) Save(ctx context.Context) ([]*User, error) { } else { // Invoke the actual operation on the latest mutation in the chain. if err = sqlgraph.BatchCreate(ctx, ucb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } } } diff --git a/examples/entcpkg/ent/user_update.go b/examples/entcpkg/ent/user_update.go index b17e8470e..bb31a0f2f 100644 --- a/examples/entcpkg/ent/user_update.go +++ b/examples/entcpkg/ent/user_update.go @@ -187,8 +187,8 @@ func (uu *UserUpdate) sqlSave(ctx context.Context) (n int, err error) { if n, err = sqlgraph.UpdateNodes(ctx, uu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{user.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return 0, err } @@ -387,8 +387,8 @@ func (uuo *UserUpdateOne) sqlSave(ctx context.Context) (_node *User, err error) if err = sqlgraph.UpdateNode(ctx, uuo.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{user.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } diff --git a/examples/fs/ent/ent.go b/examples/fs/ent/ent.go index 9ecf396a5..3d6e45be5 100644 --- a/examples/fs/ent/ent.go +++ b/examples/fs/ent/ent.go @@ -12,7 +12,6 @@ import ( "entgo.io/ent" "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/examples/fs/ent/file" ) @@ -262,10 +261,3 @@ func IsConstraintError(err error) bool { var e *ConstraintError return errors.As(err, &e) } - -func isSQLConstraintError(err error) (*ConstraintError, bool) { - if sqlgraph.IsConstraintError(err) { - return &ConstraintError{err.Error(), err}, true - } - return nil, false -} diff --git a/examples/fs/ent/file_create.go b/examples/fs/ent/file_create.go index fbe5bf49d..bb5139fc0 100644 --- a/examples/fs/ent/file_create.go +++ b/examples/fs/ent/file_create.go @@ -152,8 +152,8 @@ func (fc *FileCreate) check() error { func (fc *FileCreate) sqlSave(ctx context.Context) (*File, error) { _node, _spec := fc.createSpec() if err := sqlgraph.CreateNode(ctx, fc.driver, _spec); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } @@ -262,8 +262,8 @@ func (fcb *FileCreateBulk) Save(ctx context.Context) ([]*File, error) { } else { // Invoke the actual operation on the latest mutation in the chain. if err = sqlgraph.BatchCreate(ctx, fcb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } } } diff --git a/examples/fs/ent/file_update.go b/examples/fs/ent/file_update.go index 773c5fe31..842a0745c 100644 --- a/examples/fs/ent/file_update.go +++ b/examples/fs/ent/file_update.go @@ -297,8 +297,8 @@ func (fu *FileUpdate) sqlSave(ctx context.Context) (n int, err error) { if n, err = sqlgraph.UpdateNodes(ctx, fu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{file.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return 0, err } @@ -607,8 +607,8 @@ func (fuo *FileUpdateOne) sqlSave(ctx context.Context) (_node *File, err error) if err = sqlgraph.UpdateNode(ctx, fuo.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{file.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } diff --git a/examples/m2m2types/ent/ent.go b/examples/m2m2types/ent/ent.go index 8c9c1427a..66d5e60fd 100644 --- a/examples/m2m2types/ent/ent.go +++ b/examples/m2m2types/ent/ent.go @@ -12,7 +12,6 @@ import ( "entgo.io/ent" "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/examples/m2m2types/ent/group" "entgo.io/ent/examples/m2m2types/ent/user" ) @@ -264,10 +263,3 @@ func IsConstraintError(err error) bool { var e *ConstraintError return errors.As(err, &e) } - -func isSQLConstraintError(err error) (*ConstraintError, bool) { - if sqlgraph.IsConstraintError(err) { - return &ConstraintError{err.Error(), err}, true - } - return nil, false -} diff --git a/examples/m2m2types/ent/group_create.go b/examples/m2m2types/ent/group_create.go index 5f6c4cb1d..336b2c769 100644 --- a/examples/m2m2types/ent/group_create.go +++ b/examples/m2m2types/ent/group_create.go @@ -108,8 +108,8 @@ func (gc *GroupCreate) check() error { func (gc *GroupCreate) sqlSave(ctx context.Context) (*Group, error) { _node, _spec := gc.createSpec() if err := sqlgraph.CreateNode(ctx, gc.driver, _spec); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } @@ -189,8 +189,8 @@ func (gcb *GroupCreateBulk) Save(ctx context.Context) ([]*Group, error) { } else { // Invoke the actual operation on the latest mutation in the chain. if err = sqlgraph.BatchCreate(ctx, gcb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } } } diff --git a/examples/m2m2types/ent/group_update.go b/examples/m2m2types/ent/group_update.go index eedc57da5..2e8835e44 100644 --- a/examples/m2m2types/ent/group_update.go +++ b/examples/m2m2types/ent/group_update.go @@ -211,8 +211,8 @@ func (gu *GroupUpdate) sqlSave(ctx context.Context) (n int, err error) { if n, err = sqlgraph.UpdateNodes(ctx, gu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{group.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return 0, err } @@ -434,8 +434,8 @@ func (guo *GroupUpdateOne) sqlSave(ctx context.Context) (_node *Group, err error if err = sqlgraph.UpdateNode(ctx, guo.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{group.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } diff --git a/examples/m2m2types/ent/user_create.go b/examples/m2m2types/ent/user_create.go index 4066f4814..84218232a 100644 --- a/examples/m2m2types/ent/user_create.go +++ b/examples/m2m2types/ent/user_create.go @@ -117,8 +117,8 @@ func (uc *UserCreate) check() error { func (uc *UserCreate) sqlSave(ctx context.Context) (*User, error) { _node, _spec := uc.createSpec() if err := sqlgraph.CreateNode(ctx, uc.driver, _spec); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } @@ -206,8 +206,8 @@ func (ucb *UserCreateBulk) Save(ctx context.Context) ([]*User, error) { } else { // Invoke the actual operation on the latest mutation in the chain. if err = sqlgraph.BatchCreate(ctx, ucb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } } } diff --git a/examples/m2m2types/ent/user_update.go b/examples/m2m2types/ent/user_update.go index f58ab1959..73c6f57d0 100644 --- a/examples/m2m2types/ent/user_update.go +++ b/examples/m2m2types/ent/user_update.go @@ -238,8 +238,8 @@ func (uu *UserUpdate) sqlSave(ctx context.Context) (n int, err error) { if n, err = sqlgraph.UpdateNodes(ctx, uu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{user.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return 0, err } @@ -488,8 +488,8 @@ func (uuo *UserUpdateOne) sqlSave(ctx context.Context) (_node *User, err error) if err = sqlgraph.UpdateNode(ctx, uuo.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{user.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } diff --git a/examples/m2mbidi/ent/ent.go b/examples/m2mbidi/ent/ent.go index c0b45367d..dc4bf1819 100644 --- a/examples/m2mbidi/ent/ent.go +++ b/examples/m2mbidi/ent/ent.go @@ -12,7 +12,6 @@ import ( "entgo.io/ent" "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/examples/m2mbidi/ent/user" ) @@ -262,10 +261,3 @@ func IsConstraintError(err error) bool { var e *ConstraintError return errors.As(err, &e) } - -func isSQLConstraintError(err error) (*ConstraintError, bool) { - if sqlgraph.IsConstraintError(err) { - return &ConstraintError{err.Error(), err}, true - } - return nil, false -} diff --git a/examples/m2mbidi/ent/user_create.go b/examples/m2mbidi/ent/user_create.go index e6810029c..d08cd9434 100644 --- a/examples/m2mbidi/ent/user_create.go +++ b/examples/m2mbidi/ent/user_create.go @@ -116,8 +116,8 @@ func (uc *UserCreate) check() error { func (uc *UserCreate) sqlSave(ctx context.Context) (*User, error) { _node, _spec := uc.createSpec() if err := sqlgraph.CreateNode(ctx, uc.driver, _spec); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } @@ -205,8 +205,8 @@ func (ucb *UserCreateBulk) Save(ctx context.Context) ([]*User, error) { } else { // Invoke the actual operation on the latest mutation in the chain. if err = sqlgraph.BatchCreate(ctx, ucb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } } } diff --git a/examples/m2mbidi/ent/user_update.go b/examples/m2mbidi/ent/user_update.go index 0e40a7f92..67198f30a 100644 --- a/examples/m2mbidi/ent/user_update.go +++ b/examples/m2mbidi/ent/user_update.go @@ -237,8 +237,8 @@ func (uu *UserUpdate) sqlSave(ctx context.Context) (n int, err error) { if n, err = sqlgraph.UpdateNodes(ctx, uu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{user.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return 0, err } @@ -487,8 +487,8 @@ func (uuo *UserUpdateOne) sqlSave(ctx context.Context) (_node *User, err error) if err = sqlgraph.UpdateNode(ctx, uuo.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{user.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } diff --git a/examples/m2mrecur/ent/ent.go b/examples/m2mrecur/ent/ent.go index be5650d66..3224a00d7 100644 --- a/examples/m2mrecur/ent/ent.go +++ b/examples/m2mrecur/ent/ent.go @@ -12,7 +12,6 @@ import ( "entgo.io/ent" "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/examples/m2mrecur/ent/user" ) @@ -262,10 +261,3 @@ func IsConstraintError(err error) bool { var e *ConstraintError return errors.As(err, &e) } - -func isSQLConstraintError(err error) (*ConstraintError, bool) { - if sqlgraph.IsConstraintError(err) { - return &ConstraintError{err.Error(), err}, true - } - return nil, false -} diff --git a/examples/m2mrecur/ent/user_create.go b/examples/m2mrecur/ent/user_create.go index e3f639896..4ef8f4d19 100644 --- a/examples/m2mrecur/ent/user_create.go +++ b/examples/m2mrecur/ent/user_create.go @@ -131,8 +131,8 @@ func (uc *UserCreate) check() error { func (uc *UserCreate) sqlSave(ctx context.Context) (*User, error) { _node, _spec := uc.createSpec() if err := sqlgraph.CreateNode(ctx, uc.driver, _spec); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } @@ -239,8 +239,8 @@ func (ucb *UserCreateBulk) Save(ctx context.Context) ([]*User, error) { } else { // Invoke the actual operation on the latest mutation in the chain. if err = sqlgraph.BatchCreate(ctx, ucb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } } } diff --git a/examples/m2mrecur/ent/user_update.go b/examples/m2mrecur/ent/user_update.go index 6e1f85986..4ea5436ed 100644 --- a/examples/m2mrecur/ent/user_update.go +++ b/examples/m2mrecur/ent/user_update.go @@ -327,8 +327,8 @@ func (uu *UserUpdate) sqlSave(ctx context.Context) (n int, err error) { if n, err = sqlgraph.UpdateNodes(ctx, uu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{user.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return 0, err } @@ -667,8 +667,8 @@ func (uuo *UserUpdateOne) sqlSave(ctx context.Context) (_node *User, err error) if err = sqlgraph.UpdateNode(ctx, uuo.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{user.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } diff --git a/examples/o2m2types/ent/ent.go b/examples/o2m2types/ent/ent.go index 2c0de228e..427f77180 100644 --- a/examples/o2m2types/ent/ent.go +++ b/examples/o2m2types/ent/ent.go @@ -12,7 +12,6 @@ import ( "entgo.io/ent" "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/examples/o2m2types/ent/pet" "entgo.io/ent/examples/o2m2types/ent/user" ) @@ -264,10 +263,3 @@ func IsConstraintError(err error) bool { var e *ConstraintError return errors.As(err, &e) } - -func isSQLConstraintError(err error) (*ConstraintError, bool) { - if sqlgraph.IsConstraintError(err) { - return &ConstraintError{err.Error(), err}, true - } - return nil, false -} diff --git a/examples/o2m2types/ent/pet_create.go b/examples/o2m2types/ent/pet_create.go index 643a84e2d..1ddfc748c 100644 --- a/examples/o2m2types/ent/pet_create.go +++ b/examples/o2m2types/ent/pet_create.go @@ -112,8 +112,8 @@ func (pc *PetCreate) check() error { func (pc *PetCreate) sqlSave(ctx context.Context) (*Pet, error) { _node, _spec := pc.createSpec() if err := sqlgraph.CreateNode(ctx, pc.driver, _spec); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } @@ -194,8 +194,8 @@ func (pcb *PetCreateBulk) Save(ctx context.Context) ([]*Pet, error) { } else { // Invoke the actual operation on the latest mutation in the chain. if err = sqlgraph.BatchCreate(ctx, pcb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } } } diff --git a/examples/o2m2types/ent/pet_update.go b/examples/o2m2types/ent/pet_update.go index 6f7a80f11..d3aca90d8 100644 --- a/examples/o2m2types/ent/pet_update.go +++ b/examples/o2m2types/ent/pet_update.go @@ -181,8 +181,8 @@ func (pu *PetUpdate) sqlSave(ctx context.Context) (n int, err error) { if n, err = sqlgraph.UpdateNodes(ctx, pu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{pet.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return 0, err } @@ -374,8 +374,8 @@ func (puo *PetUpdateOne) sqlSave(ctx context.Context) (_node *Pet, err error) { if err = sqlgraph.UpdateNode(ctx, puo.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{pet.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } diff --git a/examples/o2m2types/ent/user_create.go b/examples/o2m2types/ent/user_create.go index 832ac7ac1..e95085ada 100644 --- a/examples/o2m2types/ent/user_create.go +++ b/examples/o2m2types/ent/user_create.go @@ -117,8 +117,8 @@ func (uc *UserCreate) check() error { func (uc *UserCreate) sqlSave(ctx context.Context) (*User, error) { _node, _spec := uc.createSpec() if err := sqlgraph.CreateNode(ctx, uc.driver, _spec); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } @@ -206,8 +206,8 @@ func (ucb *UserCreateBulk) Save(ctx context.Context) ([]*User, error) { } else { // Invoke the actual operation on the latest mutation in the chain. if err = sqlgraph.BatchCreate(ctx, ucb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } } } diff --git a/examples/o2m2types/ent/user_update.go b/examples/o2m2types/ent/user_update.go index 52855ce06..1520fe3f6 100644 --- a/examples/o2m2types/ent/user_update.go +++ b/examples/o2m2types/ent/user_update.go @@ -238,8 +238,8 @@ func (uu *UserUpdate) sqlSave(ctx context.Context) (n int, err error) { if n, err = sqlgraph.UpdateNodes(ctx, uu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{user.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return 0, err } @@ -488,8 +488,8 @@ func (uuo *UserUpdateOne) sqlSave(ctx context.Context) (_node *User, err error) if err = sqlgraph.UpdateNode(ctx, uuo.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{user.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } diff --git a/examples/o2mrecur/ent/ent.go b/examples/o2mrecur/ent/ent.go index 430ed7d08..6c51fe312 100644 --- a/examples/o2mrecur/ent/ent.go +++ b/examples/o2mrecur/ent/ent.go @@ -12,7 +12,6 @@ import ( "entgo.io/ent" "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/examples/o2mrecur/ent/node" ) @@ -262,10 +261,3 @@ func IsConstraintError(err error) bool { var e *ConstraintError return errors.As(err, &e) } - -func isSQLConstraintError(err error) (*ConstraintError, bool) { - if sqlgraph.IsConstraintError(err) { - return &ConstraintError{err.Error(), err}, true - } - return nil, false -} diff --git a/examples/o2mrecur/ent/node_create.go b/examples/o2mrecur/ent/node_create.go index 0cab5d585..167c1d384 100644 --- a/examples/o2mrecur/ent/node_create.go +++ b/examples/o2mrecur/ent/node_create.go @@ -126,8 +126,8 @@ func (nc *NodeCreate) check() error { func (nc *NodeCreate) sqlSave(ctx context.Context) (*Node, error) { _node, _spec := nc.createSpec() if err := sqlgraph.CreateNode(ctx, nc.driver, _spec); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } @@ -227,8 +227,8 @@ func (ncb *NodeCreateBulk) Save(ctx context.Context) ([]*Node, error) { } else { // Invoke the actual operation on the latest mutation in the chain. if err = sqlgraph.BatchCreate(ctx, ncb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } } } diff --git a/examples/o2mrecur/ent/node_update.go b/examples/o2mrecur/ent/node_update.go index af8b4791f..e9cb851c9 100644 --- a/examples/o2mrecur/ent/node_update.go +++ b/examples/o2mrecur/ent/node_update.go @@ -284,8 +284,8 @@ func (nu *NodeUpdate) sqlSave(ctx context.Context) (n int, err error) { if n, err = sqlgraph.UpdateNodes(ctx, nu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{node.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return 0, err } @@ -581,8 +581,8 @@ func (nuo *NodeUpdateOne) sqlSave(ctx context.Context) (_node *Node, err error) if err = sqlgraph.UpdateNode(ctx, nuo.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{node.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } diff --git a/examples/o2o2types/ent/card_create.go b/examples/o2o2types/ent/card_create.go index 68768c0e4..bd09377dc 100644 --- a/examples/o2o2types/ent/card_create.go +++ b/examples/o2o2types/ent/card_create.go @@ -117,8 +117,8 @@ func (cc *CardCreate) check() error { func (cc *CardCreate) sqlSave(ctx context.Context) (*Card, error) { _node, _spec := cc.createSpec() if err := sqlgraph.CreateNode(ctx, cc.driver, _spec); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } @@ -207,8 +207,8 @@ func (ccb *CardCreateBulk) Save(ctx context.Context) ([]*Card, error) { } else { // Invoke the actual operation on the latest mutation in the chain. if err = sqlgraph.BatchCreate(ctx, ccb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } } } diff --git a/examples/o2o2types/ent/card_update.go b/examples/o2o2types/ent/card_update.go index 7bb1f6f8a..b7da9ceac 100644 --- a/examples/o2o2types/ent/card_update.go +++ b/examples/o2o2types/ent/card_update.go @@ -202,8 +202,8 @@ func (cu *CardUpdate) sqlSave(ctx context.Context) (n int, err error) { if n, err = sqlgraph.UpdateNodes(ctx, cu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{card.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return 0, err } @@ -414,8 +414,8 @@ func (cuo *CardUpdateOne) sqlSave(ctx context.Context) (_node *Card, err error) if err = sqlgraph.UpdateNode(ctx, cuo.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{card.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } diff --git a/examples/o2o2types/ent/ent.go b/examples/o2o2types/ent/ent.go index edf6b9c4c..0b37ce505 100644 --- a/examples/o2o2types/ent/ent.go +++ b/examples/o2o2types/ent/ent.go @@ -12,7 +12,6 @@ import ( "entgo.io/ent" "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/examples/o2o2types/ent/card" "entgo.io/ent/examples/o2o2types/ent/user" ) @@ -264,10 +263,3 @@ func IsConstraintError(err error) bool { var e *ConstraintError return errors.As(err, &e) } - -func isSQLConstraintError(err error) (*ConstraintError, bool) { - if sqlgraph.IsConstraintError(err) { - return &ConstraintError{err.Error(), err}, true - } - return nil, false -} diff --git a/examples/o2o2types/ent/user_create.go b/examples/o2o2types/ent/user_create.go index fa9f1cc41..607a0326e 100644 --- a/examples/o2o2types/ent/user_create.go +++ b/examples/o2o2types/ent/user_create.go @@ -121,8 +121,8 @@ func (uc *UserCreate) check() error { func (uc *UserCreate) sqlSave(ctx context.Context) (*User, error) { _node, _spec := uc.createSpec() if err := sqlgraph.CreateNode(ctx, uc.driver, _spec); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } @@ -210,8 +210,8 @@ func (ucb *UserCreateBulk) Save(ctx context.Context) ([]*User, error) { } else { // Invoke the actual operation on the latest mutation in the chain. if err = sqlgraph.BatchCreate(ctx, ucb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } } } diff --git a/examples/o2o2types/ent/user_update.go b/examples/o2o2types/ent/user_update.go index fd6f2b16e..461ed9714 100644 --- a/examples/o2o2types/ent/user_update.go +++ b/examples/o2o2types/ent/user_update.go @@ -208,8 +208,8 @@ func (uu *UserUpdate) sqlSave(ctx context.Context) (n int, err error) { if n, err = sqlgraph.UpdateNodes(ctx, uu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{user.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return 0, err } @@ -428,8 +428,8 @@ func (uuo *UserUpdateOne) sqlSave(ctx context.Context) (_node *User, err error) if err = sqlgraph.UpdateNode(ctx, uuo.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{user.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } diff --git a/examples/o2obidi/ent/ent.go b/examples/o2obidi/ent/ent.go index 31ebf67e8..56bae37a1 100644 --- a/examples/o2obidi/ent/ent.go +++ b/examples/o2obidi/ent/ent.go @@ -12,7 +12,6 @@ import ( "entgo.io/ent" "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/examples/o2obidi/ent/user" ) @@ -262,10 +261,3 @@ func IsConstraintError(err error) bool { var e *ConstraintError return errors.As(err, &e) } - -func isSQLConstraintError(err error) (*ConstraintError, bool) { - if sqlgraph.IsConstraintError(err) { - return &ConstraintError{err.Error(), err}, true - } - return nil, false -} diff --git a/examples/o2obidi/ent/user_create.go b/examples/o2obidi/ent/user_create.go index 40fa2be27..1e40a317f 100644 --- a/examples/o2obidi/ent/user_create.go +++ b/examples/o2obidi/ent/user_create.go @@ -120,8 +120,8 @@ func (uc *UserCreate) check() error { func (uc *UserCreate) sqlSave(ctx context.Context) (*User, error) { _node, _spec := uc.createSpec() if err := sqlgraph.CreateNode(ctx, uc.driver, _spec); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } @@ -210,8 +210,8 @@ func (ucb *UserCreateBulk) Save(ctx context.Context) ([]*User, error) { } else { // Invoke the actual operation on the latest mutation in the chain. if err = sqlgraph.BatchCreate(ctx, ucb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } } } diff --git a/examples/o2obidi/ent/user_update.go b/examples/o2obidi/ent/user_update.go index 7c0f3fb21..405584fe2 100644 --- a/examples/o2obidi/ent/user_update.go +++ b/examples/o2obidi/ent/user_update.go @@ -207,8 +207,8 @@ func (uu *UserUpdate) sqlSave(ctx context.Context) (n int, err error) { if n, err = sqlgraph.UpdateNodes(ctx, uu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{user.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return 0, err } @@ -427,8 +427,8 @@ func (uuo *UserUpdateOne) sqlSave(ctx context.Context) (_node *User, err error) if err = sqlgraph.UpdateNode(ctx, uuo.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{user.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } diff --git a/examples/o2orecur/ent/ent.go b/examples/o2orecur/ent/ent.go index c01134de8..107781325 100644 --- a/examples/o2orecur/ent/ent.go +++ b/examples/o2orecur/ent/ent.go @@ -12,7 +12,6 @@ import ( "entgo.io/ent" "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/examples/o2orecur/ent/node" ) @@ -262,10 +261,3 @@ func IsConstraintError(err error) bool { var e *ConstraintError return errors.As(err, &e) } - -func isSQLConstraintError(err error) (*ConstraintError, bool) { - if sqlgraph.IsConstraintError(err) { - return &ConstraintError{err.Error(), err}, true - } - return nil, false -} diff --git a/examples/o2orecur/ent/node_create.go b/examples/o2orecur/ent/node_create.go index 06e5884ce..fd570008e 100644 --- a/examples/o2orecur/ent/node_create.go +++ b/examples/o2orecur/ent/node_create.go @@ -130,8 +130,8 @@ func (nc *NodeCreate) check() error { func (nc *NodeCreate) sqlSave(ctx context.Context) (*Node, error) { _node, _spec := nc.createSpec() if err := sqlgraph.CreateNode(ctx, nc.driver, _spec); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } @@ -231,8 +231,8 @@ func (ncb *NodeCreateBulk) Save(ctx context.Context) ([]*Node, error) { } else { // Invoke the actual operation on the latest mutation in the chain. if err = sqlgraph.BatchCreate(ctx, ncb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } } } diff --git a/examples/o2orecur/ent/node_update.go b/examples/o2orecur/ent/node_update.go index c91e40ffd..74c2c65bc 100644 --- a/examples/o2orecur/ent/node_update.go +++ b/examples/o2orecur/ent/node_update.go @@ -254,8 +254,8 @@ func (nu *NodeUpdate) sqlSave(ctx context.Context) (n int, err error) { if n, err = sqlgraph.UpdateNodes(ctx, nu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{node.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return 0, err } @@ -521,8 +521,8 @@ func (nuo *NodeUpdateOne) sqlSave(ctx context.Context) (_node *Node, err error) if err = sqlgraph.UpdateNode(ctx, nuo.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{node.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } diff --git a/examples/privacyadmin/ent/ent.go b/examples/privacyadmin/ent/ent.go index 3c4ea6318..8a213abee 100644 --- a/examples/privacyadmin/ent/ent.go +++ b/examples/privacyadmin/ent/ent.go @@ -12,7 +12,6 @@ import ( "entgo.io/ent" "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/examples/privacyadmin/ent/user" ) @@ -262,10 +261,3 @@ func IsConstraintError(err error) bool { var e *ConstraintError return errors.As(err, &e) } - -func isSQLConstraintError(err error) (*ConstraintError, bool) { - if sqlgraph.IsConstraintError(err) { - return &ConstraintError{err.Error(), err}, true - } - return nil, false -} diff --git a/examples/privacyadmin/ent/user_create.go b/examples/privacyadmin/ent/user_create.go index 786304933..e50ed7951 100644 --- a/examples/privacyadmin/ent/user_create.go +++ b/examples/privacyadmin/ent/user_create.go @@ -109,8 +109,8 @@ func (uc *UserCreate) check() error { func (uc *UserCreate) sqlSave(ctx context.Context) (*User, error) { _node, _spec := uc.createSpec() if err := sqlgraph.CreateNode(ctx, uc.driver, _spec); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } @@ -172,8 +172,8 @@ func (ucb *UserCreateBulk) Save(ctx context.Context) ([]*User, error) { } else { // Invoke the actual operation on the latest mutation in the chain. if err = sqlgraph.BatchCreate(ctx, ucb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } } } diff --git a/examples/privacyadmin/ent/user_update.go b/examples/privacyadmin/ent/user_update.go index fd47c77dc..ed7ffd3aa 100644 --- a/examples/privacyadmin/ent/user_update.go +++ b/examples/privacyadmin/ent/user_update.go @@ -128,8 +128,8 @@ func (uu *UserUpdate) sqlSave(ctx context.Context) (n int, err error) { if n, err = sqlgraph.UpdateNodes(ctx, uu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{user.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return 0, err } @@ -269,8 +269,8 @@ func (uuo *UserUpdateOne) sqlSave(ctx context.Context) (_node *User, err error) if err = sqlgraph.UpdateNode(ctx, uuo.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{user.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } diff --git a/examples/privacytenant/ent/ent.go b/examples/privacytenant/ent/ent.go index 39af5906a..f3d11e219 100644 --- a/examples/privacytenant/ent/ent.go +++ b/examples/privacytenant/ent/ent.go @@ -12,7 +12,6 @@ import ( "entgo.io/ent" "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/examples/privacytenant/ent/group" "entgo.io/ent/examples/privacytenant/ent/tenant" "entgo.io/ent/examples/privacytenant/ent/user" @@ -266,10 +265,3 @@ func IsConstraintError(err error) bool { var e *ConstraintError return errors.As(err, &e) } - -func isSQLConstraintError(err error) (*ConstraintError, bool) { - if sqlgraph.IsConstraintError(err) { - return &ConstraintError{err.Error(), err}, true - } - return nil, false -} diff --git a/examples/privacytenant/ent/group_create.go b/examples/privacytenant/ent/group_create.go index 2e0bfc3a5..a11e1b1fe 100644 --- a/examples/privacytenant/ent/group_create.go +++ b/examples/privacytenant/ent/group_create.go @@ -140,8 +140,8 @@ func (gc *GroupCreate) check() error { func (gc *GroupCreate) sqlSave(ctx context.Context) (*Group, error) { _node, _spec := gc.createSpec() if err := sqlgraph.CreateNode(ctx, gc.driver, _spec); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } @@ -242,8 +242,8 @@ func (gcb *GroupCreateBulk) Save(ctx context.Context) ([]*Group, error) { } else { // Invoke the actual operation on the latest mutation in the chain. if err = sqlgraph.BatchCreate(ctx, gcb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } } } diff --git a/examples/privacytenant/ent/group_update.go b/examples/privacytenant/ent/group_update.go index 3a7461a9e..94e901d75 100644 --- a/examples/privacytenant/ent/group_update.go +++ b/examples/privacytenant/ent/group_update.go @@ -287,8 +287,8 @@ func (gu *GroupUpdate) sqlSave(ctx context.Context) (n int, err error) { if n, err = sqlgraph.UpdateNodes(ctx, gu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{group.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return 0, err } @@ -584,8 +584,8 @@ func (guo *GroupUpdateOne) sqlSave(ctx context.Context) (_node *Group, err error if err = sqlgraph.UpdateNode(ctx, guo.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{group.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } diff --git a/examples/privacytenant/ent/tenant_create.go b/examples/privacytenant/ent/tenant_create.go index 3d40b5ee3..4708aa8e2 100644 --- a/examples/privacytenant/ent/tenant_create.go +++ b/examples/privacytenant/ent/tenant_create.go @@ -97,8 +97,8 @@ func (tc *TenantCreate) check() error { func (tc *TenantCreate) sqlSave(ctx context.Context) (*Tenant, error) { _node, _spec := tc.createSpec() if err := sqlgraph.CreateNode(ctx, tc.driver, _spec); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } @@ -159,8 +159,8 @@ func (tcb *TenantCreateBulk) Save(ctx context.Context) ([]*Tenant, error) { } else { // Invoke the actual operation on the latest mutation in the chain. if err = sqlgraph.BatchCreate(ctx, tcb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } } } diff --git a/examples/privacytenant/ent/tenant_update.go b/examples/privacytenant/ent/tenant_update.go index ce594f61c..0581e5d24 100644 --- a/examples/privacytenant/ent/tenant_update.go +++ b/examples/privacytenant/ent/tenant_update.go @@ -136,8 +136,8 @@ func (tu *TenantUpdate) sqlSave(ctx context.Context) (n int, err error) { if n, err = sqlgraph.UpdateNodes(ctx, tu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{tenant.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return 0, err } @@ -285,8 +285,8 @@ func (tuo *TenantUpdateOne) sqlSave(ctx context.Context) (_node *Tenant, err err if err = sqlgraph.UpdateNode(ctx, tuo.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{tenant.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } diff --git a/examples/privacytenant/ent/user_create.go b/examples/privacytenant/ent/user_create.go index 968cb5d76..82be08515 100644 --- a/examples/privacytenant/ent/user_create.go +++ b/examples/privacytenant/ent/user_create.go @@ -146,8 +146,8 @@ func (uc *UserCreate) check() error { func (uc *UserCreate) sqlSave(ctx context.Context) (*User, error) { _node, _spec := uc.createSpec() if err := sqlgraph.CreateNode(ctx, uc.driver, _spec); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } @@ -256,8 +256,8 @@ func (ucb *UserCreateBulk) Save(ctx context.Context) ([]*User, error) { } else { // Invoke the actual operation on the latest mutation in the chain. if err = sqlgraph.BatchCreate(ctx, ucb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } } } diff --git a/examples/privacytenant/ent/user_update.go b/examples/privacytenant/ent/user_update.go index 2c6716453..aea604c4b 100644 --- a/examples/privacytenant/ent/user_update.go +++ b/examples/privacytenant/ent/user_update.go @@ -312,8 +312,8 @@ func (uu *UserUpdate) sqlSave(ctx context.Context) (n int, err error) { if n, err = sqlgraph.UpdateNodes(ctx, uu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{user.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return 0, err } @@ -634,8 +634,8 @@ func (uuo *UserUpdateOne) sqlSave(ctx context.Context) (_node *User, err error) if err = sqlgraph.UpdateNode(ctx, uuo.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{user.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } diff --git a/examples/start/ent/car_create.go b/examples/start/ent/car_create.go index 1599167a4..9bc6562bc 100644 --- a/examples/start/ent/car_create.go +++ b/examples/start/ent/car_create.go @@ -122,8 +122,8 @@ func (cc *CarCreate) check() error { func (cc *CarCreate) sqlSave(ctx context.Context) (*Car, error) { _node, _spec := cc.createSpec() if err := sqlgraph.CreateNode(ctx, cc.driver, _spec); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } @@ -212,8 +212,8 @@ func (ccb *CarCreateBulk) Save(ctx context.Context) ([]*Car, error) { } else { // Invoke the actual operation on the latest mutation in the chain. if err = sqlgraph.BatchCreate(ctx, ccb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } } } diff --git a/examples/start/ent/car_update.go b/examples/start/ent/car_update.go index 7f3ff1c64..8dc5779ed 100644 --- a/examples/start/ent/car_update.go +++ b/examples/start/ent/car_update.go @@ -195,8 +195,8 @@ func (cu *CarUpdate) sqlSave(ctx context.Context) (n int, err error) { if n, err = sqlgraph.UpdateNodes(ctx, cu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{car.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return 0, err } @@ -401,8 +401,8 @@ func (cuo *CarUpdateOne) sqlSave(ctx context.Context) (_node *Car, err error) { if err = sqlgraph.UpdateNode(ctx, cuo.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{car.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } diff --git a/examples/start/ent/ent.go b/examples/start/ent/ent.go index 66405d17b..657210bc2 100644 --- a/examples/start/ent/ent.go +++ b/examples/start/ent/ent.go @@ -12,7 +12,6 @@ import ( "entgo.io/ent" "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/examples/start/ent/car" "entgo.io/ent/examples/start/ent/group" "entgo.io/ent/examples/start/ent/user" @@ -266,10 +265,3 @@ func IsConstraintError(err error) bool { var e *ConstraintError return errors.As(err, &e) } - -func isSQLConstraintError(err error) (*ConstraintError, bool) { - if sqlgraph.IsConstraintError(err) { - return &ConstraintError{err.Error(), err}, true - } - return nil, false -} diff --git a/examples/start/ent/group_create.go b/examples/start/ent/group_create.go index ad66caa42..0eba5fb71 100644 --- a/examples/start/ent/group_create.go +++ b/examples/start/ent/group_create.go @@ -113,8 +113,8 @@ func (gc *GroupCreate) check() error { func (gc *GroupCreate) sqlSave(ctx context.Context) (*Group, error) { _node, _spec := gc.createSpec() if err := sqlgraph.CreateNode(ctx, gc.driver, _spec); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } @@ -194,8 +194,8 @@ func (gcb *GroupCreateBulk) Save(ctx context.Context) ([]*Group, error) { } else { // Invoke the actual operation on the latest mutation in the chain. if err = sqlgraph.BatchCreate(ctx, gcb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } } } diff --git a/examples/start/ent/group_update.go b/examples/start/ent/group_update.go index fb30ed3f8..70e12f92f 100644 --- a/examples/start/ent/group_update.go +++ b/examples/start/ent/group_update.go @@ -227,8 +227,8 @@ func (gu *GroupUpdate) sqlSave(ctx context.Context) (n int, err error) { if n, err = sqlgraph.UpdateNodes(ctx, gu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{group.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return 0, err } @@ -466,8 +466,8 @@ func (guo *GroupUpdateOne) sqlSave(ctx context.Context) (_node *Group, err error if err = sqlgraph.UpdateNode(ctx, guo.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{group.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } diff --git a/examples/start/ent/user_create.go b/examples/start/ent/user_create.go index 27fff6644..eadb8a171 100644 --- a/examples/start/ent/user_create.go +++ b/examples/start/ent/user_create.go @@ -155,8 +155,8 @@ func (uc *UserCreate) check() error { func (uc *UserCreate) sqlSave(ctx context.Context) (*User, error) { _node, _spec := uc.createSpec() if err := sqlgraph.CreateNode(ctx, uc.driver, _spec); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } @@ -264,8 +264,8 @@ func (ucb *UserCreateBulk) Save(ctx context.Context) ([]*User, error) { } else { // Invoke the actual operation on the latest mutation in the chain. if err = sqlgraph.BatchCreate(ctx, ucb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } } } diff --git a/examples/start/ent/user_update.go b/examples/start/ent/user_update.go index 505aff714..dd238af8d 100644 --- a/examples/start/ent/user_update.go +++ b/examples/start/ent/user_update.go @@ -353,8 +353,8 @@ func (uu *UserUpdate) sqlSave(ctx context.Context) (n int, err error) { if n, err = sqlgraph.UpdateNodes(ctx, uu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{user.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return 0, err } @@ -717,8 +717,8 @@ func (uuo *UserUpdateOne) sqlSave(ctx context.Context) (_node *User, err error) if err = sqlgraph.UpdateNode(ctx, uuo.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{user.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } diff --git a/examples/traversal/ent/ent.go b/examples/traversal/ent/ent.go index ae4b6da22..e8f3516c7 100644 --- a/examples/traversal/ent/ent.go +++ b/examples/traversal/ent/ent.go @@ -12,7 +12,6 @@ import ( "entgo.io/ent" "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/examples/traversal/ent/group" "entgo.io/ent/examples/traversal/ent/pet" "entgo.io/ent/examples/traversal/ent/user" @@ -266,10 +265,3 @@ func IsConstraintError(err error) bool { var e *ConstraintError return errors.As(err, &e) } - -func isSQLConstraintError(err error) (*ConstraintError, bool) { - if sqlgraph.IsConstraintError(err) { - return &ConstraintError{err.Error(), err}, true - } - return nil, false -} diff --git a/examples/traversal/ent/group_create.go b/examples/traversal/ent/group_create.go index f34101b81..a175d694a 100644 --- a/examples/traversal/ent/group_create.go +++ b/examples/traversal/ent/group_create.go @@ -127,8 +127,8 @@ func (gc *GroupCreate) check() error { func (gc *GroupCreate) sqlSave(ctx context.Context) (*Group, error) { _node, _spec := gc.createSpec() if err := sqlgraph.CreateNode(ctx, gc.driver, _spec); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } @@ -228,8 +228,8 @@ func (gcb *GroupCreateBulk) Save(ctx context.Context) ([]*Group, error) { } else { // Invoke the actual operation on the latest mutation in the chain. if err = sqlgraph.BatchCreate(ctx, gcb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } } } diff --git a/examples/traversal/ent/group_update.go b/examples/traversal/ent/group_update.go index 28f4d55ef..bafc6e516 100644 --- a/examples/traversal/ent/group_update.go +++ b/examples/traversal/ent/group_update.go @@ -271,8 +271,8 @@ func (gu *GroupUpdate) sqlSave(ctx context.Context) (n int, err error) { if n, err = sqlgraph.UpdateNodes(ctx, gu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{group.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return 0, err } @@ -554,8 +554,8 @@ func (guo *GroupUpdateOne) sqlSave(ctx context.Context) (_node *Group, err error if err = sqlgraph.UpdateNode(ctx, guo.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{group.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } diff --git a/examples/traversal/ent/pet_create.go b/examples/traversal/ent/pet_create.go index 275cb03a1..c41547372 100644 --- a/examples/traversal/ent/pet_create.go +++ b/examples/traversal/ent/pet_create.go @@ -127,8 +127,8 @@ func (pc *PetCreate) check() error { func (pc *PetCreate) sqlSave(ctx context.Context) (*Pet, error) { _node, _spec := pc.createSpec() if err := sqlgraph.CreateNode(ctx, pc.driver, _spec); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } @@ -228,8 +228,8 @@ func (pcb *PetCreateBulk) Save(ctx context.Context) ([]*Pet, error) { } else { // Invoke the actual operation on the latest mutation in the chain. if err = sqlgraph.BatchCreate(ctx, pcb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } } } diff --git a/examples/traversal/ent/pet_update.go b/examples/traversal/ent/pet_update.go index 92a879884..ad6d49460 100644 --- a/examples/traversal/ent/pet_update.go +++ b/examples/traversal/ent/pet_update.go @@ -271,8 +271,8 @@ func (pu *PetUpdate) sqlSave(ctx context.Context) (n int, err error) { if n, err = sqlgraph.UpdateNodes(ctx, pu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{pet.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return 0, err } @@ -554,8 +554,8 @@ func (puo *PetUpdateOne) sqlSave(ctx context.Context) (_node *Pet, err error) { if err = sqlgraph.UpdateNode(ctx, puo.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{pet.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } diff --git a/examples/traversal/ent/user_create.go b/examples/traversal/ent/user_create.go index adf4fe2a8..7c618b146 100644 --- a/examples/traversal/ent/user_create.go +++ b/examples/traversal/ent/user_create.go @@ -163,8 +163,8 @@ func (uc *UserCreate) check() error { func (uc *UserCreate) sqlSave(ctx context.Context) (*User, error) { _node, _spec := uc.createSpec() if err := sqlgraph.CreateNode(ctx, uc.driver, _spec); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err } @@ -309,8 +309,8 @@ func (ucb *UserCreateBulk) Save(ctx context.Context) ([]*User, error) { } else { // Invoke the actual operation on the latest mutation in the chain. if err = sqlgraph.BatchCreate(ctx, ucb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil { - if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } } } diff --git a/examples/traversal/ent/user_update.go b/examples/traversal/ent/user_update.go index 64f8293ac..f79c16a52 100644 --- a/examples/traversal/ent/user_update.go +++ b/examples/traversal/ent/user_update.go @@ -509,8 +509,8 @@ func (uu *UserUpdate) sqlSave(ctx context.Context) (n int, err error) { if n, err = sqlgraph.UpdateNodes(ctx, uu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{user.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return 0, err } @@ -1029,8 +1029,8 @@ func (uuo *UserUpdateOne) sqlSave(ctx context.Context) (_node *User, err error) if err = sqlgraph.UpdateNode(ctx, uuo.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{user.Label} - } else if cerr, ok := isSQLConstraintError(err); ok { - err = cerr + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{err.Error(), err} } return nil, err }