diff --git a/CHANGELOG.md b/CHANGELOG.md index 3f0f8fe5f06eb8e31cc321acdf21d1d46c277bf3..46da65231f09e8cbff3df8340166d26d1feb5942 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,6 +35,7 @@ The format is based on [keep a changelog](http://keepachangelog.com) and this pr - Listing user groups no longer returns an error when the user is a member of zero groups. - Go runtime group creation now correctly validates max count. - Consistent expiry calculation in leaderboard records haystack queries. +- Convert custom SQL query and exec parameters to integers where appropriate. ## [2.6.0] - 2019-07-01 ### Added diff --git a/server/core_wallet.go b/server/core_wallet.go index a0d99c138b76e4b8d15b9658624562ce83624e0f..427ae6b2ccdf29d7bcf7b7c03e0d40310c5cc551 100644 --- a/server/core_wallet.go +++ b/server/core_wallet.go @@ -304,6 +304,12 @@ func applyWalletUpdate(wallet map[string]interface{}, changeset map[string]inter return nil, fmt.Errorf("wallet update rejected negative value at path '%v'", currentPath) } wallet[k] = newValue + } else if changesetValue, ok := v.(int64); ok { + newValue := existingValue + float64(changesetValue) + if newValue < 0 { + return nil, fmt.Errorf("wallet update rejected negative value at path '%v'", currentPath) + } + wallet[k] = newValue } else { return nil, fmt.Errorf("update changeset does not match existing wallet value number type at path '%v'", currentPath) } @@ -325,6 +331,12 @@ func applyWalletUpdate(wallet map[string]interface{}, changeset map[string]inter return nil, fmt.Errorf("wallet update rejected negative value at path '%v'", currentPath) } wallet[k] = changesetValue + } else if changesetValue, ok := v.(int64); ok { + if changesetValue < 0 { + // Do not allow setting negative initial values. + return nil, fmt.Errorf("wallet update rejected negative value at path '%v'", currentPath) + } + wallet[k] = float64(changesetValue) } else { // Incoming value is not a map or float. return nil, fmt.Errorf("unknown update changeset value type at path '%v', expecting map or float64", currentPath) diff --git a/server/runtime_lua_context.go b/server/runtime_lua_context.go index 124ed9868628bdc49087ae2a673605122b6460d6..b1160d5092551d48217b81b30b946ed0573f160d 100644 --- a/server/runtime_lua_context.go +++ b/server/runtime_lua_context.go @@ -171,7 +171,13 @@ func RuntimeLuaConvertLuaValue(lv lua.LValue) interface{} { case lua.LString: return string(v) case lua.LNumber: - return float64(v) + vf := float64(v) + vi := int64(v) + if vf == float64(vi) { + // If it's a whole number use an actual integer type. + return vi + } + return vf case *lua.LTable: maxn := v.MaxN() if maxn == 0 {