This commit is contained in:
Lizandro Guarnizo
2026-06-02 13:27:45 -05:00
parent 28d0eae715
commit c5603c51f8
2 changed files with 11 additions and 37 deletions
+11 -2
View File
@@ -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.