lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Can you encoded it/decode it as NaN (0/0)?

Not perfect but gets you there.

Here is how to create NaN value in lua - simply
nan_value = 0/0

http://lua-users.org/wiki/InfAndNanComparisons


On 11/10/2011 12:40 AM, HyperHacker wrote:
I'm using lsqlite3 with prepared statements like (simplified example):

local stmt = db:prepare("INSERT INTO items (x, y, z) VALUES (?, ?, ?)")
stmt:bind_values(a, b, c)
stmt:step()
stmt:finalize()

The problem is if, for example, a is nil and x is a numeric, nullable
type such as INTEGER, x ends up being not null but zero. Seemingly the
only way to actually insert null is to explicitly specify it in the
query, instead of as a parameter, which kinda defeats the purpose of
parameters. Is there some workaround?