1
0
forked from ALHP/ALHP.GO

fixed rebuilding of x86_64->any packages; updated deps

This commit is contained in:
2023-09-23 12:52:51 +02:00
parent fd8bf63e3e
commit 7c826d2d1e
7 changed files with 45 additions and 33 deletions

View File

@@ -7,6 +7,7 @@ import (
"errors"
"fmt"
"log"
"reflect"
"somegit.dev/ALHP/ALHP.GO/ent/migrate"
@@ -104,11 +105,14 @@ func Open(driverName, dataSourceName string, options ...Option) (*Client, error)
}
}
// ErrTxStarted is returned when trying to start a new transaction from a transactional client.
var ErrTxStarted = errors.New("ent: cannot start a transaction within a transaction")
// Tx returns a new transactional client. The provided context
// is used until the transaction is committed or rolled back.
func (c *Client) Tx(ctx context.Context) (*Tx, error) {
if _, ok := c.driver.(*txDriver); ok {
return nil, errors.New("ent: cannot start a transaction within a transaction")
return nil, ErrTxStarted
}
tx, err := newTx(ctx, c.driver)
if err != nil {
@@ -220,6 +224,21 @@ func (c *DBPackageClient) CreateBulk(builders ...*DBPackageCreate) *DBPackageCre
return &DBPackageCreateBulk{config: c.config, builders: builders}
}
// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
// a builder and applies setFunc on it.
func (c *DBPackageClient) MapCreateBulk(slice any, setFunc func(*DBPackageCreate, int)) *DBPackageCreateBulk {
rv := reflect.ValueOf(slice)
if rv.Kind() != reflect.Slice {
return &DBPackageCreateBulk{err: fmt.Errorf("calling to DBPackageClient.MapCreateBulk with wrong type %T, need slice", slice)}
}
builders := make([]*DBPackageCreate, rv.Len())
for i := 0; i < rv.Len(); i++ {
builders[i] = c.Create()
setFunc(builders[i], i)
}
return &DBPackageCreateBulk{config: c.config, builders: builders}
}
// Update returns an update builder for DBPackage.
func (c *DBPackageClient) Update() *DBPackageUpdate {
mutation := newDBPackageMutation(c.config, OpUpdate)