BeginTx returns a transactional client with specified options.
(ctx context.Context, opts *sql.TxOptions)
| 231 | |
| 232 | // BeginTx returns a transactional client with specified options. |
| 233 | func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error) { |
| 234 | if _, ok := c.driver.(*txDriver); ok { |
| 235 | return nil, errors.New("ent: cannot start a transaction within a transaction") |
| 236 | } |
| 237 | tx, err := c.driver.(interface { |
| 238 | BeginTx(context.Context, *sql.TxOptions) (dialect.Tx, error) |
| 239 | }).BeginTx(ctx, opts) |
| 240 | if err != nil { |
| 241 | return nil, fmt.Errorf("ent: starting a transaction: %w", err) |
| 242 | } |
| 243 | cfg := c.config |
| 244 | cfg.driver = &txDriver{tx: tx, drv: c.driver} |
| 245 | return &Tx{ |
| 246 | ctx: ctx, |
| 247 | config: cfg, |
| 248 | APIToken: NewAPITokenClient(cfg), |
| 249 | Attestation: NewAttestationClient(cfg), |
| 250 | CASBackend: NewCASBackendClient(cfg), |
| 251 | CASMapping: NewCASMappingClient(cfg), |
| 252 | Group: NewGroupClient(cfg), |
| 253 | GroupMembership: NewGroupMembershipClient(cfg), |
| 254 | Integration: NewIntegrationClient(cfg), |
| 255 | IntegrationAttachment: NewIntegrationAttachmentClient(cfg), |
| 256 | Membership: NewMembershipClient(cfg), |
| 257 | OrgInvitation: NewOrgInvitationClient(cfg), |
| 258 | Organization: NewOrganizationClient(cfg), |
| 259 | Project: NewProjectClient(cfg), |
| 260 | ProjectVersion: NewProjectVersionClient(cfg), |
| 261 | Referrer: NewReferrerClient(cfg), |
| 262 | RobotAccount: NewRobotAccountClient(cfg), |
| 263 | User: NewUserClient(cfg), |
| 264 | Workflow: NewWorkflowClient(cfg), |
| 265 | WorkflowContract: NewWorkflowContractClient(cfg), |
| 266 | WorkflowContractVersion: NewWorkflowContractVersionClient(cfg), |
| 267 | WorkflowRun: NewWorkflowRunClient(cfg), |
| 268 | }, nil |
| 269 | } |
| 270 | |
| 271 | // Debug returns a new debug-client. It's used to get verbose logging on specific operations. |
| 272 | // |
nothing calls this directly
no test coverage detected