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

DB Query #89

Closed
Rochet2 opened this issue Jul 4, 2014 · 2 comments
Closed

DB Query #89

Rochet2 opened this issue Jul 4, 2014 · 2 comments

Comments

@Rochet2
Copy link
Member

Rochet2 commented Jul 4, 2014

Possible bug comparing 2 bigint columns in DB and then trying to compare them and fetch the result to lua.

Prints 1 for all on my machine and 0 for all on someone else's computer.
In both cases / any case getting a string, int64 or uint64 will be correct.
I may have bad MySQL version distorting the result. (Higher than TC supported)

local Q = CharDBQuery("select (a >= b) from table;")
if (Q) then
    print(Q:GetColumnCount())
    print(Q:GetRowCount())
    print()
    print(Q:GetBool(0))
    print(Q:GetUInt8(0))
    print(Q:GetUInt16(0))
    print(Q:GetUInt32(0))
    print(Q:GetUInt64(0))
    print(Q:GetInt8(0))
    print(Q:GetInt16(0))
    print(Q:GetInt32(0))
    print(Q:GetInt64(0))
    print(Q:GetFloat(0))
    print(Q:GetDouble(0))
    print(Q:GetString(0))
    print(Q:GetCString(0))
    print(Q:IsNull(0))
else
    print("Q_Q")
end
@Rochet2 Rochet2 added the bug label Jul 4, 2014
@Rochet2
Copy link
Member Author

Rochet2 commented Sep 7, 2014

This is not Eluna related.

@Rochet2
Copy link
Member Author

Rochet2 commented Nov 23, 2014

It seems that all non defined types like COUNT(*) SELECT 1; and boolean return values like in example above and are BIGINT.
What this means that any non column or set type is a BIGINT or DECIMAL

For proper return value type refer to mysql documentation of function return value and use appropriate data type in lua.
http://dev.mysql.com/doc/refman/5.5/en/arithmetic-functions.html
http://dev.mysql.com/doc/refman/5.5/en/mathematical-functions.html
.. and similar docs

This is an important notice when coding and ignoring data types of DB. One should not as it can distort the results completely, even if the value you fetch is within given range.
We should possibly implement uint64 as a proper object instead of string to be able to do math with it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant