Skip to content

✨ use dot notiation with extended tbl object#92

Merged
kkharji merged 16 commits intomasterfrom
new/extended_tables_dot_notiation
Aug 22, 2021
Merged

✨ use dot notiation with extended tbl object#92
kkharji merged 16 commits intomasterfrom
new/extended_tables_dot_notiation

Conversation

@kkharji
Copy link
Copy Markdown
Owner

@kkharji kkharji commented Aug 22, 2021

Purpose

Try to make accessing table functions by dot notiation.

Details

When extending sql object or tables, there is rarely any case where the user need to pass self. Additionally, when dealing with tables inside db object, this db.tbl.insert {...} than db.tbl:insert {..}

I have no plans to support dot notation for db object as it would create confusion between accessing a table or call a method.

Changes:

  • Fix parsing schema key when using key value pairs.
  • access tbl original methods after overwrite with appending _, same goes to db extended object
    users.get = function()
      return users._get({ where = { id = 1 } })[1].name
    end
  • super lazy extend

TODO:

  • Update sql test related to extended tables
  • explore the possibility of using t._get() instead or t.tbl.get()
  • refactor tbl:extend
  • create new emmylua class definition for dot noted methods

followup:

  • create some examples in examples directory

@kkharji kkharji force-pushed the new/extended_tables_dot_notiation branch from 976dade to bd38ce1 Compare August 22, 2021 02:27
@kkharji kkharji merged commit 73d8fa6 into master Aug 22, 2021
@kkharji kkharji deleted the new/extended_tables_dot_notiation branch August 22, 2021 14:54
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.

1 participant