A 5.3 change is biting us hard...
[
Date Prev][
Date Next][
Thread Prev][
Thread Next]
[
Date Index]
[
Thread Index]
- Subject: A 5.3 change is biting us hard...
- From: Marc Balmer <marc@...>
- Date: 2016年2月10日 17:26:24 +0100
We switched from Lua 5.2 to Lua 5.3 and suddenly a seemingly small change in Lua's number formatting is hitting us really hard:
Before 5.2, a number value of 41.0 would produce a string of '41'. After 5.3, it produces '41.0':
Lua 5.2.3 Copyright (C) 1994-2013 Lua.org, PUC-Rio
> a = 41.0
> print(a)
41
Lua 5.3.2 Copyright (C) 1994-2015 Lua.org, PUC-Rio
> a = 41.0
> print(a)
41.0
This little detail becomes "great" fun when you use numbers as integers in SQL statement:
local id = tonumber(query.id) -- Get the id from a string in a webform
local res = db:execParams('select * from foo where id = 1ドル::integer', id)
In PostgreSQL this results in an error like "Invalid input syntax for type integer: 41.0".
I will find a way to deal with this (probably in the luapgsql interface), for now I just wanted to share the fun ;)