nanos-world / issues

Issue Tracker for nanos world
9 stars 1 forks source link

MySQL escaped varargs "issue" #969

Open Timmy-the-nobody opened 1 year ago

Timmy-the-nobody commented 1 year ago

Prerequisites

Your Environment

Description

When calling a function that returns multiple values in the varargs of ExecuteAsync (those you send to be escaped) it throws an error saying

ERROR  Failed to execute Execute query: 'INSERT INTO `my_cool_table` (`field_a`,`field_b`) VALUES (:1,:2);'.
                Error: invalid vector subscript

I know that's how lua works and that's why i put quotes in the title, but it doesn't seems right to keep this behaviour in this specific case imo

Steps to reproduce the behavior

Connect to your database with the Database class, and replace my_db by your database object once connected

-- Create a new table in your database
my_db:Execute("CREATE TABLE IF NOT EXISTS `my_cool_table` (`field_a` TEXT, `field_b` TEXT);")

-- Create a function that returns multiple values
local function someFunc()
    return "B", true
end

-- Insert something in the table
my_db:ExecuteAsync(
    "INSERT INTO `my_cool_table` (`field_a`, `field_b`) VALUES (:1, :2)",
    nil,
    "A",
    someFunc() -- Here I expect the first parameter to be evaluated ("B")
)

Expected behavior

In the exemple above only the value "B" should be considered

Actual behavior

In the exemple above both returned values of my function are passed as varargs to be escaped