Jazz
Nov 6 2008, 02:54 PM
Hello All,
I Have an TLuaDB object, which iterates over a column of SQL Time stamps. The getCol(x) function returns a string which is Ok, however The The return val is of the form "Fri Oct 10 10:13:16 2008" or timedate.getTime("%a,%b,%c ") . This modified string, is complicating my further queries, as now the data has to be parsed before it can be fed back into another query.
Can anyone think of a away to retrieve the the SQL TimeStamp or a Lua TimeDate object, directly. without parsing against a Table? My hunch is that the SQL TS gets cast to a Lua timedate and subsequently returns the standard string representation. I'm curious if anyway knows a way around this that I'm missing.
Thanks
Jazz Alyxzander
It would be possible to add a function simlar to GetCol() that returns a TLuaDateTime instead of a string, I have to dig into it a bit however so we can settle on a sound implementation since once you add a function, you can never ever remove it.
GetCol() // Always return a string no matter what type of data, just like before
GetCol_AsDateTime() // returns a TLuaDateTime if the col. is TYPE_DATETIME
GetCol_AsNumeric // returns a numeric value if the col is TYPE_NUMERIC, TYPE_SHORT, TYPE_LONG or TYPE_BOOL
Feedback is welcome !
Jazz
Nov 9 2008, 05:08 AM
Adding functionality is always great however i think we can get the same affect without necessarily adding new functions, We can always run a Lua capture against the return string and create our own TLuaDateTime if needed.
A more sustainable solution would be to a function return a string representation that is compatible with both SQL and the TluaDateTime Class. When i call GetCol() on a time stamp i get a formated string of the form "Fri Oct 10 10:13:16 2008". One issue is Both SQL and the TLuaDateTime class accept Months in a numeric form. This requires a lookup against a table stored in memory to convert "Oct" to 10 and doesn't scale well in an multilingual setting, where the abbreviations are not be standardized.
I would suggest the format of the string be compatible with the source the data came from. Example a SQL timestamp should be of the form '<year>-<day>-<month> <time>' which is valid input back into a query {ts '1969-31-12 23:59:59'}
This way we can improve functionality, without needing to "java"-tize the library.
/Jazz
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please
click here.