Skip to content

dbQuery callback arguments cannot be functions #4327

@Rilot06

Description

@Rilot06

Describe the bug

When you use dbQuery as async with a callback, and you want to pass a function in the callbackArguments parameter table, it will become nil in the callback function.

function sayHello()
    print("Hello!")
end

dbQuery(function(qh, func)
    local result = dbPoll(qh, 0)

    func() -- You will get an error here, func will be nil
end, {sayHello}, dbConnection, "...")

Steps to reproduce

  1. Use async dbQuery with a callback
  2. Use the callbackArguments param, try to pass a function in that table
  3. Check the passed arg in the callback function, it will be nil

Version

Server: 1.6-release-23312

Additional context

I guess it happens because you can't reference that function after, even though it's the same resource, not sure how easy (or possible at all) a fix would be.
You could handle it in Lua every time, by storing the function in a global/top scope table and pass the index reference the function from that table (or even sending the function name and using _G), but it quickly becomes a hassle.

Relevant log output

Security Policy

  • I have read and understood the Security Policy and this issue is not security related.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions