brouznouf / fivem-mysql-async

MySql Async Library for FiveM
MIT License
111 stars 106 forks source link

Transactional documentation seems faulty. #156

Open SnakeSVx opened 3 years ago

SnakeSVx commented 3 years ago

Describe the bug

  1. https://brouznouf.github.io/fivem-mysql-async/queries/ mentions in the 2nd way of executing transactions that you need to use parameters = {} to pass the params, but in reality it seems to be values = {} instead.
  2. The Sync methods fails if you try to use the 2nd way of execution transactions, because params = null instead of the callback function.

To Reproduce local queries = { { query = 'INSERT INTO aTable (col1, col2) VALUES (@col1, @col2)', parameters = { col1='string', col2= 1 } } }

  1. MySQL.Sync.transaction(queries) => error SCRIPT ERROR in call ref: TypeError: Found non-callable @@iterator
  2. MySQL.Async.transaction(queries, function(result) end) => @col1 can not be a null value (if col1 was made as NOT NULL)

Expected behavior No errors.

Software:

Additional context

Problem 1 seems to be a documentation error, if you use "values" instead of parameters it works as expected. Problem 2 requires a check to see if the params are nil or not, and require a different call then.