Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to execute named parameters using '@' in the parameter #48

Closed
chaixshot opened this issue Oct 16, 2021 · 11 comments
Closed

Unable to execute named parameters using '@' in the parameter #48

chaixshot opened this issue Oct 16, 2021 · 11 comments
Labels
bug Something isn't working

Comments

@chaixshot
Copy link
Contributor

Version 1.6.0 at same execute fucntion

MySQL.ready(function()
	MySQL.Async.execute('INSERT INTO discord(identifier, discord) VALUES(@identifier, @discord)',
	{
		['@identifier'] = "steam:11000013d8d70d5",
		['@discord'] = "xbl:2535406267274231",
	})
end)

image

@chaixshot
Copy link
Contributor Author

image

@darksaid98
Copy link
Contributor

The column discord in table discord of your database can not be set to NULL, since you haven't enabled it for said column.

Not an oxmysql issue.

@chaixshot
Copy link
Contributor Author

image
Look like mysql-async syntax have problem.

@darksaid98
Copy link
Contributor

It should be ['identifier'] = 'test1' not ['@identifier'] = ....

I could have sworn there was backward compatibility for putting '@' in there but I might be wrong, so let me know how that goes.

@chaixshot
Copy link
Contributor Author

chaixshot commented Oct 16, 2021

image

This form 1.5.1 (['@Identifier'] Work)
image

This form 1.6.0 (['@Identifier'] Not work)
image

Look like mysql-async syntax compatible not working.
Because this is error on all my old script just update 1.5.1 to 1.6.0
1.6.0 make all mysql function cant send variable to query, because it all have ["@variable"].

MySQL.ready(function()
	local test1 = MySQL.Sync.fetchAll('SELECT id FROM users WHERE identifier = ?',
	{
		"steam:11000010971396e"
	})
	print(test1[1])
	
	---------------------------
	
	local test2 = MySQL.Sync.fetchAll('SELECT id FROM users WHERE identifier = @identifier',
	{
		['@identifier'] = "steam:11000010971396e"
	})
	print(test2[1])
	
	---------------------------

	local test3 = MySQL.Sync.fetchAll('SELECT id FROM users WHERE identifier = @identifier',
	{
		['identifier'] = "steam:11000010971396e"
	})
	print(test3[1])
end)

@darksaid98
Copy link
Contributor

Yea that's what I thought. Seems there's been a regression in backward compatibility in 1.6.

I'm currently digging through the codebase patching another issue. I'll check later to see if this is trivial to re-introduce.

@darksaid98
Copy link
Contributor

This is the same issue as in your first post. Again, the issue is your database setup. You need to allow discord to be set to NULL.

@chaixshot
Copy link
Contributor Author

Yea that's what I thought. Seems there's been a regression in backward compatibility in 1.6.

I'm currently digging through the codebase patching another issue. I'll check later to see if this is trivial to re-introduce.

Ok, for now i will try this.

local function safeArgs(query, parameters, cb, transaction)
	if type(query) == 'number' then query = Store[query] end
	if transaction then
		assert(type(query) == 'table', ('A table was expected for the transaction, but instead received %s'):format(query))
	else
		assert(type(query) == 'string', ('A string was expected for the query, but instead received %s'):format(query))
	end
	if cb then
		assert(type(cb) == 'function', ('A callback function was expected, but instead received %s'):format(cb))
	end
	local type = parameters and type(parameters)
	if type and type ~= 'table' and type ~= 'function' then
		assert(nil, ('A %s was expected, but instead received %s'):format(cb and 'table' or 'function', parameters))
	end
	
	local nparameters = parameters
	if parameters then
		nparameters = {}
		for name, value in pairs(parameters) do
			nparameters[string.gsub(name, "@", "")] = value
		end
	end
	
	return query, nparameters, cb
end

@thelindat thelindat changed the title ERROR] null was unable to execute a query! Unable to execute named parameters using '@' in the parameter Oct 16, 2021
@thelindat thelindat added the bug Something isn't working label Oct 16, 2021
@thelindat
Copy link
Member

Yea that's what I thought. Seems there's been a regression in backward compatibility in 1.6.

I'm currently digging through the codebase patching another issue. I'll check later to see if this is trivial to re-introduce.

Can you confirm that both [':var'] and ['@var'] do not work? I'll have to look back to see what I've changed to break this (likely in the patch for named-parameters).

I'm on New World for now but if you don't find a solution before me then I'll take a look at it.

@chaixshot
Copy link
Contributor Author

chaixshot commented Oct 16, 2021

[':var'] and ['@var'] not working both.
image

@darksaid98
Copy link
Contributor

Fixed in #50.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants