mirror of
https://github.com/ent/ent.git
synced 2026-05-24 09:31:56 +03:00
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
This commit is contained in:
committed by
Facebook Github Bot
parent
e7fec6f8f9
commit
dc542e46ae
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user