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

hidden attribute cannot be found using dot notation #534

Closed
circulon opened this issue Dec 8, 2021 · 5 comments
Closed

hidden attribute cannot be found using dot notation #534

circulon opened this issue Dec 8, 2021 · 5 comments
Labels
bug An existing feature is not working as intended

Comments

@circulon
Copy link
Contributor

circulon commented Dec 8, 2021

Describe the bug
Previously if an attribute was in the hidden list on the model it was only hidden from serialization not when getting the value using dot notation eg myModel.some_att

Not sure when this changed , but now when using dot notation to get attributes (that are hidden from serialization) an error similar to the following:
AttributeError: class model 'myModel' has no attribute some_att

To Reproduce
Steps to reproduce the behavior:

  1. add a model
  2. add attributes to fillable including the attribute to be hidden
  3. add attribute to be hidden to hidden
  4. save a model in any way you like to create a db row
  5. load the model from the primary key id
  6. print the hidden attribute via "print("hidden att {}".format(model.hidden_att_name))
  7. See error

Expected behavior
the value of the attribute should be returned

Desktop (please complete the following information):

  • OS: Mac OSX
  • Version 10.15.7

What database are you using?

  • Type: Postgres
  • Version 10.12
  • Masonite ORM 1.0.63
@circulon circulon added the bug An existing feature is not working as intended label Dec 8, 2021
@josephmancuso
Copy link
Member

I can't replicate this behavior. Can you provide more information maybe?
Screen Shot 2021-12-09 at 6 25 49 PM

@circulon
Copy link
Contributor Author

@josephmancuso

In your example you are using the created model instance straight after creating it.
This may be a hydration issue when populating the model at some point well after it was created is the issue.

As I noted above can you try getting the the model into a new var via the primary key .find(pk) or .first()
this will hydrate the model from the select directly

I will also investigate further and rollback to previous ORM versions to establish when this changed (or if its just me ;)

Thanks

@josephmancuso
Copy link
Member

Thats what i tried originally but it was working.
Screen Shot 2021-12-10 at 8 49 55 AM

@josephmancuso
Copy link
Member

@circulon are you doing something more than these steps before this call?

@josephmancuso
Copy link
Member

I don't believe this is an issue. Try updating to latest version. will reopen if new information comes out

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An existing feature is not working as intended
Projects
None yet
Development

No branches or pull requests

2 participants