Skip to content
This repository was archived by the owner on Dec 14, 2019. It is now read-only.

Enable "u()" shortcut also for empty tables #61

Merged
merged 2 commits into from
Mar 22, 2019

Conversation

ajthinking
Copy link
Collaborator

@ajthinking ajthinking commented Mar 21, 2019

I was about to check out issue 50, but after testing

laravel new tinx-issue-50
composer require ajthinking/tinx
php artisan tinx
>>u()::someStatic()

I got PHP Fatal error: Call to undefined function u() in Psy Shell code on line 1

It seems the shortcut to App\User also required at least one item in the database. That makes sense for $u and $u_ but u() can be needed in other situations where table is still empty. Hence I moved it outside of the try block. What do you think?

ajthinking and others added 2 commits March 21, 2019 14:22
…and up one level. Patched various "tableless_models" issues. Checking shortcut variables/functions exist before adding them to "names()" table. Dispatching initial "names()" render event via "includes" file instead of Tinx command (for variable/function existence check).
@furey furey merged commit e00880a into master Mar 22, 2019
@furey
Copy link
Owner

furey commented Mar 22, 2019

Hi @ajthinking,

Looking into this deeper, it appears there were various issues around tableless_models causing strange behaviour with Tinx's defined shortcuts in general.

I've just patched (hopefully) all those issues on top of your PR and merged it back into master, pushing a new v2.3.0 release.

If you have time, can you pull in v2.3.0 and confirm the tableless_models configuration option works as it always should have, namely…

  • If set to false, only models with database tables return working shortcuts via names()
  • If set to true, all models/classes found in model_paths configuration option paths return working shortcuts via names()

Cheers!

@ajthinking
Copy link
Collaborator Author

ajthinking commented Mar 22, 2019

Ops, you're right! Thanks! Just tested 2.3.0 and it works! $u / $u_ are not defined when tableless_models=false for a non existing DB. 👍

Though a small issue with function shortcuts (?). Even though u() does not list in names() for false it is still available for execution.

I can dig into it later.
PS nice find on the Observer/Serviceprovider-bug

furey added a commit that referenced this pull request Mar 22, 2019
@furey
Copy link
Owner

furey commented Mar 22, 2019

Hi @ajthinking,

Nice catch dude!

I've just pushed a v2.3.1 patch release that (hopefully) fixes that function shortcut issue.

The patch undoes what your PR originally did (you moved the function shortcut definition outside of the try/catch block; I moved it back again), but I think we've ended up where the codebase should have been when we started, so all the back and forth was worth it!

Cheers!

🤓🙏🤓

@furey furey deleted the enable-shortcut-for-empty-tables branch March 22, 2019 07:51
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants