u
This commit is contained in:
1 parent
4d60582d4f
commit
2fb19021ae
40 files changed
+2552
-348
No files matched your search
@@ -31,11 +31,12 @@ func buildInsertSQL(table string, data map[string]any) (string, []any) {
|
||||
}
|
||||
|
||||
func (c *Client) Insert(ctx context.Context, table, keyField string, data map[string]any) error {
|
||||
|
||||
if _, err := validateData(table, keyField, data); err != nil {
|
||||
if _, err := validateInsertData(table, keyField, data); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
ensureID(data, keyField)
|
||||
|
||||
data = applyMetaFields(ctx, table, data, true)
|
||||
|
||||
sql, args := buildInsertSQL(table, data)
|
||||
@@ -51,7 +52,7 @@ func (c *Client) BatchInsert(ctx context.Context, table, keyField string, list [
|
||||
}
|
||||
|
||||
first := list[0]
|
||||
if _, err := validateData(table, keyField, first); err != nil {
|
||||
if _, err := validateInsertData(table, keyField, first); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -71,6 +72,7 @@ func (c *Client) BatchInsert(ctx context.Context, table, keyField string, list [
|
||||
)
|
||||
|
||||
for _, row := range list {
|
||||
ensureID(row, keyField)
|
||||
|
||||
row = applyMetaFields(ctx, table, row, true)
|
||||
|
||||
|
||||
Reference in new issue
Block a user