Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ use dot notiation with extended tbl object #92

Merged
merged 16 commits into from
Aug 22, 2021

Conversation

kkharji
Copy link
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