rettama / luadbi

Automatically exported from code.google.com/p/luadbi
MIT License
0 stars 0 forks source link

Suggestion to further improve connection and statement registration #30

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
I spent some time messing with the Debian luadbi package trying to get it work 
with LUA 5.2 before I realised that this work had already been performed 
recently.  I arrived at a similar solution to the issue but there are a couple 
of advantages to the way I did it that could be useful to apply.

Firstly, I have factored out the code that is used to register the LUA for 
connection and statement objects into a single function.  This means any 
further changes can be made in one place.

Secondly, I have amended the registration code to no longer create global 
variables or pollute the package.loaded table.  This also allows the Connect 
method to be simplified and not contain conditional code based on the LUA 
version.

I have tested this with LUA 5.1 and LUA 5.2 against SQLite3 and DB2 and it is 
working nicely for me.  However, please note that I have never used the LUA C 
API before this week so there may be subtle problems with the code I haven't 
noticed.

I thought it was worth sharing though.

Original issue reported on code.google.com by lbbrow...@gmail.com on 14 Jun 2015 at 5:19

Attachments: