Conversation
d9526c2 to
bcaf9eb
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
* master: add methods, tests and inline docs for sql statements (#6)
e30cbcc to
6585046
Compare
+ make sql.open work.
5bf22d2 to
83b1fee
Compare
| if type(self) == 'string' or not self then | ||
| uri, self = self, sql | ||
| end |
There was a problem hiding this comment.
You are doing this so sql.open works? I don't even know if we should support that.
There was a problem hiding this comment.
For consistency. Just always : similar to plenary.path
There was a problem hiding this comment.
The reason I'm I like sql.open, so I know I'm calling a function instead of something object method.
There was a problem hiding this comment.
Yeah i know what you mean
There was a problem hiding this comment.
But we settled on objects so i think we should stick with them
|
|
||
| local parse_join = function(join, tbl) | ||
| if not join and not tbl then return end | ||
| if not join or not tbl then return {} end |
There was a problem hiding this comment.
tbl is most of the times given, so that function was running even tho we hadn't have any join. or fixes that
returning {} rather then nil fixed all other tests
| end | ||
| end)() | ||
| return string.format("inner join on %s %s %s", target, on, select) | ||
| return string.format("inner join %s on %s %s", target, on, select) |
There was a problem hiding this comment.
%s was at the wrong spot
There was a problem hiding this comment.
Yah this the force push I failed to push after your comment
| local inner_eval = function(tbl, p) | ||
| return self:eval(self:parse("select", { | ||
| tbl = tbl, | ||
| select = p and p.select or nil, |
There was a problem hiding this comment.
You forget the select part here
API:
open: create connection,isopen: check if database is opened and connected.isclose: check if database is closed.eval: basic evaluation of sql statements.eval: deals with data provided as parameter and optionsopen_with: connect to db, execute a function, then close.insert: insert data to a table, create the table if it isn't already existed based on key name and value (properly a bad idea)update: given an id update the contentdelete: delete a row or the whole table content if no row id is given.find: given a tablename and id return the content of that id row, and given a table with keys equivalent to sqlite table return match