diff --git a/entc/gen/internal/bindata.go b/entc/gen/internal/bindata.go index 9752c3786..d28bb3eaf 100644 --- a/entc/gen/internal/bindata.go +++ b/entc/gen/internal/bindata.go @@ -16,6 +16,7 @@ // template/dialect/gremlin/errors.tmpl // template/dialect/gremlin/group.tmpl // template/dialect/gremlin/meta.tmpl +// template/dialect/gremlin/open.tmpl // template/dialect/gremlin/predicate.tmpl // template/dialect/gremlin/query.tmpl // template/dialect/gremlin/select.tmpl @@ -27,6 +28,7 @@ // template/dialect/sql/errors.tmpl // template/dialect/sql/group.tmpl // template/dialect/sql/meta.tmpl +// template/dialect/sql/open.tmpl // template/dialect/sql/predicate.tmpl // template/dialect/sql/query.tmpl // template/dialect/sql/select.tmpl @@ -237,7 +239,7 @@ func templateBuilderUpdateTmpl() (*asset, error) { return a, nil } -var _templateClientTmpl = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xb4\x58\x5b\x6f\xe3\xba\x11\x7e\x96\x7e\xc5\x54\xf0\xb6\x52\xe0\x50\x7b\xf6\xad\x2e\xf2\x70\x10\xa7\x07\x06\x8a\xe4\xb4\x9b\xa2\xe7\xed\x40\xa6\x46\x32\x1b\x99\xd4\x92\x54\xe2\x40\xf5\x7f\x2f\x78\xd1\xcd\xb7\x78\x17\xed\x53\x22\x0e\x35\xf3\xcd\x37\x1f\x39\x63\xb5\x6d\x7a\x13\xde\x8b\xfa\x5d\xb2\x72\xa3\xe1\xcb\xe7\x9f\xfe\x7c\x5b\x4b\x54\xc8\x35\xfc\x35\xa3\xb8\x16\xe2\x05\x56\x9c\x12\xf8\xb9\xaa\xc0\x6e\x52\x60\xec\xf2\x15\x73\x12\x3e\x6f\x98\x02\x25\x1a\x49\x11\xa8\xc8\x11\x98\x82\x8a\x51\xe4\x0a\x73\x68\x78\x8e\x12\xf4\x06\xe1\xe7\x3a\xa3\x1b\x84\x2f\xe4\x73\x67\x85\x42\x34\x3c\x0f\x19\xb7\xf6\xbf\xad\xee\x1f\x1e\xbf\x3e\x40\xc1\x2a\x04\xbf\x26\x85\xd0\x90\x33\x89\x54\x0b\xf9\x0e\xa2\x00\x3d\x0a\xa6\x25\x22\x09\x6f\xd2\xfd\x3e\x0c\xdb\x16\x72\x2c\x18\x47\x88\x68\xc5\x90\xeb\x08\xfc\xf2\xac\x7e\x29\x61\x71\x07\xeb\x4c\x21\xcc\xc8\xbd\xe0\x05\x2b\xc9\xaf\x19\x7d\xc9\x4a\x34\x9b\xda\x16\x34\x6e\xeb\x2a\xd3\x08\xd1\x06\xb3\x1c\x65\x04\x33\xfb\x3a\xdb\xd6\x42\x6a\x88\xc3\x20\xaa\x44\x19\x85\x61\x10\x19\x8f\xc7\x4e\xd2\x2d\x2b\x65\xa6\x31\x0a\x83\xb6\x05\x99\xf1\x12\x61\xf6\xfb\x1c\x66\xdc\x84\x9e\x91\x47\x91\xa3\x32\x2e\x03\xe7\x81\x9f\x70\xe1\xd6\x87\x05\xeb\xeb\x16\x90\xe7\x16\x4b\x10\x95\x4c\x6f\x9a\x35\xa1\x62\x9b\x16\xbe\x2c\x8c\xd3\x66\x9d\x69\x21\x53\xe4\x3a\xcd\x59\x56\x21\xd5\x47\x20\x94\x16\xd2\xf8\xb4\x50\xbe\xfa\x87\x5b\x8b\x66\xba\xd1\xe7\x6b\xf6\xf9\x77\xc8\xca\x2e\x29\xbf\xdd\xa1\xf7\xdb\x2c\x44\xe3\xc1\x40\xb4\xf6\xd1\xff\x49\x18\xa6\x29\xdc\xdb\x5a\x18\x45\x98\x72\xba\xca\x80\xde\x64\x1a\x36\xa2\xca\x15\x64\x55\x05\x66\x69\xdd\xb0\x2a\x47\xa9\x48\xa8\xdf\x6b\xec\x5e\x53\x5a\x36\x54\x43\x1b\x06\xd4\xb2\x15\x06\x69\x0a\x5f\xe9\x06\xb7\xd9\x81\xcb\x42\x48\xa0\x12\x33\xcd\x78\x39\x07\x57\x0c\xc6\x4b\xc8\x78\x0e\xb9\x14\x75\x6d\x1e\x94\x7d\x93\x84\x81\x77\x71\xe3\x8b\x46\xdc\xf3\xc5\xd2\xb9\xf4\xd3\x14\x5c\x95\x1e\xb3\xad\x29\xd1\x09\x14\x8c\x6b\x94\x19\xb5\xd1\xdf\x98\xde\x58\xfb\xf4\xa5\x21\x59\xcb\xde\xc8\x72\x33\x79\x74\x2c\xf4\xac\xee\xf7\xe1\xde\x92\xfa\x88\x6f\x9e\x20\x9b\x32\x2a\xc8\x80\xe3\x5b\x87\xc2\x71\xd5\x48\xcc\x07\x00\x25\x7b\x45\x0e\xa2\xd6\x4c\x70\x45\xc2\xa2\xe1\x74\x70\x13\x8b\x5a\x2b\x20\x84\x3c\x59\x7b\x02\x37\xde\xbd\x21\xde\x90\xe0\x3c\xb6\x95\x28\x17\x50\x89\x92\xfc\x2a\x19\xd7\x15\xdf\x87\x01\x25\xde\xa7\xf5\x41\x08\x49\xc2\x40\xa2\x6e\x24\x87\x3f\x3a\x27\x6d\x18\xf8\xea\x2d\x80\xce\xc3\xc0\x93\xbf\x80\x8e\xfc\x47\x7c\x73\x4b\x31\x25\xb9\x64\xaf\x28\x93\xf9\x91\x30\x4f\xd4\x62\x4a\xdd\xc2\xa4\x73\x82\xbd\x98\x76\xde\x7a\x91\x76\x34\x3e\xef\xc0\x41\xed\xf8\xd3\x32\xe3\xca\x94\x4e\xf0\xac\xf2\x6c\x7a\xae\x62\xda\x91\x92\xc0\xf3\x2e\xa6\x7a\x67\x48\xd1\xb8\xd3\xe6\x20\x9b\xbf\x09\xc4\x37\xcf\xbb\x39\xa0\x94\x42\x26\x86\x3a\x56\xc0\xef\x73\x10\x2f\x96\x41\x9f\x1a\x89\x6f\xf4\x6e\xe9\xb2\xfc\x8b\xb1\x19\x7a\x3c\x61\x9c\x55\x73\x28\xb6\x9a\x3c\x18\x17\x45\x1c\x75\x97\x97\xc9\x8e\x66\x9c\x0b\x73\x22\x32\xa9\x21\x1b\x43\xb5\x45\x66\x7c\xba\x18\x25\x26\xcf\x40\x3b\x40\x06\x01\xc7\x37\x07\x7c\xde\x83\x49\x2c\x46\x63\xff\xc3\x9d\x89\x7e\x35\x18\x8b\xc2\x1e\xaf\x71\xcc\x05\x7c\x7a\x8d\x6c\x3c\x17\x9c\x16\xe5\x48\x3c\x2e\xe4\x02\x0c\x00\x2b\x24\x4a\x2a\x51\xce\x21\xc7\x75\x63\x9f\xec\x3f\xfb\x41\x3e\xcf\xbb\x89\x74\x8a\xf2\x7f\xaa\x8a\xa2\x3c\xd6\xc5\xdc\x64\xed\xc5\xb1\x34\x68\x0e\xf4\x61\x11\xde\x7a\x5d\xc0\x4a\xff\x49\x41\x63\x7a\x9c\x16\x50\xa2\x86\x57\x94\x6b\xa1\xd0\x64\x57\x1a\x72\x04\x07\x55\x23\x65\x05\xa3\x20\x6a\x34\x37\x92\x3d\x7c\x69\x1a\xa6\x69\xe0\xdd\xd8\x38\x71\x62\x56\x2d\x9a\x98\xf1\x1c\x77\x7d\x52\x9f\x93\x0e\xb8\xdb\xf1\xf7\x06\xe5\x7b\xb7\xfd\x5e\x34\x26\x15\xbd\x4b\x8c\xcf\x23\x9d\x7a\xd7\xe3\xd3\xcc\x8a\x8e\xe8\x71\xad\xe9\x85\x72\xf9\x96\xe2\x71\x76\xca\x99\xbb\xea\x25\x27\x4b\xa9\x65\x83\xfb\x8b\xd7\x80\xab\xe5\x85\x8b\xa0\x28\xff\x2f\x57\xc1\xa9\xa2\x87\x6e\x4a\xb8\x14\xc0\xf8\xf2\x77\xeb\xe2\x0e\x6a\x73\xf9\xf5\xce\xa3\xfb\x61\xda\xf0\xdd\xc1\x6f\x75\xdd\x21\x1b\xf7\x86\xe3\x56\xd0\xb5\x24\xdb\xf5\xa6\x2f\x1f\x35\x3f\x3f\xce\x48\xb4\x77\xf2\x8c\x93\x7f\x20\x45\x43\x12\xec\xf7\x6d\x0b\xe6\x28\x7f\x73\xe6\x88\x46\x6e\xcd\x3e\x79\xc8\x05\x44\x9f\xc8\x17\x15\xf5\xe1\xff\x03\x95\x78\xeb\xde\xee\xa6\x0c\xd7\x5e\xa6\x48\x86\x53\x70\x31\x97\x42\x8a\xed\xa8\xd9\x38\xd4\x43\xaf\x99\xf8\x8c\xa9\xb7\x27\xae\xe7\x0d\xc1\xda\x41\x39\x13\x43\xdb\xab\xa7\xbb\xbf\xef\x6d\xf3\x1b\xa3\x73\x0b\xbe\xbd\x5a\x94\x13\x84\xa3\xbb\x7c\xe2\x3a\xf1\xae\xe2\xe4\xb0\x01\x3b\x87\x07\x90\x0e\xcc\x03\x30\xe2\xfe\xeb\xf0\xfd\xb3\xce\x27\xf8\x38\x34\x6e\xe5\x07\x00\x3a\x5f\x47\x00\x7d\x88\x73\x00\x9d\xf9\x03\x80\x4f\xfc\x23\x8c\x43\x4d\x91\x6b\xa6\xdf\x3f\x82\xf9\xc4\x31\xee\xc4\x77\x34\xd4\x9c\x4e\xc1\x80\x18\xb2\xa0\xa4\x5f\x5d\x2d\x47\xae\xc8\x6a\x99\x1c\x62\x5f\x2d\xaf\x46\xcf\xf2\x2b\x90\xaf\x96\x31\xcb\x7d\x59\x56\x4b\xf2\x6c\x0e\xe6\x75\xa8\x4f\x71\xff\xc4\x8f\xe9\x9f\x03\xcb\x17\xc0\xf2\x7d\xdf\x6a\x2a\x9c\xe8\x38\x77\x0b\x3f\x20\x13\xe7\xea\x48\x26\x3e\xc2\x39\xa8\xce\x7c\x56\x26\xce\x3c\x91\xc9\x29\x88\xd7\xab\xa4\x77\x78\xbd\x4a\x06\x0c\x63\x95\xf4\xab\xe7\x54\x32\xda\x70\x2d\xf8\x4b\x22\x19\xc7\xbb\x42\x24\xa7\x40\x9f\x62\xde\x8a\x84\x74\xb5\x23\xff\xda\xa0\x74\xd4\x8c\x7f\x0d\x12\x1b\x33\x49\xce\xde\x7e\xdf\xcc\x68\xf0\x23\xa2\xf1\x33\xc5\x01\x78\xbb\x7a\x16\xb8\xb5\x9e\x55\xcc\x2f\xa8\x47\xc0\xa6\x5d\xc2\x89\x03\xd6\xef\xc0\xb4\xba\xc8\xf6\x2f\xa8\x4f\x0d\xda\xe6\xf8\x9c\xa0\x3e\x9e\xc2\x1f\x0f\xe2\xbd\x5e\xba\xe9\xe9\x32\xc3\xe4\x89\x57\xef\x6e\xac\xea\xd3\xf9\xcd\x7d\xd4\x78\x41\xf3\x30\x87\x75\xa3\xa1\xce\x38\xa3\xca\xb4\xdd\x8c\xbb\x60\x20\x28\x6d\xa4\xba\x98\xd1\x6f\xdf\x91\xd2\x34\x23\x93\xc9\x20\xf2\x7e\xae\xa7\xc4\xf3\x64\x9c\x9c\x9c\xe8\x2d\xd0\xb8\x1f\xcb\x3d\x1b\x83\xab\xe3\x09\x08\xfd\x80\xf1\x90\x97\xee\xab\x85\xd9\xdc\x29\xab\x1f\x81\xe2\x3a\x53\x34\xab\x60\x86\x16\xb2\xc5\x99\x40\x64\x49\xee\xe6\x21\xa7\x93\x16\x86\xad\x5d\x36\x46\xae\x0c\x55\x3f\x47\x0c\x16\xcc\x4b\x04\x51\x1c\x2a\xe7\x03\x01\x9f\x0a\xf2\xe1\xfd\xd2\xe5\xe4\xd8\x75\x27\x68\x71\xe7\xb4\x3e\xca\xea\x82\xe0\x03\x37\x79\x95\x1a\xe2\x0a\xf9\xf0\x79\x25\x81\x9f\xfc\x70\xaa\xde\x98\xa6\x9b\xe1\x17\xe0\xd2\x4d\xd4\xb1\x95\xa6\xfd\xc2\xf3\xd1\x97\x1a\xeb\x86\x66\xca\x12\xf5\x6f\xc1\xf8\xf0\x75\xc6\x3b\x53\x10\xcd\xc1\x70\xbe\x70\xd3\xf0\xad\xfb\xe5\x8f\x3b\x6d\xe6\xba\x19\x87\xa8\x9b\x15\x23\x3f\x21\x9a\xd2\x46\xa6\xd2\x7e\x82\xb6\xd2\xd2\xdb\xba\xea\xeb\x5b\x40\xe4\x87\xff\xf4\x93\x4a\x2d\x37\xa9\x19\xf1\xa2\x01\x65\xff\xea\x2d\xec\xfa\x4f\x68\xce\x0b\x19\x8d\xe6\xfd\xb0\x3d\xfe\x9e\x15\x04\x7b\xff\x7d\xab\x52\x38\x32\x7f\x2f\xf0\xef\xc0\xdd\xff\xb6\xea\x88\xfd\x9c\x40\xe7\xe4\x7c\x06\xd3\xef\x5b\x03\x7e\x7f\x8e\x6c\x80\xd0\x1e\x91\x6e\x86\x1e\xfe\x1d\x2d\xfe\x37\x00\x00\xff\xff\x37\xc2\xb1\xcb\x65\x15\x00\x00") +var _templateClientTmpl = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xb4\x58\xdf\x6f\xe3\xb8\x11\x7e\xb6\xfe\x8a\xa9\xe0\xbd\x4a\x81\x23\xed\xdd\x5b\x5d\xec\xc3\x21\xd9\x1e\x0c\x14\xc9\xb5\x9b\xa2\xf7\x76\xa0\xa9\x91\xcc\x46\x26\xb5\x24\x95\x38\x70\xfd\xbf\x17\x43\x52\xbf\x6c\xc7\xc9\x2e\x7a\x2f\x89\x45\x52\x33\xdf\xcc\x7c\x1c\x7e\xe2\x7e\x9f\x5f\x45\x37\xaa\x79\xd1\xa2\xda\x58\xf8\xe9\xe3\x8f\x7f\xb9\x6e\x34\x1a\x94\x16\xfe\xc6\x38\xae\x95\x7a\x84\x95\xe4\x19\xfc\x5c\xd7\xe0\x16\x19\xa0\x79\xfd\x84\x45\x16\x3d\x6c\x84\x01\xa3\x5a\xcd\x11\xb8\x2a\x10\x84\x81\x5a\x70\x94\x06\x0b\x68\x65\x81\x1a\xec\x06\xe1\xe7\x86\xf1\x0d\xc2\x4f\xd9\xc7\x6e\x16\x4a\xd5\xca\x22\x12\xd2\xcd\xff\x7d\x75\xf3\xf9\xee\xcb\x67\x28\x45\x8d\x10\xc6\xb4\x52\x16\x0a\xa1\x91\x5b\xa5\x5f\x40\x95\x60\x47\xce\xac\x46\xcc\xa2\xab\xfc\x70\x88\xa2\xfd\x1e\x0a\x2c\x85\x44\x88\x79\x2d\x50\xda\x18\xc2\xf0\xbc\x79\xac\x60\xf9\x09\xd6\xcc\x20\xcc\xb3\x1b\x25\x4b\x51\x65\xbf\x32\xfe\xc8\x2a\xa4\x45\xfb\x3d\x58\xdc\x36\x35\xb3\x08\xf1\x06\x59\x81\x3a\x86\xb9\x7b\x5d\x6c\x1b\xa5\x2d\x24\xd1\x2c\xae\x55\x15\x47\xd1\x2c\x26\x8b\xa7\x46\xf2\xad\xa8\x34\xb3\x18\x47\xb3\xfd\x1e\x34\x93\x15\xc2\xfc\xf7\x05\xcc\x25\xb9\x9e\x67\x77\xaa\x40\x43\x26\x67\xde\x82\x3c\x63\xc2\x8f\x0f\x03\xce\xd6\x35\xa0\x2c\x1c\x96\x59\x5c\x09\xbb\x69\xd7\x19\x57\xdb\xbc\x0c\x65\x11\x92\xb7\x6b\x66\x95\xce\x51\xda\xbc\x10\xac\x46\x6e\x4f\x40\x18\xab\x34\xd9\x74\x50\xbe\x84\x87\x6b\x87\x66\xba\x30\xc4\x4b\xeb\xc2\x3b\xd9\xca\x0d\x99\xb0\xdc\xa3\x0f\xcb\x1c\x44\xb2\x40\x10\xdd\xfc\xe8\x77\x1a\x45\x79\x0e\x37\xae\x16\xc4\x08\x2a\xa7\xaf\x0c\xd8\x0d\xb3\xb0\x51\x75\x61\x80\xd5\x35\xd0\xd0\xba\x15\x75\x81\xda\x64\x91\x7d\x69\xb0\x7b\xcd\x58\xdd\x72\x0b\xfb\x68\xc6\x5d\xb6\xa2\x59\x9e\xc3\x17\xbe\xc1\x2d\x3b\x32\x59\x2a\x0d\x5c\x23\xb3\x42\x56\x0b\xf0\xc5\x10\xb2\x02\x26\x0b\x28\xb4\x6a\x1a\x7a\x30\xee\xcd\x2c\x9a\x05\x13\x57\xa1\x68\x99\x7f\xbe\x58\x3a\x1f\x7e\x9e\x83\xaf\xd2\x1d\xdb\x52\x89\xce\xa0\x10\xd2\xa2\x66\xdc\x79\x7f\x16\x76\xe3\xe6\xa7\x2f\x0d\xc1\xba\xec\x8d\x66\xae\x26\x8f\x3e\x0b\x7d\x56\x0f\x87\xe8\xe0\x92\x7a\x87\xcf\x21\x41\x2e\x64\x34\xc0\x40\xe2\x73\x87\xc2\xe7\xaa\xd5\x58\x0c\x00\x2a\xf1\x84\x12\x54\x63\x85\x92\x26\x8b\xca\x56\xf2\xc1\x4c\xa2\x1a\x6b\x20\xcb\xb2\x7b\x37\x9f\xc2\x55\x30\x4f\x89\xa7\x24\x78\x8b\xfb\x5a\x55\x4b\xa8\x55\x95\xfd\xaa\x85\xb4\xb5\x3c\x44\x33\x9e\x05\x9b\xce\x46\x96\x65\x69\x34\xd3\x68\x5b\x2d\xe1\x07\x6f\x64\x1f\xcd\x42\xf5\x96\xc0\x17\xd1\x2c\x24\x7f\x09\x5d\xf2\xef\xf0\xd9\x0f\x25\x3c\x2b\xb4\x78\x42\x9d\x2e\x4e\x88\x79\xa6\x16\xd3\xd4\x2d\x29\x9c\x33\xd9\x4b\x78\x67\xad\x27\x69\x97\xc6\xfb\xc6\xa5\x04\x25\xe5\x8f\x2b\x29\x91\x53\x28\x60\x95\x4b\x59\xc1\x2c\x73\x3d\xc3\x34\xc8\x45\x29\xb0\x80\xf5\x8b\x9f\x71\x28\x41\x92\x1f\x22\x18\x23\x6b\x7e\xf0\x3a\x2c\xe6\xee\xf5\xae\x51\xd1\xca\x85\x5b\xea\x73\x73\x54\x30\x66\x2d\xb5\xc6\x82\x3c\x0b\x9b\x79\x6c\x04\x85\xd5\xd0\x30\xcd\xb6\x68\x51\x1b\xe0\x4c\xc2\x1a\x81\x15\x05\x16\x9e\xf0\xa1\xd0\x44\xb5\x81\x85\xa1\xba\x14\x5d\xe2\x41\xdd\x39\xf7\x04\xe8\x8b\xc3\xe3\x12\x64\xac\x76\x7b\x25\xd4\x6f\x5c\xfe\x24\xd4\x7f\x01\xa8\xb5\xd2\x29\xf1\xc0\x3c\x0b\xcb\x37\x30\x18\xa4\x41\x6a\x4f\x6f\xb5\x19\x57\x2b\x4e\x79\xdc\xef\xe1\x3f\x4a\xc8\xa1\xb5\xdc\xfa\x76\x65\x20\x5e\x00\xb5\xeb\xa5\xaf\xea\x35\xcc\xed\xb6\xa9\xc9\x4c\x43\x44\x2b\x21\x0e\x8d\x2d\xff\x60\x72\x1f\x64\x4e\x75\x8b\x07\x97\x3d\x25\xae\x61\xd7\x37\x73\x6f\x26\xeb\x5a\x53\xdf\x4a\x67\x05\x96\xac\xad\x2d\xf9\x0b\x64\x95\xa2\x5e\x40\xb9\xb5\xd9\x67\x8a\xb8\x4c\xe2\x56\x9a\xb6\xa1\x2e\x87\x45\x08\x7a\x09\x1f\xbe\xc6\x8b\x51\x06\xd2\x81\x4a\x0f\xbb\xa3\xca\x5a\xcd\xa4\x61\x3c\x14\x71\x52\x98\x84\x77\xfb\x2b\x85\x87\x5d\xc2\xed\x8e\x0a\x69\x71\x67\xe9\x4c\xa0\xff\x54\x81\x87\xdd\x38\xfb\xa2\x84\xdf\x17\xa0\x1e\xdd\x66\x0c\xbb\x24\x4b\xae\xec\xee\xd6\x6f\x98\xbf\xd2\xdc\xfe\x42\x38\xdd\x39\x48\x1b\x85\x33\x29\x15\x35\x57\xa6\x2d\xb0\x31\x54\xd7\x2f\x84\x9c\x0e\xc6\x2e\xce\x99\xf5\x80\x08\x81\xc4\x67\x0f\x7c\xd1\x83\x49\x1d\x46\x9a\xff\xd3\x27\xf2\xfe\x6e\x30\x0e\x85\xeb\xd4\x63\x9f\x4b\xf8\xf0\x14\x3b\x7f\xde\x39\x2f\xab\x51\x1f\xea\xea\x41\x00\x5c\x4f\xe2\x59\xad\xaa\x05\x14\xb8\x6e\xdd\x93\xfb\x71\x18\x3a\xd1\xc3\x6e\xd2\x85\xca\xea\xff\xda\x60\xca\xea\xb4\xc5\x2c\x28\xea\x40\x8e\x5b\x42\x73\xc4\x0f\x87\xf0\x3a\xf0\x02\x56\xf6\xcf\x06\x5a\xe3\x3b\x40\x85\x16\x9e\x50\xaf\x95\x41\x8a\xae\xa2\xe4\x28\x09\x7d\x63\x51\x0d\xd2\xe1\xe6\xfa\x78\x9e\x47\x79\x3e\x0b\x66\x9c\x9f\x24\xa5\x51\x87\x26\x11\xb2\xc0\x5d\x1f\xd4\xc7\xb4\x03\xee\x57\xfc\xa3\x45\xfd\xd2\x2d\xbf\x51\x2d\x85\x62\x77\x29\xd9\x3c\xe1\x69\x30\x3d\x3e\x18\x44\xd9\x25\x7a\x5c\x6b\x7e\xa1\x5c\x61\x13\x07\x9c\x1d\x73\x16\xbe\x7a\xe9\xd9\x52\x5a\xdd\xe2\xe1\xe2\x89\xe2\x6b\x79\xe1\x4c\x29\xab\x3f\xe4\x54\x39\x57\xf4\x50\xef\x9b\x9a\x4a\xc7\xe9\xaf\x99\x9e\x24\xa3\x43\x86\x0e\x83\x46\xe3\x13\x4a\x6b\x1c\x23\xbe\xb6\xa8\x05\x1a\x28\xb5\xda\xf6\xbb\xe2\x4c\xcb\x70\xd6\x93\xd4\x37\x07\x4a\x7d\x97\xf9\xae\x2d\x84\x05\x91\x57\xbf\x97\xa2\xa5\xc0\xc2\x11\xd4\xf5\xda\x3e\xd2\xf8\x66\x50\xd1\x41\xf5\x84\xa5\x5e\xf5\xb0\xb1\xe6\x39\x95\x38\x9d\xd4\x72\x6a\x6e\xfa\xf2\x89\xa8\x0b\x32\x5d\xa3\xd3\x1a\x73\x99\xfd\x13\x39\xba\x13\xf6\x70\xd8\xef\x81\xfa\xca\x57\x3f\x1d\xf3\xd8\x8f\xb9\xa7\xe1\x78\xf8\x90\xfd\x64\xe2\xde\xfd\x7f\xa1\x56\xcf\xdd\xdb\x9d\x7a\xf6\xb2\x69\x8a\x64\xd8\x92\x17\x63\x71\x15\x19\x44\x94\x47\x3d\x68\xa8\x89\xcd\x84\x87\xf9\xd4\x6b\xb9\xc1\xd9\x50\xa9\x1f\x26\x13\xfb\x9e\xca\x3d\x7f\x9c\xa8\x1b\xa3\xf3\x03\x41\x36\x3a\x94\x13\x84\x23\x96\x4c\x4c\xa7\xc1\x54\x92\x1e\x0b\x4b\x6f\xf0\x08\xd2\xd1\xf4\x00\x2c\xf3\xbf\x3a\x7c\xff\x6a\x8a\x09\x3e\x09\xad\x1f\xf9\x0e\x80\xde\xd6\x09\xc0\xe0\xe2\x35\x80\x7e\xfa\x0d\x80\xf7\xf2\x2d\x8c\x43\x4d\x51\x5a\x61\x5f\xde\x82\x79\x2f\x31\xe9\xc8\x77\x22\xd6\xcf\x87\x40\x20\xc6\x7b\xb4\x1f\x5d\xdd\x8e\x4c\x65\xab\xdb\xf4\x18\xfb\xea\xf6\xdd\xe8\x45\xf1\x0e\xe4\xab\xdb\x44\x14\xa1\x2c\xab\xdb\xec\x81\x36\xe6\xfb\x50\x9f\xcb\xfd\xbd\x3c\x4d\xff\x02\x44\xb1\x04\x51\x1c\xfa\x73\xaf\xc6\x09\x8f\x0b\x3f\xf0\x1d\x34\xf1\xa6\x4e\x68\x12\x3c\xbc\x06\xd5\x4f\xbf\x4a\x13\x3f\x3d\xa1\xc9\x39\x88\xef\x67\x49\x6f\xf0\xfd\x2c\x19\x30\x8c\x59\xd2\x8f\xbe\xc6\x92\xd1\x82\xf7\x82\xbf\x44\x92\xb1\xbf\x77\x90\xe4\x1c\xe8\x73\x99\x77\x24\xc9\xba\xda\x65\xff\xde\xa0\xf6\xa9\x19\xdf\x72\x64\xce\x67\x9a\xbe\xda\xfd\xe8\x60\x7c\xf9\x1e\xd2\x04\x81\x73\x04\xde\x8d\xbe\x0a\xdc\xcd\xbe\xca\x98\x5f\xd0\x8e\x80\x4d\x4f\x09\x4f\x0e\xfa\x44\x14\xd6\x5c\xcc\xf6\x2f\x68\xcf\xa9\x7e\xda\x3e\x67\x52\x9f\x4c\xe1\x8f\xbf\x0a\x7a\xbe\x74\x52\xee\x72\x86\xb3\x7b\x59\xbf\x78\x8d\xd7\x87\xf3\x9b\xbf\xac\x7b\x44\x7a\x58\xc0\xba\xb5\xd0\x30\x29\xb8\xa1\x63\x97\xc9\xa0\x32\x14\xe7\xad\x36\x17\x23\xfa\xed\x1b\x42\x9a\x46\xe4\x3f\x24\x3b\x92\xf7\x1f\x19\x3c\x0b\x79\x22\x23\x67\x3f\x2f\x1c\xd0\xa4\xff\x46\x08\xd9\x18\x4c\x9d\x2a\x20\x0c\x02\xe3\x73\x51\xf9\xdb\x38\x5a\xdc\x31\xab\x97\x40\x49\xc3\x0c\x67\x35\xcc\xd1\x41\x76\x38\x53\x88\x5d\x92\x3b\x3d\xe4\x79\xb2\x87\x61\x69\x17\x4d\xa7\xe3\x3a\x1d\x31\xcc\x60\x51\x21\xa8\xf2\x98\x39\x6f\x10\xf8\x9c\x93\x37\xfb\x4b\x17\x93\xcf\xae\xdf\x41\xcb\x4f\x9e\xeb\xa3\xa8\x2e\x10\x7e\xe6\x95\x57\x65\x21\xa9\x51\x0e\xdf\xf3\x29\xfc\x18\x94\x72\xb8\x11\xe8\x75\x67\xf8\x9a\x4f\x1c\x35\xff\xb0\xab\x01\x77\xa3\x85\x3b\x4b\xba\x6e\x2e\x21\xee\xb4\x62\x1c\x14\x22\x95\x36\xa6\x4a\x07\x39\xef\xa8\x75\xe1\x3a\xc1\xe5\x26\x27\x89\x37\xba\x4d\xe8\x5f\x7d\xf5\x36\x61\xaa\xfc\x27\x97\x0b\xb3\xee\xb2\xa1\x36\x38\x9a\xfe\x56\xe0\xdf\x80\xbb\xff\xd0\xeb\x12\xfb\x31\x85\x37\xef\x43\x8e\xee\x6d\x07\xfc\x61\x1f\x39\x07\x91\xdb\x22\x9d\x86\x1e\x7e\x8e\x06\xff\x17\x00\x00\xff\xff\x94\x36\x8e\x5d\x3d\x18\x00\x00") func templateClientTmplBytes() ([]byte, error) { return bindataRead( @@ -252,7 +254,7 @@ func templateClientTmpl() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "template/client.tmpl", size: 5477, mode: os.FileMode(420), modTime: time.Unix(1568645715, 0)} + info := bindataFileInfo{name: "template/client.tmpl", size: 6205, mode: os.FileMode(420), modTime: time.Unix(1569672823, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -437,6 +439,26 @@ func templateDialectGremlinMetaTmpl() (*asset, error) { return a, nil } +var _templateDialectGremlinOpenTmpl = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x5c\x90\x41\x6b\xdc\x30\x10\x85\xcf\xd2\xaf\x98\xe6\xb4\x0e\xae\x9c\xe6\xd6\x85\x1c\xc2\x76\x0b\x81\xb0\x94\xa6\xfd\x01\xaa\x34\x5e\x0f\x55\x46\x62\x24\xbb\x04\xa3\xff\x5e\x6c\xd6\xdb\x92\xa3\xde\x7b\x7a\xdf\x63\xe6\xb9\xbb\xd5\x87\x98\xde\x84\xce\x43\x81\xfb\xbb\x4f\x9f\x3f\x26\xc1\x8c\x5c\xe0\xab\x75\xf8\x2b\xc6\xdf\xf0\xc4\xce\xc0\x63\x08\xb0\x86\x32\x2c\xbe\x4c\xe8\x8d\xfe\x31\x50\x86\x1c\x47\x71\x08\x2e\x7a\x04\xca\x10\xc8\x21\x67\xf4\x30\xb2\x47\x81\x32\x20\x3c\x26\xeb\x06\x84\x7b\x73\xb7\xb9\xd0\xc7\x91\xbd\x26\x5e\xfd\xe7\xa7\xc3\xf1\xf4\x72\x84\x9e\x02\xc2\x45\x93\x18\x0b\x78\x12\x74\x25\xca\x1b\xc4\x1e\xca\x7f\xb0\x22\x88\x46\xdf\x76\xb5\x6a\x3d\xcf\xe0\xb1\x27\x46\xb8\xf1\x64\x03\xba\xd2\x9d\x05\x5f\x03\x71\xe7\x02\x21\x97\x2e\x26\xe4\x1b\xa8\x55\xab\xb1\x05\x14\x81\xfd\x03\x8c\x12\xcc\x37\x2b\x19\x77\xde\x16\xfb\xb2\xd6\x9e\xec\x2b\x36\x5a\x51\xbf\x86\x3e\x3c\x00\x53\x80\x59\x2b\x25\x58\x46\xe1\xe5\xb9\xfe\xd7\xaa\x6a\xe5\xae\x55\x17\x9a\x39\xe1\x9f\xc3\x0a\xdc\x6d\xca\x21\x72\x4f\xe7\xa5\xe1\xc8\x3e\x45\xe2\xb2\xbf\xa6\x37\x65\x71\xd5\xcf\xef\xcf\x7b\x18\x5b\xad\x54\x6d\xb5\xaa\x8d\x56\x5e\xa6\x77\xdd\x5f\x84\x26\x94\x9d\x6b\xf4\xb6\xe7\x1f\xd0\xa6\x84\xec\x77\x31\x15\x8a\x9c\x5b\xb8\x64\xbd\x4c\x4d\x63\x8c\x69\xda\x65\xfb\x72\x29\x64\x0f\xb5\xfe\x0d\x00\x00\xff\xff\x72\x49\x92\xec\xf7\x01\x00\x00") + +func templateDialectGremlinOpenTmplBytes() ([]byte, error) { + return bindataRead( + _templateDialectGremlinOpenTmpl, + "template/dialect/gremlin/open.tmpl", + ) +} + +func templateDialectGremlinOpenTmpl() (*asset, error) { + bytes, err := templateDialectGremlinOpenTmplBytes() + if err != nil { + return nil, err + } + + info := bindataFileInfo{name: "template/dialect/gremlin/open.tmpl", size: 503, mode: os.FileMode(420), modTime: time.Unix(1569672616, 0)} + a := &asset{bytes: bytes, info: info} + return a, nil +} + var _templateDialectGremlinPredicateTmpl = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xd4\x56\x5f\x6b\xeb\xb8\x13\x7d\xb6\x3f\xc5\x10\x0a\x3f\x3b\xa4\x4a\x7f\xf7\x6d\x17\xfa\xd0\xed\xe6\xb2\x81\x4b\xc3\x6e\x2f\xdd\x87\x52\x82\x6a\x8d\x13\x51\x55\x32\x23\xd9\xe5\x62\xfc\xdd\x17\x49\x4e\xe2\xa4\xb9\xa4\xdb\xee\x1f\xf6\x29\x41\x33\x9a\x39\x73\xce\xb1\xa4\xb6\x9d\x8e\xd3\x6b\x53\x7d\x23\xb9\x5a\x3b\xf8\x74\xf1\xff\x1f\xce\x2b\x42\x8b\xda\xc1\x67\x5e\xe0\xa3\x31\x4f\x30\xd7\x05\x83\x2b\xa5\x20\x24\x59\xf0\x71\x6a\x50\xb0\xf4\xeb\x5a\x5a\xb0\xa6\xa6\x02\xa1\x30\x02\x41\x5a\x50\xb2\x40\x6d\x51\x40\xad\x05\x12\xb8\x35\xc2\x55\xc5\x8b\x35\xc2\x27\x76\xb1\x89\x42\x69\x6a\x2d\x52\xa9\x43\xfc\xcb\xfc\x7a\x76\x73\x3b\x83\x52\x2a\x84\x7e\x8d\x8c\x71\x20\x24\x61\xe1\x0c\x7d\x03\x53\x82\x1b\x34\x73\x84\xc8\xd2\xf1\xb4\xeb\xd2\xb4\x6d\x41\x60\x29\x35\xc2\x48\x48\xae\xb0\x70\xd3\x15\xe1\xb3\x92\x7a\x5a\x11\x0a\x59\x70\x87\x53\x29\x46\x70\xde\x75\x69\x52\xd6\xba\xc8\x1c\x8c\x85\x55\xec\x2b\xf1\x06\xc9\x72\x95\x43\x9b\x26\x89\x63\xbf\x70\x3b\xff\x39\x93\x22\x4f\x93\x2e\x6d\xdb\x73\x40\x2d\xe0\x4f\xf4\x98\x9a\xca\xf6\x7d\xfc\xee\x33\x53\xc1\x8f\x97\x70\xc6\x6e\x0b\x53\x21\x5b\x54\x83\x10\xa7\xd5\x30\x76\x45\xab\x41\xd0\x3a\x43\x7c\x85\xc3\x84\xdb\x7e\xe9\xd4\x10\x7e\xbf\x2c\x7d\x6b\x76\xc7\x49\x72\x21\x0b\x3f\x41\x92\x24\x8d\x2f\xf7\xcc\x9f\x30\xbb\x7f\x90\xda\x21\x95\xbc\xc0\xb6\x9b\x80\x42\x9d\xb5\x6d\x84\xd4\x75\x79\xee\x93\x4b\x43\x20\xfd\x06\xe2\x7a\x85\xd0\x84\xda\x49\xd2\xdc\xcb\x07\xb8\x84\x5d\xf6\xbd\x7c\xf0\x81\xae\xef\xdc\xf3\xb5\xe3\xb2\x62\x6d\x0b\x05\x57\x6a\x3b\x14\x5b\x54\xd7\xde\x2a\x9e\x9c\xae\xf3\x8d\x5f\xc3\x6d\x18\xf3\xfb\x50\x59\x84\xae\xdb\x75\xf3\x6b\xa1\x43\xfe\x3e\x85\x4a\x89\x4a\x0c\x05\x2a\x87\x14\x7f\xf6\xd1\xb7\xb9\x24\xfb\xc2\x1f\x51\x4d\x02\x11\x25\xbb\x36\xda\x3a\xae\x1d\x74\xdd\x04\x2a\x36\xfb\x35\x6b\x3e\x02\xf0\xd0\x45\xdf\x03\x79\xca\x62\x1f\x77\x91\x36\x2e\x48\x73\x23\xd5\xce\x48\xa7\x09\x38\x21\x79\x73\x54\xf3\x5e\xf2\xad\xbc\xd1\x4f\xd1\x01\x9b\xae\xa1\x69\x6c\x9d\xbf\xc1\x58\xfb\xc8\xf2\x03\x8f\xbe\x43\x1e\x14\x2b\x9c\xae\xf9\x9e\x3a\x7b\xfc\xce\xc4\x86\xdc\x10\x53\x1e\x69\x88\xe3\x0e\xc9\x2e\x1c\x8f\x37\x69\xb4\x4f\x19\x2d\x6a\x37\xa8\xeb\x09\x42\x36\xb7\x73\xed\x75\xe9\x8b\x1e\x6e\xbb\x84\xd1\x5c\x8f\xb6\xb1\xe9\x18\x78\x63\xa4\x80\x42\x52\x51\x2b\x4e\x20\xb0\x42\x2d\xb0\x90\x68\x21\x9c\x96\xc9\x10\x58\xc0\xd5\x37\x78\x0d\xcf\x33\xf3\x16\x9f\x4c\xc7\x1e\xac\x74\xff\xb3\xc0\x35\x78\x8a\xe0\x45\xba\x35\x58\x54\xe5\x39\x61\x89\x84\xba\xc0\x09\x38\xfe\x84\xe1\x68\x77\x2f\x06\x1a\x24\x27\x8b\x7d\x54\x71\xe4\x5b\x54\xe5\x6f\x58\xf6\x87\x96\x63\x3f\x19\xb7\x0e\x62\x46\xcc\x03\x1d\xb7\xde\x48\x9c\x37\xc3\x80\x97\xae\x9b\xed\x6f\x79\x15\xbf\xcb\xfe\x42\x3b\xf8\x71\xff\x01\x4b\x9c\xc9\x28\xd5\x72\x3f\x69\xeb\x80\xf7\xda\xe6\x68\xe5\xbd\xee\xff\x9a\xb7\x0e\x2d\x11\x70\x78\x63\x11\x96\xf0\x8c\x5c\x5b\x90\x0e\xec\xda\xd4\x4a\xc0\xa3\x7f\x17\xd4\xe1\x05\x61\x34\xc6\x27\x03\xc2\x76\xa4\x2d\xca\x44\xea\x09\x98\xda\x79\xf6\x96\x4b\x36\xd7\x77\x59\x3e\xf1\xff\x16\xb5\x8b\xbe\x08\xd7\xdf\x72\x02\xd5\xee\x06\xf4\xaa\xdb\xfe\x16\xac\x32\xa9\xf3\xfe\x9f\xa9\x5d\xbe\xb9\x01\x13\xc7\x7e\x5f\x23\x61\x16\x62\xbe\x20\xc5\xbf\x49\x2c\x7e\x68\xca\x98\x2c\x75\x3e\xd9\x66\xcd\xf5\xf1\x24\xdf\x26\x66\xc5\x9f\x63\x1f\x01\xf5\x03\xf9\xfd\xaf\x05\xdd\x78\xfe\xe4\x6c\x8e\x86\x03\x9d\xfa\xb0\x22\x3c\x47\x7f\xd3\x27\xc6\xf5\xfe\xc3\x8d\x8e\xdf\xc9\x64\xbf\xf7\xb8\xb9\x88\xef\x9b\x6d\x45\x1b\xee\x96\xe3\x1c\xc4\x84\x48\xc4\xc6\x1d\x37\xf8\x12\x69\xab\xb2\x28\xb4\xef\x75\x09\xbc\xf2\xe6\xcf\x1c\xd9\x09\x84\xf5\x70\x47\x51\x4f\xc7\x72\xc9\xae\x62\x94\x31\xf6\xce\xa7\x80\xa1\xff\xe6\xe0\x0b\xfa\xd8\xdc\xda\xb8\xb7\x0c\x7e\x80\xb2\x07\x39\x04\x72\x63\x5c\xe6\x0e\x41\xfc\x11\x00\x00\xff\xff\xa5\xc2\xe7\x43\xf1\x0c\x00\x00") func templateDialectGremlinPredicateTmplBytes() ([]byte, error) { @@ -657,6 +679,26 @@ func templateDialectSqlMetaTmpl() (*asset, error) { return a, nil } +var _templateDialectSqlOpenTmpl = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x4c\x8e\x41\x8b\xdb\x30\x14\x84\xcf\xd6\xaf\x98\xe6\x64\x07\x57\x4e\x73\x6b\x21\x87\x90\xa6\x10\x28\xe9\x21\xfd\x03\xae\xf4\x5c\x8b\xd5\x3e\x29\x4f\xb2\x97\x60\xfc\xdf\x17\x9b\x0d\xec\xf1\xcd\xcc\x9b\x6f\xa6\xa9\xd9\xaa\x53\x88\x0f\x71\xff\xfb\x8c\xfd\xee\xdb\xf7\xaf\x51\x28\x11\x67\xfc\x6a\x0d\xfd\x0b\xe1\x05\x17\x36\x1a\x47\xef\xb1\x86\x12\x16\x5f\x46\xb2\x5a\xfd\xed\x5d\x42\x0a\x83\x18\x82\x09\x96\xe0\x12\xbc\x33\xc4\x89\x2c\x06\xb6\x24\xc8\x3d\xe1\x18\x5b\xd3\x13\xf6\x7a\xf7\x74\xd1\x85\x81\xad\x72\xbc\xfa\xbf\x2f\xa7\xf3\xf5\x76\x46\xe7\x3c\xe1\x43\x93\x10\x32\xac\x13\x32\x39\xc8\x03\xa1\x43\xfe\x04\xcb\x42\xa4\xd5\xb6\x99\x67\xa5\xa6\x09\x96\x3a\xc7\x84\x8d\x75\xad\x27\x93\x9b\x74\xf7\x8d\xf1\x8e\x38\x37\x21\x12\x6f\x30\xcf\xaa\xb0\x32\xd6\x20\x11\xfc\x38\x20\xdd\xbd\xfe\x13\x89\x4b\x2b\x6e\x24\xb9\xb6\xaf\x54\xc3\xb6\xb9\xbd\xad\xfd\xcb\x5d\xa9\xc2\x75\x6b\xfe\xcb\x01\xec\x3c\x26\x55\x14\x42\x79\x10\x5e\xce\xb5\x4a\x15\xb3\x7a\x6a\x57\x7a\x3b\xad\xc8\xb2\x8d\x91\xd8\x96\x21\x66\x17\x38\xd5\xf8\xb9\x32\x4a\x2b\x63\x55\x69\xad\xab\x7a\xf9\x5f\x66\x13\xdb\x65\xd9\x7b\x00\x00\x00\xff\xff\x01\xec\x54\x15\x85\x01\x00\x00") + +func templateDialectSqlOpenTmplBytes() ([]byte, error) { + return bindataRead( + _templateDialectSqlOpenTmpl, + "template/dialect/sql/open.tmpl", + ) +} + +func templateDialectSqlOpenTmpl() (*asset, error) { + bytes, err := templateDialectSqlOpenTmplBytes() + if err != nil { + return nil, err + } + + info := bindataFileInfo{name: "template/dialect/sql/open.tmpl", size: 389, mode: os.FileMode(420), modTime: time.Unix(1569672619, 0)} + a := &asset{bytes: bytes, info: info} + return a, nil +} + var _templateDialectSqlPredicateTmpl = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xec\x57\xd1\x4f\xe3\xb8\x13\x7e\x4e\xff\x8a\x11\xaa\xf4\x4b\x50\x71\xa1\xbb\x3c\xfc\x4e\xe2\x24\xd4\x03\xa9\x77\x0b\xbd\x53\x57\x77\x0f\x08\xad\xbc\xf1\xa4\xf5\xae\xb1\x83\xed\x16\xa1\x6c\xfe\xf7\x93\x1d\x37\x4d\x4a\x0a\x3d\x96\xd5\xbd\xdc\x13\x49\x66\x3c\xf3\xcd\x37\xdf\x4c\x4d\x51\x0c\x0f\x7b\x63\x95\x3f\x6a\x3e\x5f\x58\x18\x1d\x9f\xfc\xff\x28\xd7\x68\x50\x5a\xb8\xa4\x29\x7e\x56\xea\x2b\x4c\x64\x4a\xe0\x5c\x08\xf0\x4e\x06\x9c\x5d\xaf\x90\x91\xde\xc7\x05\x37\x60\xd4\x52\xa7\x08\xa9\x62\x08\xdc\x80\xe0\x29\x4a\x83\x0c\x96\x92\xa1\x06\xbb\x40\x38\xcf\x69\xba\x40\x18\x91\xe3\xb5\x15\x32\xb5\x94\xac\xc7\xa5\xb7\x7f\x98\x8c\x2f\xae\x67\x17\x90\x71\x81\x10\xbe\x69\xa5\x2c\x30\xae\x31\xb5\x4a\x3f\x82\xca\xc0\x36\x92\x59\x8d\x48\x7a\x87\xc3\xb2\xec\xf5\x8a\x02\x18\x66\x5c\x22\x1c\x30\x4e\x05\xa6\x76\x68\xee\xc5\x30\xd7\xc8\x78\x4a\x2d\x0e\x39\x3b\x80\xa3\xb2\xec\x45\xd9\x52\xa6\xb1\x81\x43\x73\x2f\xc8\x0c\x85\x0f\x9d\x40\xd1\x8b\xa2\xa2\x38\x02\x9e\x41\x9f\x4c\x7e\x21\x13\x33\xb3\x9a\xcb\x39\x94\x25\x67\x03\xf8\x04\x3f\x9d\x81\xb1\x3a\x55\x72\x45\xce\xad\xe2\x31\x67\x89\xf3\x47\xc9\xc0\x45\x8d\x0c\xf9\x6b\x81\x1a\x63\x17\xf6\xe2\x8f\xd8\x90\x71\x5c\x14\x55\xac\xb1\x92\xc6\x52\x69\xa1\x2c\x93\x01\x70\x96\x24\xbd\xa8\xec\x35\x4e\xef\x83\x7e\xa8\x72\x13\x2a\x70\x27\xfb\x2a\x77\x90\xfa\x64\x96\xaa\x1c\xc9\x34\x6f\x98\xa8\x9e\x37\x6d\xe7\x7a\xde\x30\x1a\xab\x34\x9d\x63\xd3\x61\x16\x3e\xed\x49\x8f\xca\xc9\x9f\x54\x73\xca\x78\x5a\x95\x1e\x0d\x87\xce\x20\x95\x05\xaa\xe7\xcb\x3b\x94\xd6\xc0\x03\x6a\x84\x5c\xab\x15\x67\xc8\x06\x40\xf3\xdc\x15\xeb\x9a\x7a\x79\xfe\x61\x76\x01\x69\x20\xc5\x0c\x42\x04\xc3\x65\x8a\xf0\x80\x90\x52\xf9\x3f\xeb\x0e\x88\x47\x38\x98\x5c\x43\x9c\x1c\x10\xf0\x22\x7b\xe0\x42\xc0\x1d\xfd\x8a\x95\x0c\x6a\x7a\x20\xa3\xc2\x3c\x12\x17\x88\x67\x20\x50\x7a\xea\x1d\x0d\x65\x99\xc0\xd9\x19\x1c\xfb\x02\xda\x4d\xba\xa4\xc2\x60\xec\x7a\x11\x45\x91\x46\xbb\xd4\xd2\x3d\xfa\x82\x56\x8e\x1e\x97\x28\xbe\xb9\xe5\xd2\xa2\xce\x68\x8a\x45\x39\xd8\x8e\xed\x0f\x67\x4a\x03\x77\x07\x34\x95\x73\x84\x55\xc8\x55\x14\x5d\x62\x5a\xdd\xf0\x5b\x27\xa7\x2d\x35\x6d\x62\xde\xf0\xdb\xa4\x28\x00\x85\xc1\xe0\x0e\x67\xd0\x32\x3b\xeb\x5a\x75\x1e\xae\x57\x92\xf3\xef\xc8\xe7\x39\xe9\x14\x70\xa3\x8c\x75\x8c\x2e\x2d\x17\x05\xa4\x54\x88\x5a\x38\x64\x9a\x8f\xdd\x90\x3b\x01\x96\xe5\x33\x3a\x0f\xf5\xb7\xd5\xb2\x22\x84\x6c\xaa\xe3\xac\xae\xe5\x15\x33\x91\x71\x14\xac\x39\x12\x59\x53\xd4\x97\xce\xfa\x92\xa4\x77\x0c\x6d\xb6\x55\xca\xea\xb5\xe8\xb6\x87\x76\x17\xc2\xff\x26\xfa\x07\x4f\xf4\xf7\xca\xbb\xad\x88\x4a\xda\x8e\x1d\x47\xdd\x35\x17\x81\xb9\x01\xac\x3a\x55\x1f\x44\xef\xf3\x7f\x8f\xe2\x91\xcd\x71\xb8\xa0\x2d\x49\xb5\xfa\x7e\xc1\xf6\x6f\x3a\x92\xab\xd1\x15\x84\x7e\xdb\x13\xbf\x1f\xc8\x47\xfa\x59\x60\xec\x19\x5c\xb3\x54\xd1\x7c\x2f\xc8\x44\x56\xcf\x91\x3d\xd9\x35\xf4\x95\x7d\x93\xd3\x7b\x21\xf9\xfd\xb7\x86\xd7\x4d\xa0\x08\xc9\xc4\x4c\xe4\x0a\xb5\x5f\x05\x27\x9b\xad\x70\x5c\x53\x74\x9b\x90\x4b\xad\xee\x7c\xa3\x2a\x64\x55\x3c\xff\xdc\x4c\x1c\x32\x57\x7f\x92\xad\x95\xa8\x74\x55\xec\x14\x62\x2a\x99\x7b\x9e\x8e\xa6\xad\xfc\x89\xef\xcb\xf0\x10\x9c\xd3\xb7\x6f\x10\x3b\x87\x07\x6e\x17\xc0\x03\x40\xc7\x7c\x02\xfe\xaa\xf1\x3c\x5b\x0e\xea\xb5\xb2\xd7\x4b\x21\xe2\x9a\x27\x24\x63\x25\x96\x77\xb2\x05\xb9\x05\x33\xe4\x9f\x8e\xae\xda\xf9\xa9\x31\x2a\xdd\x3f\xfb\x1b\xf4\xea\x29\x52\x52\x79\x46\x7b\xb6\x62\xed\xfe\x94\x8f\x9d\x54\x74\x76\x2f\x4c\xeb\x2b\x47\xc4\xb1\xf7\xf6\x63\xe2\x2a\xf0\x3f\xf5\x27\xd5\x24\xf7\xbf\xb8\x97\x63\xff\x72\xd4\xa1\xea\xca\x7f\xed\xe1\xdc\xeb\xa3\xae\xa2\xa3\x9d\x0d\xb5\x23\xff\xa9\x26\x3b\xdc\x28\x7c\x0e\x89\xd0\xaf\x3e\xfb\x06\x3c\xe6\xa1\x0b\xeb\x70\x15\x4c\x24\x01\xc6\x76\x87\xea\x50\x5e\x78\xf5\x19\xef\xb6\xb1\x6d\xd0\x55\x78\xde\xb5\xf1\xec\x68\xbe\x77\x7d\xbf\x76\x0d\xba\xb2\xef\xea\x31\x78\xb2\x08\xfa\x5f\xfc\x98\x07\xd1\x78\x85\xd9\x77\xe1\xed\x57\xc5\x65\x6c\x47\xe1\x6d\x2a\x9f\x0f\xc4\x7d\xa0\x01\xd8\x51\xed\xe4\xa9\xd9\x92\x7d\x05\xf1\x74\x0b\x62\xd8\x33\x76\x54\x5f\xe8\x3e\x0d\x20\xdf\xdc\xe9\x9c\xbe\x4c\xf8\xc5\xc9\x63\x7b\x9a\xd4\x37\x45\xfb\xde\x1f\x5d\x97\x7a\xfa\x64\x19\x4c\x64\xbc\x7b\x06\xc1\xbe\x4f\xfe\x95\x75\xb5\xd1\x57\x6b\xf8\xbb\x18\xdb\x5e\xc1\x3f\x5e\x8a\xdd\xe2\xea\xd4\xe6\x7e\xfd\x1a\x6d\xfa\xb5\xab\x35\x5d\x7b\xc9\x89\xe9\x4d\xd7\xf4\x0e\xd6\x3b\x56\xee\x9e\xbb\xf6\xad\xaa\xef\x10\x66\xa3\xf2\xd7\x6d\x62\x2a\x5f\xfe\x8f\xbb\x1b\xbb\x3f\x1f\x0a\xc8\x63\xe3\x70\xfc\xf3\xf4\x4a\xef\x95\x9d\x3f\x9b\x9d\x67\xc0\xe1\xe7\xc6\x65\x73\xaa\xe3\x0d\x9b\xaf\xc6\x26\x95\x7d\x11\x5c\x1e\x1b\xf7\xc3\x19\x3f\xb9\x26\xfe\x1d\x00\x00\xff\xff\xa5\xf9\x0b\x05\xae\x11\x00\x00") func templateDialectSqlPredicateTmplBytes() ([]byte, error) { @@ -832,7 +874,7 @@ func templateMetaTmpl() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "template/meta.tmpl", size: 3295, mode: os.FileMode(420), modTime: time.Unix(1569501505, 0)} + info := bindataFileInfo{name: "template/meta.tmpl", size: 3295, mode: os.FileMode(420), modTime: time.Unix(1569513414, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -1005,6 +1047,7 @@ var _bindata = map[string]func() (*asset, error){ "template/dialect/gremlin/errors.tmpl": templateDialectGremlinErrorsTmpl, "template/dialect/gremlin/group.tmpl": templateDialectGremlinGroupTmpl, "template/dialect/gremlin/meta.tmpl": templateDialectGremlinMetaTmpl, + "template/dialect/gremlin/open.tmpl": templateDialectGremlinOpenTmpl, "template/dialect/gremlin/predicate.tmpl": templateDialectGremlinPredicateTmpl, "template/dialect/gremlin/query.tmpl": templateDialectGremlinQueryTmpl, "template/dialect/gremlin/select.tmpl": templateDialectGremlinSelectTmpl, @@ -1016,6 +1059,7 @@ var _bindata = map[string]func() (*asset, error){ "template/dialect/sql/errors.tmpl": templateDialectSqlErrorsTmpl, "template/dialect/sql/group.tmpl": templateDialectSqlGroupTmpl, "template/dialect/sql/meta.tmpl": templateDialectSqlMetaTmpl, + "template/dialect/sql/open.tmpl": templateDialectSqlOpenTmpl, "template/dialect/sql/predicate.tmpl": templateDialectSqlPredicateTmpl, "template/dialect/sql/query.tmpl": templateDialectSqlQueryTmpl, "template/dialect/sql/select.tmpl": templateDialectSqlSelectTmpl, @@ -1094,6 +1138,7 @@ var _bintree = &bintree{nil, map[string]*bintree{ "errors.tmpl": &bintree{templateDialectGremlinErrorsTmpl, map[string]*bintree{}}, "group.tmpl": &bintree{templateDialectGremlinGroupTmpl, map[string]*bintree{}}, "meta.tmpl": &bintree{templateDialectGremlinMetaTmpl, map[string]*bintree{}}, + "open.tmpl": &bintree{templateDialectGremlinOpenTmpl, map[string]*bintree{}}, "predicate.tmpl": &bintree{templateDialectGremlinPredicateTmpl, map[string]*bintree{}}, "query.tmpl": &bintree{templateDialectGremlinQueryTmpl, map[string]*bintree{}}, "select.tmpl": &bintree{templateDialectGremlinSelectTmpl, map[string]*bintree{}}, @@ -1107,6 +1152,7 @@ var _bintree = &bintree{nil, map[string]*bintree{ "errors.tmpl": &bintree{templateDialectSqlErrorsTmpl, map[string]*bintree{}}, "group.tmpl": &bintree{templateDialectSqlGroupTmpl, map[string]*bintree{}}, "meta.tmpl": &bintree{templateDialectSqlMetaTmpl, map[string]*bintree{}}, + "open.tmpl": &bintree{templateDialectSqlOpenTmpl, map[string]*bintree{}}, "predicate.tmpl": &bintree{templateDialectSqlPredicateTmpl, map[string]*bintree{}}, "query.tmpl": &bintree{templateDialectSqlQueryTmpl, map[string]*bintree{}}, "select.tmpl": &bintree{templateDialectSqlSelectTmpl, map[string]*bintree{}}, diff --git a/entc/gen/template/client.tmpl b/entc/gen/template/client.tmpl index b02f1fccb..d5453b235 100644 --- a/entc/gen/template/client.tmpl +++ b/entc/gen/template/client.tmpl @@ -49,6 +49,21 @@ func NewClient(opts ...Option) *Client { } } +// Open opens a connection to the database specified by the driver name and a +// driver-specific data source name, and returns a new client attached to it. +// Optional parameters can be added for configuring the client. +func Open(driverName, dataSourceName string, options ...Option) (*Client, error) { + switch driverName { + {{- range $_, $storage := $.Storage }} + case {{ join $storage.Dialects ", " }}: + {{- $tmpl := printf "dialect/%s/client/open" $storage -}} + {{- xtemplate $tmpl . -}} + {{- end }} + default: + return nil, fmt.Errorf("unsupported driver: %q", driverName) + } +} + // Tx returns a new transactional client. func (c *Client) Tx(ctx context.Context) (*Tx, error) { if _, ok := c.driver.(*txDriver); ok { @@ -88,6 +103,11 @@ func (c *Client) Debug() *Client { } } +// Close closes the database connection and prevents new queries from starting. +func (c *Client) Close() error { + return c.driver.Close() +} + {{ range $_, $n := $.Nodes -}} {{ $client := print $n.Name "Client" }} // {{ $client }} is a client for the {{ $n.Name }} schema. diff --git a/entc/gen/template/dialect/gremlin/open.tmpl b/entc/gen/template/dialect/gremlin/open.tmpl new file mode 100644 index 000000000..3ecf5552b --- /dev/null +++ b/entc/gen/template/dialect/gremlin/open.tmpl @@ -0,0 +1,19 @@ +{{/* +Copyright 2019-present Facebook Inc. All rights reserved. +This source code is licensed under the Apache 2.0 license found +in the LICENSE file in the root directory of this source tree. +*/}} + +{{ define "dialect/gremlin/client/open" }} + u, err := url.Parse(dataSourceName) + if err != nil { + return nil, err + } + c, err := gremlin.NewClient(gremlin.Config{ + Endpoint: gremlin.Endpoint{ + URL: u, + }, + }) + drv := gremlin.NewDriver(c) + return NewClient(append(options, Driver(drv))...), nil +{{ end }} \ No newline at end of file diff --git a/entc/gen/template/dialect/sql/open.tmpl b/entc/gen/template/dialect/sql/open.tmpl new file mode 100644 index 000000000..7c692ca75 --- /dev/null +++ b/entc/gen/template/dialect/sql/open.tmpl @@ -0,0 +1,13 @@ +{{/* +Copyright 2019-present Facebook Inc. All rights reserved. +This source code is licensed under the Apache 2.0 license found +in the LICENSE file in the root directory of this source tree. +*/}} + +{{ define "dialect/sql/client/open" }} + drv, err := sql.Open(driverName, dataSourceName) + if err != nil { + return nil, err + } + return NewClient(append(options, Driver(drv))...), nil +{{ end }} diff --git a/entc/integration/config/ent/client.go b/entc/integration/config/ent/client.go index eba17c44f..0c1cb7a19 100644 --- a/entc/integration/config/ent/client.go +++ b/entc/integration/config/ent/client.go @@ -16,6 +16,7 @@ import ( "github.com/facebookincubator/ent/entc/integration/config/ent/user" "github.com/facebookincubator/ent/dialect" + "github.com/facebookincubator/ent/dialect/sql" ) // Client is the client that holds all ent builders. @@ -38,6 +39,23 @@ func NewClient(opts ...Option) *Client { } } +// Open opens a connection to the database specified by the driver name and a +// driver-specific data source name, and returns a new client attached to it. +// Optional parameters can be added for configuring the client. +func Open(driverName, dataSourceName string, options ...Option) (*Client, error) { + switch driverName { + case dialect.MySQL, dialect.SQLite: + drv, err := sql.Open(driverName, dataSourceName) + if err != nil { + return nil, err + } + return NewClient(append(options, Driver(drv))...), nil + + default: + return nil, fmt.Errorf("unsupported driver: %q", driverName) + } +} + // Tx returns a new transactional client. func (c *Client) Tx(ctx context.Context) (*Tx, error) { if _, ok := c.driver.(*txDriver); ok { @@ -73,6 +91,11 @@ func (c *Client) Debug() *Client { } } +// Close closes the database connection and prevents new queries from starting. +func (c *Client) Close() error { + return c.driver.Close() +} + // UserClient is a client for the User schema. type UserClient struct { config diff --git a/entc/integration/ent/client.go b/entc/integration/ent/client.go index 7fe6f2166..cc2f90363 100644 --- a/entc/integration/ent/client.go +++ b/entc/integration/ent/client.go @@ -10,6 +10,7 @@ import ( "context" "fmt" "log" + "net/url" "github.com/facebookincubator/ent/entc/integration/ent/migrate" @@ -25,6 +26,7 @@ import ( "github.com/facebookincubator/ent/entc/integration/ent/user" "github.com/facebookincubator/ent/dialect" + "github.com/facebookincubator/ent/dialect/gremlin" "github.com/facebookincubator/ent/dialect/gremlin/graph/dsl/g" "github.com/facebookincubator/ent/dialect/sql" ) @@ -76,6 +78,36 @@ func NewClient(opts ...Option) *Client { } } +// Open opens a connection to the database specified by the driver name and a +// driver-specific data source name, and returns a new client attached to it. +// Optional parameters can be added for configuring the client. +func Open(driverName, dataSourceName string, options ...Option) (*Client, error) { + switch driverName { + case dialect.MySQL, dialect.SQLite: + drv, err := sql.Open(driverName, dataSourceName) + if err != nil { + return nil, err + } + return NewClient(append(options, Driver(drv))...), nil + + case dialect.Gremlin: + u, err := url.Parse(dataSourceName) + if err != nil { + return nil, err + } + c, err := gremlin.NewClient(gremlin.Config{ + Endpoint: gremlin.Endpoint{ + URL: u, + }, + }) + drv := gremlin.NewDriver(c) + return NewClient(append(options, Driver(drv))...), nil + + default: + return nil, fmt.Errorf("unsupported driver: %q", driverName) + } +} + // Tx returns a new transactional client. func (c *Client) Tx(ctx context.Context) (*Tx, error) { if _, ok := c.driver.(*txDriver); ok { @@ -129,6 +161,11 @@ func (c *Client) Debug() *Client { } } +// Close closes the database connection and prevents new queries from starting. +func (c *Client) Close() error { + return c.driver.Close() +} + // CardClient is a client for the Card schema. type CardClient struct { config diff --git a/entc/integration/idtype/ent/client.go b/entc/integration/idtype/ent/client.go index 567e5bc9e..abc3d017a 100644 --- a/entc/integration/idtype/ent/client.go +++ b/entc/integration/idtype/ent/client.go @@ -39,6 +39,23 @@ func NewClient(opts ...Option) *Client { } } +// Open opens a connection to the database specified by the driver name and a +// driver-specific data source name, and returns a new client attached to it. +// Optional parameters can be added for configuring the client. +func Open(driverName, dataSourceName string, options ...Option) (*Client, error) { + switch driverName { + case dialect.MySQL, dialect.SQLite: + drv, err := sql.Open(driverName, dataSourceName) + if err != nil { + return nil, err + } + return NewClient(append(options, Driver(drv))...), nil + + default: + return nil, fmt.Errorf("unsupported driver: %q", driverName) + } +} + // Tx returns a new transactional client. func (c *Client) Tx(ctx context.Context) (*Tx, error) { if _, ok := c.driver.(*txDriver); ok { @@ -74,6 +91,11 @@ func (c *Client) Debug() *Client { } } +// Close closes the database connection and prevents new queries from starting. +func (c *Client) Close() error { + return c.driver.Close() +} + // UserClient is a client for the User schema. type UserClient struct { config diff --git a/entc/integration/idtype/idtype_test.go b/entc/integration/idtype/idtype_test.go index 07f60fc63..5e8b3c06c 100644 --- a/entc/integration/idtype/idtype_test.go +++ b/entc/integration/idtype/idtype_test.go @@ -8,7 +8,6 @@ import ( "context" "testing" - "github.com/facebookincubator/ent/dialect/sql" "github.com/facebookincubator/ent/entc/integration/idtype/ent" "github.com/facebookincubator/ent/entc/integration/idtype/ent/migrate" "github.com/facebookincubator/ent/entc/integration/idtype/ent/user" @@ -17,11 +16,10 @@ import ( ) func TestIDType(t *testing.T) { - drv, err := sql.Open("sqlite3", "file:ent?mode=memory&cache=shared&_fk=1") + client, err := ent.Open("sqlite3", "file:ent?mode=memory&cache=shared&_fk=1") require.NoError(t, err) - defer drv.Close() + defer client.Close() ctx := context.Background() - client := ent.NewClient(ent.Driver(drv)) require.NoError(t, client.Schema.Create(ctx, migrate.WithGlobalUniqueID(true))) a8m := client.User.Create().SetName("a8m").SaveX(ctx) diff --git a/entc/integration/integration_test.go b/entc/integration/integration_test.go index 7c44b9308..eec47fafc 100644 --- a/entc/integration/integration_test.go +++ b/entc/integration/integration_test.go @@ -8,7 +8,6 @@ import ( "context" "fmt" "math" - "net/url" "reflect" "runtime" "sort" @@ -16,8 +15,6 @@ import ( "testing" "time" - "github.com/facebookincubator/ent/dialect/gremlin" - "github.com/facebookincubator/ent/dialect/sql" "github.com/facebookincubator/ent/entc/integration/ent" "github.com/facebookincubator/ent/entc/integration/ent/card" "github.com/facebookincubator/ent/entc/integration/ent/file" @@ -33,10 +30,9 @@ import ( ) func TestSQLite(t *testing.T) { - drv, err := sql.Open("sqlite3", "file:ent?mode=memory&cache=shared&_fk=1") + client, err := ent.Open("sqlite3", "file:ent?mode=memory&cache=shared&_fk=1") require.NoError(t, err) - defer drv.Close() - client := ent.NewClient(ent.Driver(drv)) + defer client.Close() require.NoError(t, client.Schema.Create(context.Background())) for _, tt := range tests { name := runtime.FuncForPC(reflect.ValueOf(tt).Pointer()).Name() @@ -50,10 +46,9 @@ func TestSQLite(t *testing.T) { func TestMySQL(t *testing.T) { for version, port := range map[string]int{"56": 3306, "57": 3307, "8": 3308} { t.Run(version, func(t *testing.T) { - drv, err := sql.Open("mysql", fmt.Sprintf("root:pass@tcp(localhost:%d)/test?parseTime=True", port)) + client, err := ent.Open("mysql", fmt.Sprintf("root:pass@tcp(localhost:%d)/test?parseTime=True", port)) require.NoError(t, err) - defer drv.Close() - client := ent.NewClient(ent.Driver(drv)) + defer client.Close() require.NoError(t, client.Schema.Create(context.Background())) for _, tt := range tests { name := runtime.FuncForPC(reflect.ValueOf(tt).Pointer()).Name() @@ -67,16 +62,9 @@ func TestMySQL(t *testing.T) { } func TestGremlin(t *testing.T) { - c, err := gremlin.NewClient(gremlin.Config{ - Endpoint: gremlin.Endpoint{ - URL: &url.URL{ - Scheme: "http", - Host: "localhost:8182", - }, - }, - }) + client, err := ent.Open("gremlin", "http://localhost:8182") require.NoError(t, err) - client := ent.NewClient(ent.Driver(gremlin.NewDriver(c))) + defer client.Close() // run all tests except transaction and index tests. for _, tt := range tests[2:] { name := runtime.FuncForPC(reflect.ValueOf(tt).Pointer()).Name() diff --git a/entc/integration/json/ent/client.go b/entc/integration/json/ent/client.go index 2197bd578..f26784b49 100644 --- a/entc/integration/json/ent/client.go +++ b/entc/integration/json/ent/client.go @@ -16,6 +16,7 @@ import ( "github.com/facebookincubator/ent/entc/integration/json/ent/user" "github.com/facebookincubator/ent/dialect" + "github.com/facebookincubator/ent/dialect/sql" ) // Client is the client that holds all ent builders. @@ -38,6 +39,23 @@ func NewClient(opts ...Option) *Client { } } +// Open opens a connection to the database specified by the driver name and a +// driver-specific data source name, and returns a new client attached to it. +// Optional parameters can be added for configuring the client. +func Open(driverName, dataSourceName string, options ...Option) (*Client, error) { + switch driverName { + case dialect.MySQL, dialect.SQLite: + drv, err := sql.Open(driverName, dataSourceName) + if err != nil { + return nil, err + } + return NewClient(append(options, Driver(drv))...), nil + + default: + return nil, fmt.Errorf("unsupported driver: %q", driverName) + } +} + // Tx returns a new transactional client. func (c *Client) Tx(ctx context.Context) (*Tx, error) { if _, ok := c.driver.(*txDriver); ok { @@ -73,6 +91,11 @@ func (c *Client) Debug() *Client { } } +// Close closes the database connection and prevents new queries from starting. +func (c *Client) Close() error { + return c.driver.Close() +} + // UserClient is a client for the User schema. type UserClient struct { config diff --git a/entc/integration/migrate/entv1/client.go b/entc/integration/migrate/entv1/client.go index e41737d43..e3b629b80 100644 --- a/entc/integration/migrate/entv1/client.go +++ b/entc/integration/migrate/entv1/client.go @@ -16,6 +16,7 @@ import ( "github.com/facebookincubator/ent/entc/integration/migrate/entv1/user" "github.com/facebookincubator/ent/dialect" + "github.com/facebookincubator/ent/dialect/sql" ) // Client is the client that holds all ent builders. @@ -38,6 +39,23 @@ func NewClient(opts ...Option) *Client { } } +// Open opens a connection to the database specified by the driver name and a +// driver-specific data source name, and returns a new client attached to it. +// Optional parameters can be added for configuring the client. +func Open(driverName, dataSourceName string, options ...Option) (*Client, error) { + switch driverName { + case dialect.MySQL, dialect.SQLite: + drv, err := sql.Open(driverName, dataSourceName) + if err != nil { + return nil, err + } + return NewClient(append(options, Driver(drv))...), nil + + default: + return nil, fmt.Errorf("unsupported driver: %q", driverName) + } +} + // Tx returns a new transactional client. func (c *Client) Tx(ctx context.Context) (*Tx, error) { if _, ok := c.driver.(*txDriver); ok { @@ -73,6 +91,11 @@ func (c *Client) Debug() *Client { } } +// Close closes the database connection and prevents new queries from starting. +func (c *Client) Close() error { + return c.driver.Close() +} + // UserClient is a client for the User schema. type UserClient struct { config diff --git a/entc/integration/migrate/entv2/client.go b/entc/integration/migrate/entv2/client.go index d8803a1d0..95f2ef4f8 100644 --- a/entc/integration/migrate/entv2/client.go +++ b/entc/integration/migrate/entv2/client.go @@ -18,6 +18,7 @@ import ( "github.com/facebookincubator/ent/entc/integration/migrate/entv2/user" "github.com/facebookincubator/ent/dialect" + "github.com/facebookincubator/ent/dialect/sql" ) // Client is the client that holds all ent builders. @@ -46,6 +47,23 @@ func NewClient(opts ...Option) *Client { } } +// Open opens a connection to the database specified by the driver name and a +// driver-specific data source name, and returns a new client attached to it. +// Optional parameters can be added for configuring the client. +func Open(driverName, dataSourceName string, options ...Option) (*Client, error) { + switch driverName { + case dialect.MySQL, dialect.SQLite: + drv, err := sql.Open(driverName, dataSourceName) + if err != nil { + return nil, err + } + return NewClient(append(options, Driver(drv))...), nil + + default: + return nil, fmt.Errorf("unsupported driver: %q", driverName) + } +} + // Tx returns a new transactional client. func (c *Client) Tx(ctx context.Context) (*Tx, error) { if _, ok := c.driver.(*txDriver); ok { @@ -85,6 +103,11 @@ func (c *Client) Debug() *Client { } } +// Close closes the database connection and prevents new queries from starting. +func (c *Client) Close() error { + return c.driver.Close() +} + // GroupClient is a client for the Group schema. type GroupClient struct { config diff --git a/entc/integration/template/ent/client.go b/entc/integration/template/ent/client.go index ed09b9fb8..8f1098548 100644 --- a/entc/integration/template/ent/client.go +++ b/entc/integration/template/ent/client.go @@ -47,6 +47,23 @@ func NewClient(opts ...Option) *Client { } } +// Open opens a connection to the database specified by the driver name and a +// driver-specific data source name, and returns a new client attached to it. +// Optional parameters can be added for configuring the client. +func Open(driverName, dataSourceName string, options ...Option) (*Client, error) { + switch driverName { + case dialect.MySQL, dialect.SQLite: + drv, err := sql.Open(driverName, dataSourceName) + if err != nil { + return nil, err + } + return NewClient(append(options, Driver(drv))...), nil + + default: + return nil, fmt.Errorf("unsupported driver: %q", driverName) + } +} + // Tx returns a new transactional client. func (c *Client) Tx(ctx context.Context) (*Tx, error) { if _, ok := c.driver.(*txDriver); ok { @@ -86,6 +103,11 @@ func (c *Client) Debug() *Client { } } +// Close closes the database connection and prevents new queries from starting. +func (c *Client) Close() error { + return c.driver.Close() +} + // GroupClient is a client for the Group schema. type GroupClient struct { config diff --git a/entc/integration/template/template_test.go b/entc/integration/template/template_test.go index 679a8f6dc..6cf9dce29 100644 --- a/entc/integration/template/template_test.go +++ b/entc/integration/template/template_test.go @@ -8,7 +8,6 @@ import ( "context" "testing" - "github.com/facebookincubator/ent/dialect/sql" "github.com/facebookincubator/ent/entc/integration/template/ent" "github.com/facebookincubator/ent/entc/integration/template/ent/migrate" @@ -17,11 +16,10 @@ import ( ) func TestCustomTemplate(t *testing.T) { - drv, err := sql.Open("sqlite3", "file:ent?mode=memory&cache=shared&_fk=1") + client, err := ent.Open("sqlite3", "file:ent?mode=memory&cache=shared&_fk=1") require.NoError(t, err) - defer drv.Close() + defer client.Close() ctx := context.Background() - client := ent.NewClient(ent.Driver(drv)) require.NoError(t, client.Schema.Create(ctx, migrate.WithGlobalUniqueID(true))) p := client.Pet.Create().SetAge(1).SaveX(ctx) diff --git a/entc/load/internal/bindata.go b/entc/load/internal/bindata.go index b8d7c7cb4..9ba073d2e 100644 --- a/entc/load/internal/bindata.go +++ b/entc/load/internal/bindata.go @@ -113,7 +113,7 @@ func schemaGo() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "schema.go", size: 7149, mode: os.FileMode(420), modTime: time.Unix(1569499336, 0)} + info := bindataFileInfo{name: "schema.go", size: 7149, mode: os.FileMode(420), modTime: time.Unix(1569513414, 0)} a := &asset{bytes: bytes, info: info} return a, nil } diff --git a/examples/edgeindex/edgeindex.go b/examples/edgeindex/edgeindex.go index 133263abb..e4052009a 100644 --- a/examples/edgeindex/edgeindex.go +++ b/examples/edgeindex/edgeindex.go @@ -11,17 +11,15 @@ import ( "github.com/facebookincubator/ent/examples/edgeindex/ent" - "github.com/facebookincubator/ent/dialect/sql" _ "github.com/mattn/go-sqlite3" ) func main() { - db, err := sql.Open("sqlite3", "file:o2o2types?mode=memory&cache=shared&_fk=1") + client, err := ent.Open("sqlite3", "file:ent?mode=memory&cache=shared&_fk=1") if err != nil { log.Fatalf("failed opening connection to sqlite: %v", err) } - defer db.Close() - client := ent.NewClient(ent.Driver(db)) + defer client.Close() ctx := context.Background() // run the auto migration tool. if err := client.Schema.Create(ctx); err != nil { diff --git a/examples/edgeindex/ent/client.go b/examples/edgeindex/ent/client.go index 9d14990de..d416148f9 100644 --- a/examples/edgeindex/ent/client.go +++ b/examples/edgeindex/ent/client.go @@ -43,6 +43,23 @@ func NewClient(opts ...Option) *Client { } } +// Open opens a connection to the database specified by the driver name and a +// driver-specific data source name, and returns a new client attached to it. +// Optional parameters can be added for configuring the client. +func Open(driverName, dataSourceName string, options ...Option) (*Client, error) { + switch driverName { + case dialect.MySQL, dialect.SQLite: + drv, err := sql.Open(driverName, dataSourceName) + if err != nil { + return nil, err + } + return NewClient(append(options, Driver(drv))...), nil + + default: + return nil, fmt.Errorf("unsupported driver: %q", driverName) + } +} + // Tx returns a new transactional client. func (c *Client) Tx(ctx context.Context) (*Tx, error) { if _, ok := c.driver.(*txDriver); ok { @@ -80,6 +97,11 @@ func (c *Client) Debug() *Client { } } +// Close closes the database connection and prevents new queries from starting. +func (c *Client) Close() error { + return c.driver.Close() +} + // CityClient is a client for the City schema. type CityClient struct { config diff --git a/examples/m2m2types/ent/client.go b/examples/m2m2types/ent/client.go index 907c59ec2..c7968f1a4 100644 --- a/examples/m2m2types/ent/client.go +++ b/examples/m2m2types/ent/client.go @@ -43,6 +43,23 @@ func NewClient(opts ...Option) *Client { } } +// Open opens a connection to the database specified by the driver name and a +// driver-specific data source name, and returns a new client attached to it. +// Optional parameters can be added for configuring the client. +func Open(driverName, dataSourceName string, options ...Option) (*Client, error) { + switch driverName { + case dialect.MySQL, dialect.SQLite: + drv, err := sql.Open(driverName, dataSourceName) + if err != nil { + return nil, err + } + return NewClient(append(options, Driver(drv))...), nil + + default: + return nil, fmt.Errorf("unsupported driver: %q", driverName) + } +} + // Tx returns a new transactional client. func (c *Client) Tx(ctx context.Context) (*Tx, error) { if _, ok := c.driver.(*txDriver); ok { @@ -80,6 +97,11 @@ func (c *Client) Debug() *Client { } } +// Close closes the database connection and prevents new queries from starting. +func (c *Client) Close() error { + return c.driver.Close() +} + // GroupClient is a client for the Group schema. type GroupClient struct { config diff --git a/examples/m2m2types/m2m2types.go b/examples/m2m2types/m2m2types.go index 8a251a271..47b4f4d41 100644 --- a/examples/m2m2types/m2m2types.go +++ b/examples/m2m2types/m2m2types.go @@ -14,17 +14,15 @@ import ( "github.com/facebookincubator/ent/examples/m2m2types/ent" "github.com/facebookincubator/ent/examples/m2m2types/ent/group" - "github.com/facebookincubator/ent/dialect/sql" _ "github.com/mattn/go-sqlite3" ) func main() { - db, err := sql.Open("sqlite3", "file:o2o2types?mode=memory&cache=shared&_fk=1") + client, err := ent.Open("sqlite3", "file:ent?mode=memory&cache=shared&_fk=1") if err != nil { log.Fatalf("failed opening connection to sqlite: %v", err) } - defer db.Close() - client := ent.NewClient(ent.Driver(db)) + defer client.Close() ctx := context.Background() // run the auto migration tool. if err := client.Schema.Create(ctx); err != nil { diff --git a/examples/m2mbidi/ent/client.go b/examples/m2mbidi/ent/client.go index aa66f4a23..ce98b98ae 100644 --- a/examples/m2mbidi/ent/client.go +++ b/examples/m2mbidi/ent/client.go @@ -39,6 +39,23 @@ func NewClient(opts ...Option) *Client { } } +// Open opens a connection to the database specified by the driver name and a +// driver-specific data source name, and returns a new client attached to it. +// Optional parameters can be added for configuring the client. +func Open(driverName, dataSourceName string, options ...Option) (*Client, error) { + switch driverName { + case dialect.MySQL, dialect.SQLite: + drv, err := sql.Open(driverName, dataSourceName) + if err != nil { + return nil, err + } + return NewClient(append(options, Driver(drv))...), nil + + default: + return nil, fmt.Errorf("unsupported driver: %q", driverName) + } +} + // Tx returns a new transactional client. func (c *Client) Tx(ctx context.Context) (*Tx, error) { if _, ok := c.driver.(*txDriver); ok { @@ -74,6 +91,11 @@ func (c *Client) Debug() *Client { } } +// Close closes the database connection and prevents new queries from starting. +func (c *Client) Close() error { + return c.driver.Close() +} + // UserClient is a client for the User schema. type UserClient struct { config diff --git a/examples/m2mbidi/m2mbidi.go b/examples/m2mbidi/m2mbidi.go index c6bdf0500..61a9e1610 100644 --- a/examples/m2mbidi/m2mbidi.go +++ b/examples/m2mbidi/m2mbidi.go @@ -12,17 +12,15 @@ import ( "github.com/facebookincubator/ent/examples/m2mbidi/ent" "github.com/facebookincubator/ent/examples/m2mbidi/ent/user" - "github.com/facebookincubator/ent/dialect/sql" _ "github.com/mattn/go-sqlite3" ) func main() { - db, err := sql.Open("sqlite3", "file:o2o2types?mode=memory&cache=shared&_fk=1") + client, err := ent.Open("sqlite3", "file:ent?mode=memory&cache=shared&_fk=1") if err != nil { log.Fatalf("failed opening connection to sqlite: %v", err) } - defer db.Close() - client := ent.NewClient(ent.Driver(db)) + defer client.Close() ctx := context.Background() // run the auto migration tool. if err := client.Schema.Create(ctx); err != nil { diff --git a/examples/m2mrecur/ent/client.go b/examples/m2mrecur/ent/client.go index d2d8032b5..a603c4fed 100644 --- a/examples/m2mrecur/ent/client.go +++ b/examples/m2mrecur/ent/client.go @@ -39,6 +39,23 @@ func NewClient(opts ...Option) *Client { } } +// Open opens a connection to the database specified by the driver name and a +// driver-specific data source name, and returns a new client attached to it. +// Optional parameters can be added for configuring the client. +func Open(driverName, dataSourceName string, options ...Option) (*Client, error) { + switch driverName { + case dialect.MySQL, dialect.SQLite: + drv, err := sql.Open(driverName, dataSourceName) + if err != nil { + return nil, err + } + return NewClient(append(options, Driver(drv))...), nil + + default: + return nil, fmt.Errorf("unsupported driver: %q", driverName) + } +} + // Tx returns a new transactional client. func (c *Client) Tx(ctx context.Context) (*Tx, error) { if _, ok := c.driver.(*txDriver); ok { @@ -74,6 +91,11 @@ func (c *Client) Debug() *Client { } } +// Close closes the database connection and prevents new queries from starting. +func (c *Client) Close() error { + return c.driver.Close() +} + // UserClient is a client for the User schema. type UserClient struct { config diff --git a/examples/m2mrecur/m2mrecur.go b/examples/m2mrecur/m2mrecur.go index 57f1ffa4e..9a9167b7b 100644 --- a/examples/m2mrecur/m2mrecur.go +++ b/examples/m2mrecur/m2mrecur.go @@ -13,17 +13,15 @@ import ( "github.com/facebookincubator/ent/examples/m2mrecur/ent" - "github.com/facebookincubator/ent/dialect/sql" _ "github.com/mattn/go-sqlite3" ) func main() { - db, err := sql.Open("sqlite3", "file:o2o2types?mode=memory&cache=shared&_fk=1") + client, err := ent.Open("sqlite3", "file:ent?mode=memory&cache=shared&_fk=1") if err != nil { log.Fatalf("failed opening connection to sqlite: %v", err) } - defer db.Close() - client := ent.NewClient(ent.Driver(db)) + defer client.Close() ctx := context.Background() // run the auto migration tool. if err := client.Schema.Create(ctx); err != nil { diff --git a/examples/o2m2types/ent/client.go b/examples/o2m2types/ent/client.go index 8befb71b6..188e1b84a 100644 --- a/examples/o2m2types/ent/client.go +++ b/examples/o2m2types/ent/client.go @@ -43,6 +43,23 @@ func NewClient(opts ...Option) *Client { } } +// Open opens a connection to the database specified by the driver name and a +// driver-specific data source name, and returns a new client attached to it. +// Optional parameters can be added for configuring the client. +func Open(driverName, dataSourceName string, options ...Option) (*Client, error) { + switch driverName { + case dialect.MySQL, dialect.SQLite: + drv, err := sql.Open(driverName, dataSourceName) + if err != nil { + return nil, err + } + return NewClient(append(options, Driver(drv))...), nil + + default: + return nil, fmt.Errorf("unsupported driver: %q", driverName) + } +} + // Tx returns a new transactional client. func (c *Client) Tx(ctx context.Context) (*Tx, error) { if _, ok := c.driver.(*txDriver); ok { @@ -80,6 +97,11 @@ func (c *Client) Debug() *Client { } } +// Close closes the database connection and prevents new queries from starting. +func (c *Client) Close() error { + return c.driver.Close() +} + // PetClient is a client for the Pet schema. type PetClient struct { config diff --git a/examples/o2m2types/o2m2types.go b/examples/o2m2types/o2m2types.go index b739be1a2..5abea308e 100644 --- a/examples/o2m2types/o2m2types.go +++ b/examples/o2m2types/o2m2types.go @@ -11,17 +11,15 @@ import ( "github.com/facebookincubator/ent/examples/o2m2types/ent" - "github.com/facebookincubator/ent/dialect/sql" _ "github.com/mattn/go-sqlite3" ) func main() { - db, err := sql.Open("sqlite3", "file:o2o2types?mode=memory&cache=shared&_fk=1") + client, err := ent.Open("sqlite3", "file:ent?mode=memory&cache=shared&_fk=1") if err != nil { log.Fatalf("failed opening connection to sqlite: %v", err) } - defer db.Close() - client := ent.NewClient(ent.Driver(db)) + defer client.Close() ctx := context.Background() // run the auto migration tool. if err := client.Schema.Create(ctx); err != nil { diff --git a/examples/o2mrecur/ent/client.go b/examples/o2mrecur/ent/client.go index ab4593f1b..4c3ffd531 100644 --- a/examples/o2mrecur/ent/client.go +++ b/examples/o2mrecur/ent/client.go @@ -39,6 +39,23 @@ func NewClient(opts ...Option) *Client { } } +// Open opens a connection to the database specified by the driver name and a +// driver-specific data source name, and returns a new client attached to it. +// Optional parameters can be added for configuring the client. +func Open(driverName, dataSourceName string, options ...Option) (*Client, error) { + switch driverName { + case dialect.MySQL, dialect.SQLite: + drv, err := sql.Open(driverName, dataSourceName) + if err != nil { + return nil, err + } + return NewClient(append(options, Driver(drv))...), nil + + default: + return nil, fmt.Errorf("unsupported driver: %q", driverName) + } +} + // Tx returns a new transactional client. func (c *Client) Tx(ctx context.Context) (*Tx, error) { if _, ok := c.driver.(*txDriver); ok { @@ -74,6 +91,11 @@ func (c *Client) Debug() *Client { } } +// Close closes the database connection and prevents new queries from starting. +func (c *Client) Close() error { + return c.driver.Close() +} + // NodeClient is a client for the Node schema. type NodeClient struct { config diff --git a/examples/o2mrecur/o2mrecur.go b/examples/o2mrecur/o2mrecur.go index 320d135b2..170766ffe 100644 --- a/examples/o2mrecur/o2mrecur.go +++ b/examples/o2mrecur/o2mrecur.go @@ -12,17 +12,15 @@ import ( "github.com/facebookincubator/ent/examples/o2mrecur/ent" "github.com/facebookincubator/ent/examples/o2mrecur/ent/node" - "github.com/facebookincubator/ent/dialect/sql" _ "github.com/mattn/go-sqlite3" ) func main() { - db, err := sql.Open("sqlite3", "file:o2o2types?mode=memory&cache=shared&_fk=1") + client, err := ent.Open("sqlite3", "file:ent?mode=memory&cache=shared&_fk=1") if err != nil { log.Fatalf("failed opening connection to sqlite: %v", err) } - defer db.Close() - client := ent.NewClient(ent.Driver(db)) + defer client.Close() ctx := context.Background() // run the auto migration tool. if err := client.Schema.Create(ctx); err != nil { diff --git a/examples/o2o2types/ent/client.go b/examples/o2o2types/ent/client.go index 2f0d53a87..532660dbe 100644 --- a/examples/o2o2types/ent/client.go +++ b/examples/o2o2types/ent/client.go @@ -43,6 +43,23 @@ func NewClient(opts ...Option) *Client { } } +// Open opens a connection to the database specified by the driver name and a +// driver-specific data source name, and returns a new client attached to it. +// Optional parameters can be added for configuring the client. +func Open(driverName, dataSourceName string, options ...Option) (*Client, error) { + switch driverName { + case dialect.MySQL, dialect.SQLite: + drv, err := sql.Open(driverName, dataSourceName) + if err != nil { + return nil, err + } + return NewClient(append(options, Driver(drv))...), nil + + default: + return nil, fmt.Errorf("unsupported driver: %q", driverName) + } +} + // Tx returns a new transactional client. func (c *Client) Tx(ctx context.Context) (*Tx, error) { if _, ok := c.driver.(*txDriver); ok { @@ -80,6 +97,11 @@ func (c *Client) Debug() *Client { } } +// Close closes the database connection and prevents new queries from starting. +func (c *Client) Close() error { + return c.driver.Close() +} + // CardClient is a client for the Card schema. type CardClient struct { config diff --git a/examples/o2o2types/o2o2types.go b/examples/o2o2types/o2o2types.go index b5f050fb7..30d84e775 100644 --- a/examples/o2o2types/o2o2types.go +++ b/examples/o2o2types/o2o2types.go @@ -12,17 +12,15 @@ import ( "github.com/facebookincubator/ent/examples/o2o2types/ent" - "github.com/facebookincubator/ent/dialect/sql" _ "github.com/mattn/go-sqlite3" ) func main() { - db, err := sql.Open("sqlite3", "file:o2o2types?mode=memory&cache=shared&_fk=1") + client, err := ent.Open("sqlite3", "file:ent?mode=memory&cache=shared&_fk=1") if err != nil { log.Fatalf("failed opening connection to sqlite: %v", err) } - defer db.Close() - client := ent.NewClient(ent.Driver(db)) + defer client.Close() ctx := context.Background() // run the auto migration tool. if err := client.Schema.Create(ctx); err != nil { diff --git a/examples/o2obidi/ent/client.go b/examples/o2obidi/ent/client.go index a2f9c385f..8097076eb 100644 --- a/examples/o2obidi/ent/client.go +++ b/examples/o2obidi/ent/client.go @@ -39,6 +39,23 @@ func NewClient(opts ...Option) *Client { } } +// Open opens a connection to the database specified by the driver name and a +// driver-specific data source name, and returns a new client attached to it. +// Optional parameters can be added for configuring the client. +func Open(driverName, dataSourceName string, options ...Option) (*Client, error) { + switch driverName { + case dialect.MySQL, dialect.SQLite: + drv, err := sql.Open(driverName, dataSourceName) + if err != nil { + return nil, err + } + return NewClient(append(options, Driver(drv))...), nil + + default: + return nil, fmt.Errorf("unsupported driver: %q", driverName) + } +} + // Tx returns a new transactional client. func (c *Client) Tx(ctx context.Context) (*Tx, error) { if _, ok := c.driver.(*txDriver); ok { @@ -74,6 +91,11 @@ func (c *Client) Debug() *Client { } } +// Close closes the database connection and prevents new queries from starting. +func (c *Client) Close() error { + return c.driver.Close() +} + // UserClient is a client for the User schema. type UserClient struct { config diff --git a/examples/o2obidi/o2obidi.go b/examples/o2obidi/o2obidi.go index 877733f36..d79728459 100644 --- a/examples/o2obidi/o2obidi.go +++ b/examples/o2obidi/o2obidi.go @@ -12,17 +12,15 @@ import ( "github.com/facebookincubator/ent/examples/o2obidi/ent" "github.com/facebookincubator/ent/examples/o2obidi/ent/user" - "github.com/facebookincubator/ent/dialect/sql" _ "github.com/mattn/go-sqlite3" ) func main() { - db, err := sql.Open("sqlite3", "file:o2o2types?mode=memory&cache=shared&_fk=1") + client, err := ent.Open("sqlite3", "file:ent?mode=memory&cache=shared&_fk=1") if err != nil { log.Fatalf("failed opening connection to sqlite: %v", err) } - defer db.Close() - client := ent.NewClient(ent.Driver(db)) + defer client.Close() ctx := context.Background() // run the auto migration tool. if err := client.Schema.Create(ctx); err != nil { diff --git a/examples/o2orecur/ent/client.go b/examples/o2orecur/ent/client.go index 1ed5680ac..7ebd8e857 100644 --- a/examples/o2orecur/ent/client.go +++ b/examples/o2orecur/ent/client.go @@ -39,6 +39,23 @@ func NewClient(opts ...Option) *Client { } } +// Open opens a connection to the database specified by the driver name and a +// driver-specific data source name, and returns a new client attached to it. +// Optional parameters can be added for configuring the client. +func Open(driverName, dataSourceName string, options ...Option) (*Client, error) { + switch driverName { + case dialect.MySQL, dialect.SQLite: + drv, err := sql.Open(driverName, dataSourceName) + if err != nil { + return nil, err + } + return NewClient(append(options, Driver(drv))...), nil + + default: + return nil, fmt.Errorf("unsupported driver: %q", driverName) + } +} + // Tx returns a new transactional client. func (c *Client) Tx(ctx context.Context) (*Tx, error) { if _, ok := c.driver.(*txDriver); ok { @@ -74,6 +91,11 @@ func (c *Client) Debug() *Client { } } +// Close closes the database connection and prevents new queries from starting. +func (c *Client) Close() error { + return c.driver.Close() +} + // NodeClient is a client for the Node schema. type NodeClient struct { config diff --git a/examples/o2orecur/o2orecur.go b/examples/o2orecur/o2orecur.go index b6a8a9f16..1484b5e4f 100644 --- a/examples/o2orecur/o2orecur.go +++ b/examples/o2orecur/o2orecur.go @@ -12,17 +12,15 @@ import ( "github.com/facebookincubator/ent/examples/o2orecur/ent" "github.com/facebookincubator/ent/examples/o2orecur/ent/node" - "github.com/facebookincubator/ent/dialect/sql" _ "github.com/mattn/go-sqlite3" ) func main() { - db, err := sql.Open("sqlite3", "file:o2o2types?mode=memory&cache=shared&_fk=1") + client, err := ent.Open("sqlite3", "file:ent?mode=memory&cache=shared&_fk=1") if err != nil { log.Fatalf("failed opening connection to sqlite: %v", err) } - defer db.Close() - client := ent.NewClient(ent.Driver(db)) + defer client.Close() ctx := context.Background() // run the auto migration tool. if err := client.Schema.Create(ctx); err != nil { diff --git a/examples/traversal/ent/client.go b/examples/traversal/ent/client.go index 307d85a44..1c48a9e94 100644 --- a/examples/traversal/ent/client.go +++ b/examples/traversal/ent/client.go @@ -47,6 +47,23 @@ func NewClient(opts ...Option) *Client { } } +// Open opens a connection to the database specified by the driver name and a +// driver-specific data source name, and returns a new client attached to it. +// Optional parameters can be added for configuring the client. +func Open(driverName, dataSourceName string, options ...Option) (*Client, error) { + switch driverName { + case dialect.MySQL, dialect.SQLite: + drv, err := sql.Open(driverName, dataSourceName) + if err != nil { + return nil, err + } + return NewClient(append(options, Driver(drv))...), nil + + default: + return nil, fmt.Errorf("unsupported driver: %q", driverName) + } +} + // Tx returns a new transactional client. func (c *Client) Tx(ctx context.Context) (*Tx, error) { if _, ok := c.driver.(*txDriver); ok { @@ -86,6 +103,11 @@ func (c *Client) Debug() *Client { } } +// Close closes the database connection and prevents new queries from starting. +func (c *Client) Close() error { + return c.driver.Close() +} + // GroupClient is a client for the Group schema. type GroupClient struct { config diff --git a/examples/traversal/traversal.go b/examples/traversal/traversal.go index c8b3717f8..3f1681da7 100644 --- a/examples/traversal/traversal.go +++ b/examples/traversal/traversal.go @@ -17,17 +17,15 @@ import ( "github.com/facebookincubator/ent/examples/traversal/ent" "github.com/facebookincubator/ent/examples/traversal/ent/group" - "github.com/facebookincubator/ent/dialect/sql" _ "github.com/mattn/go-sqlite3" ) func main() { - db, err := sql.Open("sqlite3", "file:o2o2types?mode=memory&cache=shared&_fk=1") + client, err := ent.Open("sqlite3", "file:ent?mode=memory&cache=shared&_fk=1") if err != nil { log.Fatalf("failed opening connection to sqlite: %v", err) } - defer db.Close() - client := ent.NewClient(ent.Driver(db)) + defer client.Close() ctx := context.Background() // run the auto migration tool. if err := client.Schema.Create(ctx); err != nil {