[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: new "empty" value/type in Lua?
- From: Tim Hill <drtimhill@...>
- Date: Fri, 28 Jun 2013 15:56:24 -0700
You can do this of course, but only at the expense of not using arrays to hold rows. I guess more or less what I'm saying is this:
-- The cleanest, most obvious way to map a SQL row into Lua is as a Lua array.
-- Most databases have numbers, strings, boolean (maybe), NULL and BLOB (maybe)
-- Again, there is an obvious clean mapping of each database type to a Lua type (BLOBs aside)
-- Except if SQL NULL maps to nil, you cannot put the NULL (=nil) value into the array
So you either have to map NULL to something other than nil, or choose a different representation in Lua, which means moving away from the obvious mapping to a non-obvious one to work-around the nil-array problem. At this point, in my mind, you are swimming upstream *against* the language, rather than having it help you (which, in most other ways, Lua excels at).
On Jun 28, 2013, at 2:30 PM, Petite Abeille <firstname.lastname@example.org> wrote:
> On Jun 28, 2013, at 11:17 AM, Tim Hill <email@example.com> wrote:
>> No-one has answered my original question: How can I write a CLEAN C library that emits a SQL rowset that might include NULL values? Without "empty", I cannot see a clean way to do this.
> Again, as spelled out by Rena among others, what's so fundamentally wrong with mapping null to nil?!? I'm personally doing it every day, in and out, and don't feel like I'm missing anything at all. But perhaps it's just me…