Android Bug When Using SQL Table Aliases

I've reported this through the bug submission form, but I thought I'd put it here in case anyone else runs into the same problem. It took a couple of hours to trace this one down since I had to do builds to the android device to finally narrow down the line of code giving the problem.

This bug only occurs on android devices. The code works fine on the simulator and on iOS devices.

The bug occurs when creating SQL with a table alias. The app is able to correctly grab data from iOS devices but the data returns nil on Android devices.

Here's some mock SQL that serves as an example:

local sql="SELECT distinct v.item_id FROM inventory v, items e WHERE v.item_id=e.item_id";
for row in db:nrows(sql) do
local item_id=row.item_id;
end

In this example, item_id will result in a nil value regardless of the value returned in the sql dataset. However, this modded SQL statement will work correctly:

local sql="SELECT distinct v.item_id as item_id FROM inventory v, items e WHERE v.item_id=e.item_id";

The bug seems rooted in the fact that the table has an alias and android is handling this differently than iOS.

views:1736 update:2012/2/9 11:37:26
corona forums © 2003-2011