Skip to content

Add User-Facing API#5

Merged
Conni2461 merged 16 commits intomasterfrom
dev
Jan 7, 2021
Merged

Add User-Facing API#5
Conni2461 merged 16 commits intomasterfrom
dev

Conversation

@kkharji
Copy link
Copy Markdown
Owner

@kkharji kkharji commented Dec 31, 2020

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 options
  • open_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 content
  • delete: 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

@kkharji kkharji force-pushed the dev branch 7 times, most recently from d9526c2 to bcaf9eb Compare December 31, 2020 09:06
@Conni2461

This comment has been minimized.

@Conni2461

This comment has been minimized.

@kkharji

This comment has been minimized.

@kkharji kkharji changed the title user facing low level apis Add User-Facing API Jan 4, 2021
* master:
  add methods, tests and inline docs for sql statements (#6)
@kkharji kkharji force-pushed the dev branch 4 times, most recently from e30cbcc to 6585046 Compare January 5, 2021 18:10
+ make sql.open work.
@kkharji kkharji force-pushed the dev branch 2 times, most recently from 5bf22d2 to 83b1fee Compare January 7, 2021 06:30
Comment on lines +45 to +47
if type(self) == 'string' or not self then
uri, self = self, sql
end
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are doing this so sql.open works? I don't even know if we should support that.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For consistency. Just always : similar to plenary.path

Copy link
Copy Markdown
Owner Author

@kkharji kkharji Jan 7, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason I'm I like sql.open, so I know I'm calling a function instead of something object method.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah i know what you mean

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

%s was at the wrong spot

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You forget the select part here

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ohhhh thats why

@Conni2461 Conni2461 merged commit b0aa93f into master Jan 7, 2021
@Conni2461 Conni2461 deleted the dev branch January 7, 2021 14:40
kkharji added a commit that referenced this pull request Aug 19, 2021
kkharji added a commit that referenced this pull request Aug 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants