This commit is contained in:
oneao committed 2026-04-19 21:30:51 +08:00
1 parent b6415c0d65
commit 89aaef1d6b
29 files changed
+1118 -277

No files matched your search

+23 -3
View File
@@ -16,11 +16,21 @@ func (c *Client) Delete(
return fmt.Errorf("keyField 不能为空")
}
keyVal, err := validateData(table, keyField, data)
rawTable := table
keyVal, err := validateData(rawTable, keyField, data)
if err != nil {
return err
}
tableParts := strings.Split(table, ".")
for i, p := range tableParts {
tableParts[i] = `"` + p + `"`
}
table = strings.Join(tableParts, ".")
keyField = `"` + keyField + `"`
sql := fmt.Sprintf(
"DELETE FROM %s WHERE %s = $1",
table,
@@ -50,6 +60,16 @@ func (c *Client) BatchDelete(
return fmt.Errorf("数据不能为空")
}
rawTable := table
tableParts := strings.Split(table, ".")
for i, p := range tableParts {
tableParts[i] = `"` + p + `"`
}
table = strings.Join(tableParts, ".")
keyFieldQuoted := `"` + keyField + `"`
var (
placeholders []string
args []any
@@ -57,7 +77,7 @@ func (c *Client) BatchDelete(
)
for _, data := range dataList {
keyVal, err := validateData(table, keyField, data)
keyVal, err := validateData(rawTable, keyField, data)
if err != nil {
return err
}
@@ -74,7 +94,7 @@ func (c *Client) BatchDelete(
sql := fmt.Sprintf(
"DELETE FROM %s WHERE %s IN (%s)",
table,
keyField,
keyFieldQuoted,
strings.Join(placeholders, ", "),
)