|
|
@@ -127,7 +127,8 @@ func Delete[T any](executor SqlExecutor, tableName string, e T) error {
|
|
|
}
|
|
|
|
|
|
executeParams := raw_sql_tpl.DeleteExecuteParams{
|
|
|
- TableName: tableName,
|
|
|
+ TableName: tableName,
|
|
|
+ Conditions: make([]raw_sql_tpl.Condition, 0),
|
|
|
}
|
|
|
|
|
|
for _, sqlMappingColumn := range sqlMapping.ColumnMap {
|
|
|
@@ -186,13 +187,14 @@ func Update[T any](executor SqlExecutor, tableName string, e T, callback ValueCa
|
|
|
}
|
|
|
|
|
|
executeParams := raw_sql_tpl.UpdateExecuteParams{
|
|
|
- TableName: tableName,
|
|
|
+ TableName: tableName,
|
|
|
+ Conditions: make([]raw_sql_tpl.Condition, 0),
|
|
|
}
|
|
|
|
|
|
now := time.Now()
|
|
|
|
|
|
for fieldName, sqlMappingColumn := range sqlMapping.ColumnMap {
|
|
|
- if !sqlMappingColumn.CanUpdate {
|
|
|
+ if !sqlMappingColumn.IsKey && !sqlMappingColumn.CanUpdate {
|
|
|
continue
|
|
|
}
|
|
|
|
|
|
@@ -236,10 +238,12 @@ func Update[T any](executor SqlExecutor, tableName string, e T, callback ValueCa
|
|
|
return err
|
|
|
}
|
|
|
|
|
|
- executeParams.TableRows = append(executeParams.TableRows, raw_sql_tpl.TableRow{
|
|
|
- Column: sqlMappingColumn.Name,
|
|
|
- Value: tableRowValue,
|
|
|
- })
|
|
|
+ if !sqlMappingColumn.IsKey {
|
|
|
+ executeParams.TableRows = append(executeParams.TableRows, raw_sql_tpl.TableRow{
|
|
|
+ Column: sqlMappingColumn.Name,
|
|
|
+ Value: tableRowValue,
|
|
|
+ })
|
|
|
+ }
|
|
|
|
|
|
if sqlMappingColumn.IsKey {
|
|
|
executeParams.Conditions = append(executeParams.Conditions, raw_sql_tpl.Condition{
|
|
|
@@ -289,13 +293,15 @@ func Query[T any](executor SqlExecutor, tableName string, e T, pageNo int, pageS
|
|
|
}
|
|
|
|
|
|
executeParams := raw_sql_tpl.QueryExecuteParams{
|
|
|
- TableName: tableName,
|
|
|
- Limit: limit,
|
|
|
- Offset: offset,
|
|
|
+ TableName: tableName,
|
|
|
+ Conditions: make([]raw_sql_tpl.Condition, 0),
|
|
|
+ Limit: limit,
|
|
|
+ Offset: offset,
|
|
|
}
|
|
|
|
|
|
countParams := raw_sql_tpl.CountExecuteParams{
|
|
|
- TableName: tableName,
|
|
|
+ TableName: tableName,
|
|
|
+ Conditions: make([]raw_sql_tpl.Condition, 0),
|
|
|
}
|
|
|
|
|
|
for fieldName, sqlMappingColumn := range sqlMapping.ColumnMap {
|
|
|
@@ -396,9 +402,10 @@ func QueryByKeys[T any](executor SqlExecutor, tableName string, e T) (map[string
|
|
|
}
|
|
|
|
|
|
executeParams := raw_sql_tpl.QueryExecuteParams{
|
|
|
- TableName: tableName,
|
|
|
- Limit: 0,
|
|
|
- Offset: 0,
|
|
|
+ TableName: tableName,
|
|
|
+ Conditions: make([]raw_sql_tpl.Condition, 0),
|
|
|
+ Limit: 0,
|
|
|
+ Offset: 0,
|
|
|
}
|
|
|
|
|
|
for _, sqlMappingColumn := range sqlMapping.ColumnMap {
|
|
|
@@ -461,7 +468,8 @@ func Count[T any](executor SqlExecutor, tableName string, e T, callback Conditio
|
|
|
}
|
|
|
|
|
|
executeParams := raw_sql_tpl.CountExecuteParams{
|
|
|
- TableName: tableName,
|
|
|
+ TableName: tableName,
|
|
|
+ Conditions: make([]raw_sql_tpl.Condition, 0),
|
|
|
}
|
|
|
|
|
|
for fieldName, sqlMappingColumn := range sqlMapping.ColumnMap {
|
|
|
@@ -537,7 +545,8 @@ func CheckExist[T any](executor SqlExecutor, tableName string, e T, callback Con
|
|
|
}
|
|
|
|
|
|
executeParams := raw_sql_tpl.CountExecuteParams{
|
|
|
- TableName: tableName,
|
|
|
+ TableName: tableName,
|
|
|
+ Conditions: make([]raw_sql_tpl.Condition, 0),
|
|
|
}
|
|
|
|
|
|
for fieldName, sqlMappingColumn := range sqlMapping.ColumnMap {
|
|
|
@@ -613,7 +622,8 @@ func CheckExistByKey[T any](executor SqlExecutor, tableName string, e T) (bool,
|
|
|
}
|
|
|
|
|
|
executeParams := raw_sql_tpl.CountExecuteParams{
|
|
|
- TableName: tableName,
|
|
|
+ TableName: tableName,
|
|
|
+ Conditions: make([]raw_sql_tpl.Condition, 0),
|
|
|
}
|
|
|
|
|
|
for _, sqlMappingColumn := range sqlMapping.ColumnMap {
|
|
|
@@ -672,7 +682,8 @@ func CheckHasOnlyOne[T any](executor SqlExecutor, tableName string, e T, callbac
|
|
|
}
|
|
|
|
|
|
executeParams := raw_sql_tpl.CountExecuteParams{
|
|
|
- TableName: tableName,
|
|
|
+ TableName: tableName,
|
|
|
+ Conditions: make([]raw_sql_tpl.Condition, 0),
|
|
|
}
|
|
|
|
|
|
for fieldName, sqlMappingColumn := range sqlMapping.ColumnMap {
|