up
This commit is contained in:
@@ -298,8 +298,14 @@ func UpdateCellHandler(c *fiber.Ctx) error {
|
||||
valueSQL = "'" + strings.ReplaceAll(body.Value, "'", "''") + "'"
|
||||
}
|
||||
|
||||
sqlText := fmt.Sprintf("UPDATE %s SET %s = %s WHERE %s = '%s'",
|
||||
qTable, qCol, valueSQL, qPkCol, strings.ReplaceAll(body.PkValue, "'", "''"))
|
||||
// Determinar si pk_value es numérico para no entrecomillarlo
|
||||
pkValueSQL := "'" + strings.ReplaceAll(body.PkValue, "'", "''") + "'"
|
||||
if _, err := strconv.ParseFloat(body.PkValue, 64); err == nil {
|
||||
pkValueSQL = body.PkValue
|
||||
}
|
||||
|
||||
sqlText := fmt.Sprintf("UPDATE %s SET %s = %s WHERE %s = %s",
|
||||
qTable, qCol, valueSQL, qPkCol, pkValueSQL)
|
||||
|
||||
result := services.ExecuteSQL(conx, body.Database, sqlText)
|
||||
if result.Error != "" {
|
||||
@@ -524,6 +530,9 @@ SQL original:
|
||||
%s
|
||||
|
||||
SQL optimizado:`, sql)
|
||||
case "nl2sql":
|
||||
// El prompt ya viene construido desde NL2SQLHandler (incluye esquema + descripción)
|
||||
prompt = sql
|
||||
default:
|
||||
prompt = fmt.Sprintf(`Eres un experto en SQL. Ayuda con esta consulta SQL. Devuelve SOLO el SQL resultante, sin explicaciones.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user