From dc542e46aeb77c0312d1f8ba6218c6192e8f9845 Mon Sep 17 00:00:00 2001 From: Ariel Mashraki Date: Wed, 28 Aug 2019 07:22:25 -0700 Subject: [PATCH] entc/gen: add debug option to client Summary: It's possible to execute: ``` client.Debug().T.Query().AllX(ctx) `` Reviewed By: alexsn Differential Revision: D17092159 fbshipit-source-id: 6d1c56e8e45cfd8e36b2700c9d450f2bd5f66a71 --- dialect/dialect.go | 2 +- entc/gen/bindata.go | 4 ++-- entc/gen/template/client.tmpl | 21 ++++++++++++++++++ entc/integration/ent/client.go | 28 ++++++++++++++++++++++++ entc/integration/integration_test.go | 19 +++------------- entc/integration/migrate/entv1/client.go | 21 ++++++++++++++++++ entc/integration/migrate/entv2/client.go | 23 +++++++++++++++++++ entc/integration/migrate/migrate_test.go | 2 +- examples/edgeindex/ent/client.go | 21 ++++++++++++++++++ examples/m2m2types/ent/client.go | 21 ++++++++++++++++++ examples/m2mbidi/ent/client.go | 20 +++++++++++++++++ examples/m2mrecur/ent/client.go | 20 +++++++++++++++++ examples/o2m2types/ent/client.go | 21 ++++++++++++++++++ examples/o2mrecur/ent/client.go | 20 +++++++++++++++++ examples/o2o2types/ent/client.go | 21 ++++++++++++++++++ examples/o2obidi/ent/client.go | 20 +++++++++++++++++ examples/o2orecur/ent/client.go | 20 +++++++++++++++++ 17 files changed, 284 insertions(+), 20 deletions(-) diff --git a/dialect/dialect.go b/dialect/dialect.go index 312a4d869..922adc464 100644 --- a/dialect/dialect.go +++ b/dialect/dialect.go @@ -17,7 +17,7 @@ import ( const ( MySQL = "mysql" SQLite = "sqlite3" - Neptune = "neptune" + Gremlin = "gremlin" ) // ExecQuerier wraps the 2 database operations. diff --git a/entc/gen/bindata.go b/entc/gen/bindata.go index 0a9bc61a9..33396d5f8 100644 --- a/entc/gen/bindata.go +++ b/entc/gen/bindata.go @@ -224,7 +224,7 @@ func templateBuilderUpdateTmpl() (*asset, error) { return a, nil } -var _templateClientTmpl = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xac\x57\x4d\x73\xdb\x36\x10\x3d\x93\xbf\x62\x8b\x51\x3a\xa4\x87\x06\xdb\x1e\xd5\xf1\xc9\xca\xc1\x17\x3b\x6d\xdc\xe9\x31\x03\x83\x4b\x0a\x35\x05\x30\x20\x14\x29\xc3\xea\xbf\x77\xf0\xc1\x2f\x4b\xb2\x15\x4f\x4f\x12\xb1\xc0\xdb\xb7\x6f\x17\x0b\xa0\xeb\xa0\xc0\x52\x48\x04\xc2\x6b\x81\xd2\x10\x38\x1c\xe2\xb8\xeb\x60\xd1\x3c\x57\xb0\xbc\x81\x27\xd6\x22\x2c\xe8\xad\x92\xa5\xa8\xe8\x27\xc6\x9f\x59\x85\x76\x52\xd7\x81\xc1\x4d\x53\x33\x83\x40\xd6\xc8\x0a\xd4\x04\x16\x6e\xb9\xd8\x34\x4a\x1b\x48\xe2\x88\xd4\xaa\x22\x71\x1c\x11\x8b\x78\x0c\x92\x6f\x44\xa5\x99\x41\x12\x47\x5d\x07\x9a\xc9\x0a\x61\xf1\x25\x83\x85\xb4\xae\x17\xf4\x5e\x15\xd8\x5a\xc8\xc8\x23\xc8\x13\x10\x7e\x7c\x1c\x70\x58\xd7\x80\xb2\x70\x5c\x22\x52\x09\xb3\xde\x3e\x51\xae\x36\x79\xc9\x38\x3e\x29\xf5\x2c\x24\xdf\x3e\x31\xa3\x74\x8e\xd2\xe4\x85\x60\x35\x72\x73\x44\xa2\x35\x4a\x5b\x4c\x47\xe5\x73\xf8\xb8\x76\x6c\xe6\x13\x43\xbc\x76\x5e\x58\x43\xef\xdc\x50\x1b\xa6\x7b\xf6\x61\x9a\xa3\x68\x11\x2c\x45\x67\x9f\xfc\x4f\xe3\x38\xcf\xe1\xd6\xe5\x02\x44\x0b\x66\x8d\xe0\x33\x03\x66\xcd\x0c\xac\x55\x5d\xb4\xc0\xea\x1a\xec\xd0\xd3\x56\xd4\x05\xea\x96\xc6\xe6\x7b\x83\xfd\xb2\xd6\xe8\x2d\x37\xd0\xc5\x11\x77\x6a\xc5\x51\x9e\xc3\x67\xbe\xc6\x0d\x7b\x01\x59\x2a\x0d\x5c\x23\x33\x42\x56\x19\xf8\x64\x08\x59\x01\x93\x05\x14\x5a\x35\x8d\xfd\x68\xdd\x4a\x1a\x47\x01\xe2\x2a\x24\x8d\xfa\xef\x57\x53\xe7\xc3\xcf\x73\xf0\x59\xba\x67\x1b\x9b\xa2\x13\x2c\x84\x34\xa8\x19\x77\xde\x77\xc2\xac\x9d\x7d\xbe\x68\x0c\xd6\xa9\x37\xb1\x5c\xcd\x3e\xbd\x0a\x83\xaa\x87\x43\x7c\x70\xa2\xde\xe3\x2e\x08\xe4\x42\xc6\x16\x18\x48\xdc\xf5\x2c\xbc\x56\x5b\x8d\xc5\x48\xa0\x12\xdf\x50\x82\x6a\x8c\x50\xb2\xa5\x71\xb9\x95\x7c\x84\x49\x54\x63\x5a\xa0\x94\x3e\x38\x7b\x0a\x57\x01\xde\x0a\x6f\x45\xf0\x88\x5d\xad\xaa\x25\xd4\xaa\xa2\x9f\xb4\x90\xa6\x96\x87\x38\xe2\x34\x60\x3a\x0c\x4a\x69\x1a\x47\x1a\xcd\x56\x4b\xf8\xd9\x83\x74\x71\x14\xb2\xb7\x04\x9e\xc5\x51\x10\x7f\x09\xbd\xf8\xf7\xb8\xf3\x43\x09\xa7\x85\x16\xdf\x50\xa7\xd9\x51\x61\x9e\xc8\xc5\x5c\xba\xa5\x0d\xe7\x84\x7a\x09\xef\xd1\x86\x22\xed\x65\x7c\xdc\x83\xa7\xda\xeb\x67\x34\x93\xad\x4d\x9d\x92\xac\x0e\x6a\x06\xad\x12\xde\x8b\x92\xc2\xe3\x3e\xe1\x66\x6f\x45\x31\xb8\x37\x76\x23\xdb\xdf\x14\x92\xab\xc7\x7d\x06\xa8\xb5\xd2\xa9\x95\x4e\x94\xf0\x25\x03\xf5\xec\x14\x0c\xa1\xd1\xe4\xca\xec\x57\x3e\xca\xdf\xad\xcd\xca\x13\x04\x93\xa2\xce\xa0\xdc\x18\xfa\xd1\x42\x94\x09\xe9\x9b\x97\x8d\x8e\x33\x29\x95\xdd\x11\x4c\x1b\x60\x53\xaa\x2e\xc9\x42\xce\x07\x49\x6a\xe3\x8c\x8c\x27\x64\x19\x48\xdc\x79\xe2\xd9\x40\x26\x75\x1c\xad\xfd\xa7\x1b\xeb\xfd\x62\x32\x8e\x85\xdb\x5e\x53\x9f\x4b\xf8\xf0\x8d\x38\x7f\xde\x39\x2f\xab\x49\xf1\x78\x97\x4b\xb0\x04\x5c\x21\x71\x5a\xab\x2a\x83\x02\x9f\xb6\xee\xcb\xfd\x39\x8c\xe5\xf3\xb8\x9f\x95\x4e\x59\xfd\xaf\x55\x51\x56\xc7\x75\x91\xd9\xa8\x63\x7f\x6a\xbc\xe6\xc5\x02\x86\xbd\xb6\xbc\x81\xc6\x6e\x86\xc1\x03\xb9\x1d\x4f\x9f\xd0\x2d\xc2\x54\xdf\x2d\xd8\xb4\x57\x1c\xb7\x86\xbe\x45\xb9\x2e\x38\x5f\x7c\xd4\x0c\xc3\xf1\xa6\xd1\xed\xd1\x85\xa4\x7f\x22\x47\x2b\x32\x1c\x0e\x5d\x07\x36\xb5\x5f\xbd\x99\x70\xe2\xc7\xdc\x57\xa0\x5c\x02\xf9\x40\x7f\x6b\xc9\xe0\xfe\x5f\xa8\xd5\xae\x5f\xdd\x9f\x3a\xbe\xdd\xcc\x99\x8c\xbb\xe6\xd5\x58\x4a\xad\x36\x93\xe6\xe3\x59\x8f\xbd\x67\x86\x99\xf0\x60\x4f\x7d\x0f\x1c\x9d\x75\x63\x45\xcc\x0c\xdd\x50\x19\xfd\x7e\xbe\x75\xcd\x70\xca\xce\x0f\x84\x76\xeb\x58\xce\x18\x4e\xf6\xf6\x0c\x3a\x0d\x50\x49\xfa\xb2\x21\x7b\xc0\x17\x94\x5e\x98\x47\x62\xd4\xff\xeb\xf9\xfd\xd5\x14\x33\x7e\x12\xb6\x7e\xe4\x1d\x04\x3d\xd6\x11\xc1\xe0\xe2\x1c\x41\x6f\x7e\x83\xe0\x83\x7c\x8b\xe3\x98\x53\x94\x46\x98\xef\x6f\xd1\x7c\x90\x98\xf4\xc5\x77\x74\xc8\x9d\x0e\xc1\x92\x18\xa3\xe0\x74\x18\xbd\x5b\x4d\xa0\xe8\xdd\x2a\x7d\xc9\xfd\x6e\x75\x31\x7b\x51\x5c\xc0\xfc\x6e\x95\x88\x22\xa4\xe5\x6e\x45\x1f\xed\xc6\xbc\x8c\xf5\x29\xed\x1f\xe4\xb1\xfc\x19\x88\x62\x09\xa2\xe8\xd3\xb0\xc2\x1a\x67\x75\x5c\xf8\x81\x77\x94\x89\x87\x3a\x2a\x93\xe0\xe1\x1c\x55\x6f\x3e\x5b\x26\xde\x3c\x2b\x93\x53\x14\x2f\xaf\x92\x01\xf0\xf2\x2a\x19\x39\x4c\xab\x64\x18\x3d\x57\x25\x93\x09\x97\x92\x7f\xad\x48\xa6\xfe\x2e\x28\x92\x53\xa4\x4f\x29\xef\x8a\x84\xf6\xb9\xa3\x7f\xaf\x51\x7b\x69\xa6\xaf\x03\xea\x7c\xa6\xe9\xd9\xee\xf7\x75\x8b\xfa\xfb\x7b\x8a\xe6\x0f\xbb\xf0\xa8\x66\xdc\xe8\x59\xe2\xce\x7a\xba\x62\xe6\x87\x29\x86\xb3\xea\x63\x51\xf9\x07\x91\x85\xe9\x49\x0e\xa7\x69\xd2\xb0\x96\xb3\x1a\x16\xe8\xb4\x74\x5e\x52\x20\xce\x4b\x7f\xb4\x7a\x97\x1d\x8c\x53\xfb\x83\xc7\x46\x2e\xb0\x1d\x8e\xa4\xd1\x82\x45\x85\xa0\x4a\x60\x3f\xa4\xc5\x29\x27\x6f\x96\x6a\x1f\x93\x3f\xc2\x7c\x32\x96\x37\x5e\xb6\x49\x54\xaf\x68\x17\xf9\x43\xbc\x32\x90\xd4\x28\xc7\x97\x5b\x0a\xbf\x86\xcb\x4e\xbb\x13\x86\xaf\xc7\xcb\xe5\xca\xbf\xff\x12\x77\xfd\x74\x8f\xc7\xb7\x1e\x81\x0e\x86\xdb\x97\x71\xd7\xc1\x3f\x4a\xc8\xf1\xe1\x17\xc0\x5a\x20\x19\x58\xcd\x97\xfe\x76\x75\xed\x1f\x15\xb8\x37\xf6\x8a\xb0\x90\x40\xfa\x6b\x07\x09\x97\x0d\x9b\x5a\x62\x33\x1d\x6e\x64\xee\x4a\x66\x36\x4d\x3d\xe4\xb7\x04\x12\x9e\xaa\xf9\x87\x36\x77\xda\xe4\xf6\xb6\x40\x46\x96\xc3\xd2\x6b\xd8\x0f\xaf\x73\x8f\x42\x27\x57\xbd\xe1\xf2\x36\x7d\x2a\x47\xd1\x21\x3c\x9d\xeb\x16\x27\xe6\x1f\x25\xfe\x03\xbc\x13\x21\x0b\xdc\x4f\x84\xfd\x25\x85\x1e\xe4\x7c\x04\xf3\xa7\xf3\xc8\x3f\x6c\x31\xe7\x20\x76\x5b\xa4\xbf\x8e\x8d\x7f\x27\x83\xff\x05\x00\x00\xff\xff\xd7\xc4\x79\xf0\xfc\x10\x00\x00") +var _templateClientTmpl = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xb4\x58\x4b\x73\xdb\x38\x12\x3e\x93\xbf\xa2\x97\xa5\xec\x92\x2e\x19\xcc\xee\x51\x5b\x3e\x59\x39\xf8\x62\x67\x26\x9e\x9a\x63\x0a\x06\x9b\x14\xc6\x14\xc0\x80\x90\xa5\x14\x47\xff\x7d\x0a\x2f\x3e\xf4\xb2\x92\x9a\x39\x49\x04\xc0\xaf\xbf\xfe\xba\x81\x6e\xb0\xeb\xa0\xc0\x92\x0b\x84\x84\xd5\x1c\x85\x4e\x60\xbf\x8f\xe3\xae\x83\x59\xf3\x5a\xc1\xe2\x0e\x5e\x68\x8b\x30\x23\xf7\x52\x94\xbc\x22\x9f\x29\x7b\xa5\x15\x9a\x45\x5d\x07\x1a\xd7\x4d\x4d\x35\x42\xb2\x42\x5a\xa0\x4a\x60\x66\x5f\xe7\xeb\x46\x2a\x0d\x69\x1c\x25\xb5\xac\x92\x38\x8e\x12\x83\x78\x0c\x92\xaf\x79\xa5\xa8\xc6\x24\x8e\xba\x0e\x14\x15\x15\xc2\xec\xeb\x1c\x66\xc2\x98\x9e\x91\x47\x59\x60\x6b\x20\x23\x87\x20\x4e\x40\xb8\xf1\x61\xc0\x62\xdd\x02\x8a\xc2\x72\x89\x92\x8a\xeb\xd5\xe6\x85\x30\xb9\xce\x4b\xca\xf0\x45\xca\x57\x2e\xd8\xe6\x85\x6a\xa9\x72\x14\x3a\x2f\x38\xad\x91\xe9\x23\x12\xad\x96\xca\x60\x5a\x2a\x5f\xfc\xc3\xad\x65\x33\x5d\xe8\xfd\x35\xeb\xfc\x3b\xe4\xc1\x0e\xb5\x7e\xb9\x63\xef\x97\x59\x8a\x06\xc1\x50\xb4\xf3\xa3\xff\x59\x1c\xe7\x39\xdc\xdb\x58\x00\x6f\x41\xaf\x10\x5c\x64\x40\xaf\xa8\x86\x95\xac\x8b\x16\x68\x5d\x83\x19\x7a\xd9\xf0\xba\x40\xd5\x92\x58\x7f\x6f\x30\xbc\xd6\x6a\xb5\x61\x1a\xba\x38\x62\x56\xad\x38\xca\x73\xf8\xc2\x56\xb8\xa6\x07\x90\xa5\x54\xc0\x14\x52\xcd\x45\x35\x07\x17\x0c\x2e\x2a\xa0\xa2\x80\x42\xc9\xa6\x31\x0f\xad\x7d\x93\xc4\x91\x87\xb8\xf1\x41\x23\xee\xf9\x62\xe8\x9c\xfb\x79\x0e\x2e\x4a\x8f\x74\x6d\x42\x74\x82\x05\x17\x1a\x15\x65\xd6\xfa\x96\xeb\x95\x9d\x9f\xbe\x34\x38\x6b\xd5\x1b\xcd\xdc\x4c\x1e\x9d\x0a\xbd\xaa\xfb\x7d\xbc\xb7\xa2\x3e\xe2\xd6\x0b\x64\x5d\xc6\x16\x28\x08\xdc\x06\x16\x4e\xab\x8d\xc2\x62\x20\x50\xf1\x37\x14\x20\x1b\xcd\xa5\x68\x49\x5c\x6e\x04\x1b\x60\x52\xd9\xe8\x16\x08\x21\x4f\x76\x3e\x83\x1b\x0f\x6f\x84\x37\x22\x38\xc4\xae\x96\xd5\x02\x6a\x59\x91\xcf\x8a\x0b\x5d\x8b\x7d\x1c\x31\xe2\x31\x2d\x06\x21\x24\x8b\x23\x85\x7a\xa3\x04\xfc\xdb\x81\x74\x71\xe4\xa3\xb7\x00\x36\x8f\x23\x2f\xfe\x02\x82\xf8\x8f\xb8\x75\x43\x29\x23\x85\xe2\x6f\xa8\xb2\xf9\x51\x62\x9e\x88\xc5\x54\xba\x85\x71\xe7\x84\x7a\x29\x0b\x68\x7d\x92\x06\x19\x9f\x77\xe0\xa8\x06\xfd\xb4\xa2\xa2\x35\xa1\x93\x82\xd6\x5e\x4d\xaf\x55\xca\x82\x28\x19\x3c\xef\x52\xa6\x77\x46\x14\x8d\x3b\x6d\x36\xb2\xf9\xcd\x20\xbd\x79\xde\xcd\x01\x95\x92\x2a\x33\xd2\xf1\x12\xbe\xce\x41\xbe\x5a\x05\xbd\x6b\x24\xbd\xd1\xbb\xa5\xf3\xf2\xff\x66\xce\xc8\xe3\x05\x13\xbc\x9e\x43\xb9\xd6\xe4\x93\x81\x28\xd3\x24\x1c\x5e\xc6\x3b\x46\x85\x90\x66\x47\x50\xa5\x81\x8e\xa9\xda\x20\x73\x31\x1d\x4c\x32\xe3\x67\xa4\x1d\x21\xc3\x40\xe0\xd6\x11\x9f\xf7\x64\x32\xcb\xd1\xcc\xff\xeb\xce\x58\xbf\x9a\x8c\x65\x61\xb7\xd7\xd8\xe6\x02\x3e\xbc\x25\xd6\x9e\x33\xce\xca\x6a\x94\x3c\xce\xe4\x02\x0c\x01\x9b\x48\x8c\xd4\xb2\x9a\x43\x81\x2f\x1b\xfb\x64\xff\xec\x87\xf4\x79\xde\x4d\x52\xa7\xac\xfe\xd6\xac\x28\xab\xe3\xbc\x98\x1b\xaf\x7d\x72\x2c\x0d\x9b\x83\xfc\xb0\x0c\x6f\x7d\x5e\xc0\x83\xfe\x4f\x0b\x9b\x16\x0b\xd0\x12\x2a\xd4\xf0\x86\xea\x45\xb6\x68\xbc\xab\x8c\x38\x52\x40\xdb\x20\xe3\x25\x67\x20\x1b\x34\x27\x92\xdd\x7c\x79\x1e\xe7\x79\xe4\x61\xac\x9d\x34\x33\xa3\x96\x4d\xca\x45\x81\xbb\xde\xa9\x8f\x59\x20\xee\x56\xfc\xb2\x41\xf5\x3d\x2c\xbf\x97\x1b\xe3\x8a\xde\x65\x06\xf3\x28\x4f\x3d\xf4\x78\x37\xf3\x32\x08\x3d\x8e\x35\xbb\x10\x2e\x5f\x52\x3c\xcf\x90\x39\x73\x17\xbd\xec\x64\x28\xb5\xda\xe0\xfe\xe2\x31\xe0\x62\x79\xe1\x20\x28\xab\x7f\xe4\x28\x38\x15\xf4\xd8\x75\x09\x97\x0c\x18\x2c\x7f\xb6\x2e\xee\xa0\x31\x87\x5f\x0f\x9e\xdc\x0f\xdd\x86\xaf\x0e\x7e\xa9\xab\x0e\x74\x5c\x1b\x8e\x4b\x41\x28\x49\xb6\xea\x4d\x5f\x3e\x2a\x7e\xbe\x9d\x51\x68\xcf\xe4\x99\x20\xbf\x22\x43\x23\x12\xec\xf7\x5d\x07\x66\x2b\x7f\x73\xd3\x09\x4b\xdc\x98\x7d\xf2\x94\x4b\x48\x3e\x90\xff\xb5\x49\x6f\xfe\x4f\xa8\xe5\x36\xbc\x1d\xba\x0c\x57\x5e\xa6\x4c\x86\x5d\x70\xd1\x97\x52\xc9\xf5\xa8\xd8\x38\xd6\x43\xad\x99\x60\xa6\xcc\xcf\x67\xae\xe6\x0d\xc6\xba\x21\x73\x26\x13\x5d\x9f\x3d\xe1\xfc\xbe\xb7\xc5\x6f\xcc\xce\x0d\xf8\xf2\x6a\x59\x4e\x18\x8e\xce\xf2\x09\x74\xe6\xa1\xd2\xec\xb0\x00\x3b\xc0\x03\x4a\x07\xd3\x03\x31\xe2\xfe\x05\x7e\xbf\x35\xc5\x84\x9f\x80\x8d\x1b\xf9\x09\x82\x0e\xeb\x88\xa0\x37\x71\x8e\xa0\x9b\x7e\x87\xe0\x93\x78\x8f\xe3\x10\x53\x14\x9a\xeb\xef\xef\xd1\x7c\x12\x98\x86\xe4\x3b\x6a\x6a\x4e\xbb\x60\x48\x0c\x5e\x30\xd2\x8f\x3e\x2c\x47\x50\xe4\x61\x99\x1d\x72\x7f\x58\x5e\xcd\x9e\x17\x57\x30\x7f\x58\xa6\xbc\xf0\x61\x79\x58\x92\x67\xb3\x31\xaf\x63\x7d\x4a\xfb\x27\x71\x2c\xff\x1c\x78\xb1\x00\x5e\xec\xfb\x52\x53\xe3\x24\x8f\x0b\x37\xf0\x13\x69\xe2\xa0\x8e\xd2\xc4\x5b\x38\x47\xd5\x4d\x9f\x4d\x13\x37\x3d\x49\x93\x53\x14\xaf\xcf\x92\x1e\xf0\xfa\x2c\x19\x38\x8c\xb3\xa4\x1f\x3d\x97\x25\xa3\x05\xd7\x92\xbf\x94\x24\x63\x7b\x57\x24\xc9\x29\xd2\xa7\x94\xb7\x49\x42\x42\xec\xc8\xef\x2b\x54\x4e\x9a\xf1\x6d\x90\x58\x9b\x59\x76\xf6\xf4\xfb\x66\x5a\x83\x9f\x49\x1a\xdf\x53\x1c\x90\xb7\xa3\x67\x89\xdb\xd9\xd3\x19\x33\x2d\xa6\xe8\x6b\xd5\xa7\xa2\x72\x17\x60\x03\x13\x48\xf6\xd5\x34\x6d\x68\xcb\x68\x0d\x33\xb4\x5a\x5a\x2b\x19\x24\xd6\x4a\x28\xad\xce\x64\x07\xc3\xd2\x50\x78\x8c\xe7\x1c\xdb\xbe\x24\x0d\x33\x58\x54\x08\xb2\x04\xfa\x43\x5a\x9c\x32\xf2\x6e\xaa\x06\x9f\x5c\x09\x73\xc1\x58\xdc\x39\xd9\x46\x5e\x5d\xd0\x2e\x72\x45\xbc\xd2\x90\xd6\x28\x86\x9b\x7a\x06\xff\xf5\x7d\x4e\xbb\xe5\x9a\xad\x86\xcb\xc4\xd2\x35\x67\xa9\xbd\x6e\xd8\x8f\x05\xef\x5d\xfa\x2d\x0c\xa3\xad\x15\xea\x0f\xc9\xc5\x70\xd1\xf7\x60\x2d\x24\x73\x30\x9a\x2f\x5c\x63\x75\xeb\x2e\x91\xb8\xd3\xa6\x45\x98\x09\x48\x42\xdb\x91\xf8\x66\xc3\x84\x36\x31\x91\xf6\xcd\x98\xed\xc6\xf4\xba\xa9\xfb\xf8\x96\x90\xf8\x3e\x32\xff\xd0\xe6\x56\x9b\xdc\x74\x0b\xc9\xc0\xb2\x7f\xf5\x16\x76\xfd\xd7\x18\x87\x42\x46\x5d\x5e\xdf\xb7\x8d\x3f\x8d\x44\xd1\xde\x7f\x2a\xa9\x5b\x1c\x4d\xff\x28\xf1\x1f\xe0\xdd\xb7\xe9\x41\xd8\x8f\x19\x04\x90\xf3\x1e\x4c\x3f\x95\x0c\xfc\xfd\x16\xb3\x06\x62\xbb\x45\x42\x3b\x36\xfc\x1d\x0d\xfe\x15\x00\x00\xff\xff\xe5\x35\xec\x94\xec\x12\x00\x00") func templateClientTmplBytes() ([]byte, error) { return bindataRead( @@ -239,7 +239,7 @@ func templateClientTmpl() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "template/client.tmpl", size: 4348, mode: os.FileMode(420), modTime: time.Unix(1566996860, 0)} + info := bindataFileInfo{name: "template/client.tmpl", size: 4844, mode: os.FileMode(420), modTime: time.Unix(1566998190, 0)} a := &asset{bytes: bytes, info: info} return a, nil } diff --git a/entc/gen/template/client.tmpl b/entc/gen/template/client.tmpl index a546db2e6..812386923 100644 --- a/entc/gen/template/client.tmpl +++ b/entc/gen/template/client.tmpl @@ -61,6 +61,27 @@ func (c *Client) Tx(ctx context.Context) (*Tx, error) { }, nil } +// Debug returns a new debug-client. It's used to get verbose logging on specific operations. +// +// client.Debug(). +// {{ (index $.Nodes 0).Name }}. +// Query(). +// Count(ctx) +// +func (c *Client) Debug() *Client { + if c.debug { + return c + } + cfg := config{driver: dialect.Debug(c.driver, c.log), log: c.log, debug: true} + return &Client{ + config: cfg, + Schema: migrate.NewSchema(cfg.driver), + {{ range $_, $n := $.Nodes -}} + {{ $n.Name }}: New{{ $n.Name }}Client(cfg), + {{ end -}} + } +} + {{ range $_, $n := $.Nodes -}} {{ $client := print $n.Name "Client" }} // {{ $client }} is a client for the {{ $n.Name }} schema. diff --git a/entc/integration/ent/client.go b/entc/integration/ent/client.go index c23b9ad89..556b2f1a7 100644 --- a/entc/integration/ent/client.go +++ b/entc/integration/ent/client.go @@ -97,6 +97,34 @@ func (c *Client) Tx(ctx context.Context) (*Tx, error) { }, nil } +// Debug returns a new debug-client. It's used to get verbose logging on specific operations. +// +// client.Debug(). +// Card. +// Query(). +// Count(ctx) +// +func (c *Client) Debug() *Client { + if c.debug { + return c + } + cfg := config{driver: dialect.Debug(c.driver, c.log), log: c.log, debug: true} + return &Client{ + config: cfg, + Schema: migrate.NewSchema(cfg.driver), + Card: NewCardClient(cfg), + Comment: NewCommentClient(cfg), + FieldType: NewFieldTypeClient(cfg), + File: NewFileClient(cfg), + FileType: NewFileTypeClient(cfg), + Group: NewGroupClient(cfg), + GroupInfo: NewGroupInfoClient(cfg), + Node: NewNodeClient(cfg), + Pet: NewPetClient(cfg), + User: NewUserClient(cfg), + } +} + // CardClient is a client for the Card schema. type CardClient struct { config diff --git a/entc/integration/integration_test.go b/entc/integration/integration_test.go index f12c8d4b9..4206232a8 100644 --- a/entc/integration/integration_test.go +++ b/entc/integration/integration_test.go @@ -16,7 +16,6 @@ import ( "testing" "time" - "github.com/facebookincubator/ent/dialect" "github.com/facebookincubator/ent/dialect/gremlin" "github.com/facebookincubator/ent/dialect/sql" "github.com/facebookincubator/ent/entc/integration/ent" @@ -34,13 +33,9 @@ import ( ) func TestSQLite(t *testing.T) { - db, err := sql.Open("sqlite3", "file:ent?mode=memory&cache=shared&_fk=1") + drv, err := sql.Open("sqlite3", "file:ent?mode=memory&cache=shared&_fk=1") require.NoError(t, err) - defer db.Close() - drv := dialect.Driver(db) - if testing.Verbose() { - drv = dialect.Debug(drv) - } + defer drv.Close() client := ent.NewClient(ent.Driver(drv)) require.NoError(t, client.Schema.Create(context.Background())) for _, tt := range tests[1:] { @@ -55,13 +50,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) { - var drv dialect.Driver drv, err := sql.Open("mysql", fmt.Sprintf("root:pass@tcp(localhost:%d)/test?parseTime=True", port)) require.NoError(t, err) defer drv.Close() - if testing.Verbose() { - drv = dialect.Debug(drv) - } client := ent.NewClient(ent.Driver(drv)) require.NoError(t, client.Schema.Create(context.Background())) for _, tt := range tests { @@ -85,11 +76,7 @@ func TestGremlin(t *testing.T) { }, }) require.NoError(t, err) - var drv dialect.Driver = gremlin.NewDriver(c) - if testing.Verbose() { - drv = dialect.Debug(drv, t.Log) - } - client := ent.NewClient(ent.Driver(drv)) + client := ent.NewClient(ent.Driver(gremlin.NewDriver(c))) // run all tests except transaction and index tests. for _, tt := range tests[3:] { name := runtime.FuncForPC(reflect.ValueOf(tt).Pointer()).Name() diff --git a/entc/integration/migrate/entv1/client.go b/entc/integration/migrate/entv1/client.go index 2520eac28..493c748e3 100644 --- a/entc/integration/migrate/entv1/client.go +++ b/entc/integration/migrate/entv1/client.go @@ -10,6 +10,8 @@ import ( "github.com/facebookincubator/ent/entc/integration/migrate/entv1/migrate" "github.com/facebookincubator/ent/entc/integration/migrate/entv1/user" + + "github.com/facebookincubator/ent/dialect" ) // Client is the client that holds all ent builders. @@ -48,6 +50,25 @@ func (c *Client) Tx(ctx context.Context) (*Tx, error) { }, nil } +// Debug returns a new debug-client. It's used to get verbose logging on specific operations. +// +// client.Debug(). +// User. +// Query(). +// Count(ctx) +// +func (c *Client) Debug() *Client { + if c.debug { + return c + } + cfg := config{driver: dialect.Debug(c.driver, c.log), log: c.log, debug: true} + return &Client{ + config: cfg, + Schema: migrate.NewSchema(cfg.driver), + User: NewUserClient(cfg), + } +} + // 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 516ab24eb..237859d1a 100644 --- a/entc/integration/migrate/entv2/client.go +++ b/entc/integration/migrate/entv2/client.go @@ -12,6 +12,8 @@ import ( "github.com/facebookincubator/ent/entc/integration/migrate/entv2/group" "github.com/facebookincubator/ent/entc/integration/migrate/entv2/pet" "github.com/facebookincubator/ent/entc/integration/migrate/entv2/user" + + "github.com/facebookincubator/ent/dialect" ) // Client is the client that holds all ent builders. @@ -58,6 +60,27 @@ func (c *Client) Tx(ctx context.Context) (*Tx, error) { }, nil } +// Debug returns a new debug-client. It's used to get verbose logging on specific operations. +// +// client.Debug(). +// Group. +// Query(). +// Count(ctx) +// +func (c *Client) Debug() *Client { + if c.debug { + return c + } + cfg := config{driver: dialect.Debug(c.driver, c.log), log: c.log, debug: true} + return &Client{ + config: cfg, + Schema: migrate.NewSchema(cfg.driver), + Group: NewGroupClient(cfg), + Pet: NewPetClient(cfg), + User: NewUserClient(cfg), + } +} + // GroupClient is a client for the Group schema. type GroupClient struct { config diff --git a/entc/integration/migrate/migrate_test.go b/entc/integration/migrate/migrate_test.go index bb7231630..d56da9fe5 100644 --- a/entc/integration/migrate/migrate_test.go +++ b/entc/integration/migrate/migrate_test.go @@ -32,7 +32,7 @@ func TestMySQL(t *testing.T) { ctx := context.Background() err = root.Exec(ctx, "CREATE DATABASE IF NOT EXISTS migrate", []interface{}{}, new(sql.Result)) require.NoError(t, err, "creating database") - defer root.Exec(ctx, "DROP DATABASE migrate IF EXISTS", []interface{}{}, new(sql.Result)) + defer root.Exec(ctx, "DROP DATABASE IF EXISTS migrate", []interface{}{}, new(sql.Result)) drv, err := sql.Open("mysql", fmt.Sprintf("root:pass@tcp(localhost:%d)/migrate?parseTime=True", port)) require.NoError(t, err, "connecting to migrate database") diff --git a/examples/edgeindex/ent/client.go b/examples/edgeindex/ent/client.go index bc8269f7c..5d6c22f97 100644 --- a/examples/edgeindex/ent/client.go +++ b/examples/edgeindex/ent/client.go @@ -12,6 +12,7 @@ import ( "github.com/facebookincubator/ent/examples/edgeindex/ent/city" "github.com/facebookincubator/ent/examples/edgeindex/ent/street" + "github.com/facebookincubator/ent/dialect" "github.com/facebookincubator/ent/dialect/sql" ) @@ -55,6 +56,26 @@ func (c *Client) Tx(ctx context.Context) (*Tx, error) { }, nil } +// Debug returns a new debug-client. It's used to get verbose logging on specific operations. +// +// client.Debug(). +// City. +// Query(). +// Count(ctx) +// +func (c *Client) Debug() *Client { + if c.debug { + return c + } + cfg := config{driver: dialect.Debug(c.driver, c.log), log: c.log, debug: true} + return &Client{ + config: cfg, + Schema: migrate.NewSchema(cfg.driver), + City: NewCityClient(cfg), + Street: NewStreetClient(cfg), + } +} + // 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 c8a11aa5f..d8e3128ab 100644 --- a/examples/m2m2types/ent/client.go +++ b/examples/m2m2types/ent/client.go @@ -12,6 +12,7 @@ import ( "github.com/facebookincubator/ent/examples/m2m2types/ent/group" "github.com/facebookincubator/ent/examples/m2m2types/ent/user" + "github.com/facebookincubator/ent/dialect" "github.com/facebookincubator/ent/dialect/sql" ) @@ -55,6 +56,26 @@ func (c *Client) Tx(ctx context.Context) (*Tx, error) { }, nil } +// Debug returns a new debug-client. It's used to get verbose logging on specific operations. +// +// client.Debug(). +// Group. +// Query(). +// Count(ctx) +// +func (c *Client) Debug() *Client { + if c.debug { + return c + } + cfg := config{driver: dialect.Debug(c.driver, c.log), log: c.log, debug: true} + return &Client{ + config: cfg, + Schema: migrate.NewSchema(cfg.driver), + Group: NewGroupClient(cfg), + User: NewUserClient(cfg), + } +} + // GroupClient is a client for the Group schema. type GroupClient struct { config diff --git a/examples/m2mbidi/ent/client.go b/examples/m2mbidi/ent/client.go index 174c5cb1f..68397f5fc 100644 --- a/examples/m2mbidi/ent/client.go +++ b/examples/m2mbidi/ent/client.go @@ -11,6 +11,7 @@ import ( "github.com/facebookincubator/ent/examples/m2mbidi/ent/user" + "github.com/facebookincubator/ent/dialect" "github.com/facebookincubator/ent/dialect/sql" ) @@ -50,6 +51,25 @@ func (c *Client) Tx(ctx context.Context) (*Tx, error) { }, nil } +// Debug returns a new debug-client. It's used to get verbose logging on specific operations. +// +// client.Debug(). +// User. +// Query(). +// Count(ctx) +// +func (c *Client) Debug() *Client { + if c.debug { + return c + } + cfg := config{driver: dialect.Debug(c.driver, c.log), log: c.log, debug: true} + return &Client{ + config: cfg, + Schema: migrate.NewSchema(cfg.driver), + User: NewUserClient(cfg), + } +} + // UserClient is a client for the User schema. type UserClient struct { config diff --git a/examples/m2mrecur/ent/client.go b/examples/m2mrecur/ent/client.go index 6e8072b3b..1683b3168 100644 --- a/examples/m2mrecur/ent/client.go +++ b/examples/m2mrecur/ent/client.go @@ -11,6 +11,7 @@ import ( "github.com/facebookincubator/ent/examples/m2mrecur/ent/user" + "github.com/facebookincubator/ent/dialect" "github.com/facebookincubator/ent/dialect/sql" ) @@ -50,6 +51,25 @@ func (c *Client) Tx(ctx context.Context) (*Tx, error) { }, nil } +// Debug returns a new debug-client. It's used to get verbose logging on specific operations. +// +// client.Debug(). +// User. +// Query(). +// Count(ctx) +// +func (c *Client) Debug() *Client { + if c.debug { + return c + } + cfg := config{driver: dialect.Debug(c.driver, c.log), log: c.log, debug: true} + return &Client{ + config: cfg, + Schema: migrate.NewSchema(cfg.driver), + User: NewUserClient(cfg), + } +} + // UserClient is a client for the User schema. type UserClient struct { config diff --git a/examples/o2m2types/ent/client.go b/examples/o2m2types/ent/client.go index 4f1f95b17..17f98234c 100644 --- a/examples/o2m2types/ent/client.go +++ b/examples/o2m2types/ent/client.go @@ -12,6 +12,7 @@ import ( "github.com/facebookincubator/ent/examples/o2m2types/ent/pet" "github.com/facebookincubator/ent/examples/o2m2types/ent/user" + "github.com/facebookincubator/ent/dialect" "github.com/facebookincubator/ent/dialect/sql" ) @@ -55,6 +56,26 @@ func (c *Client) Tx(ctx context.Context) (*Tx, error) { }, nil } +// Debug returns a new debug-client. It's used to get verbose logging on specific operations. +// +// client.Debug(). +// Pet. +// Query(). +// Count(ctx) +// +func (c *Client) Debug() *Client { + if c.debug { + return c + } + cfg := config{driver: dialect.Debug(c.driver, c.log), log: c.log, debug: true} + return &Client{ + config: cfg, + Schema: migrate.NewSchema(cfg.driver), + Pet: NewPetClient(cfg), + User: NewUserClient(cfg), + } +} + // PetClient is a client for the Pet schema. type PetClient struct { config diff --git a/examples/o2mrecur/ent/client.go b/examples/o2mrecur/ent/client.go index 493a1971a..0b104c958 100644 --- a/examples/o2mrecur/ent/client.go +++ b/examples/o2mrecur/ent/client.go @@ -11,6 +11,7 @@ import ( "github.com/facebookincubator/ent/examples/o2mrecur/ent/node" + "github.com/facebookincubator/ent/dialect" "github.com/facebookincubator/ent/dialect/sql" ) @@ -50,6 +51,25 @@ func (c *Client) Tx(ctx context.Context) (*Tx, error) { }, nil } +// Debug returns a new debug-client. It's used to get verbose logging on specific operations. +// +// client.Debug(). +// Node. +// Query(). +// Count(ctx) +// +func (c *Client) Debug() *Client { + if c.debug { + return c + } + cfg := config{driver: dialect.Debug(c.driver, c.log), log: c.log, debug: true} + return &Client{ + config: cfg, + Schema: migrate.NewSchema(cfg.driver), + Node: NewNodeClient(cfg), + } +} + // NodeClient is a client for the Node schema. type NodeClient struct { config diff --git a/examples/o2o2types/ent/client.go b/examples/o2o2types/ent/client.go index 3c910c260..c9e392801 100644 --- a/examples/o2o2types/ent/client.go +++ b/examples/o2o2types/ent/client.go @@ -12,6 +12,7 @@ import ( "github.com/facebookincubator/ent/examples/o2o2types/ent/card" "github.com/facebookincubator/ent/examples/o2o2types/ent/user" + "github.com/facebookincubator/ent/dialect" "github.com/facebookincubator/ent/dialect/sql" ) @@ -55,6 +56,26 @@ func (c *Client) Tx(ctx context.Context) (*Tx, error) { }, nil } +// Debug returns a new debug-client. It's used to get verbose logging on specific operations. +// +// client.Debug(). +// Card. +// Query(). +// Count(ctx) +// +func (c *Client) Debug() *Client { + if c.debug { + return c + } + cfg := config{driver: dialect.Debug(c.driver, c.log), log: c.log, debug: true} + return &Client{ + config: cfg, + Schema: migrate.NewSchema(cfg.driver), + Card: NewCardClient(cfg), + User: NewUserClient(cfg), + } +} + // CardClient is a client for the Card schema. type CardClient struct { config diff --git a/examples/o2obidi/ent/client.go b/examples/o2obidi/ent/client.go index 7aa7daf3e..a772dfb4a 100644 --- a/examples/o2obidi/ent/client.go +++ b/examples/o2obidi/ent/client.go @@ -11,6 +11,7 @@ import ( "github.com/facebookincubator/ent/examples/o2obidi/ent/user" + "github.com/facebookincubator/ent/dialect" "github.com/facebookincubator/ent/dialect/sql" ) @@ -50,6 +51,25 @@ func (c *Client) Tx(ctx context.Context) (*Tx, error) { }, nil } +// Debug returns a new debug-client. It's used to get verbose logging on specific operations. +// +// client.Debug(). +// User. +// Query(). +// Count(ctx) +// +func (c *Client) Debug() *Client { + if c.debug { + return c + } + cfg := config{driver: dialect.Debug(c.driver, c.log), log: c.log, debug: true} + return &Client{ + config: cfg, + Schema: migrate.NewSchema(cfg.driver), + User: NewUserClient(cfg), + } +} + // UserClient is a client for the User schema. type UserClient struct { config diff --git a/examples/o2orecur/ent/client.go b/examples/o2orecur/ent/client.go index baa8c2bfa..2ac87016d 100644 --- a/examples/o2orecur/ent/client.go +++ b/examples/o2orecur/ent/client.go @@ -11,6 +11,7 @@ import ( "github.com/facebookincubator/ent/examples/o2orecur/ent/node" + "github.com/facebookincubator/ent/dialect" "github.com/facebookincubator/ent/dialect/sql" ) @@ -50,6 +51,25 @@ func (c *Client) Tx(ctx context.Context) (*Tx, error) { }, nil } +// Debug returns a new debug-client. It's used to get verbose logging on specific operations. +// +// client.Debug(). +// Node. +// Query(). +// Count(ctx) +// +func (c *Client) Debug() *Client { + if c.debug { + return c + } + cfg := config{driver: dialect.Debug(c.driver, c.log), log: c.log, debug: true} + return &Client{ + config: cfg, + Schema: migrate.NewSchema(cfg.driver), + Node: NewNodeClient(cfg), + } +} + // NodeClient is a client for the Node schema. type NodeClient struct { config