Skip to content

Overrides getAttributesForInsert & getDirtyForUpdate instead of performInsert & performUpdate to #88

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

Merged
merged 3 commits into from
Jul 21, 2024

Conversation

RomainMazB
Copy link
Contributor

This fix #87 by decreasing the code override from the Eloquent Model class.

  • Instead of overriding the whole performInsert method, we now override the getAttributesForInsert method which only cares about getting the attributes to be inserted into the database.
  • Instead of overriding the whole performUpdate method, we now override the getDirtyForUpdate method which only cares about getting the modified attributes to be updated into the database.

@saibotk saibotk self-requested a review May 17, 2024 15:15
@saibotk saibotk self-assigned this May 17, 2024
@saibotk
Copy link
Member

saibotk commented May 17, 2024

Wow, thank you very very much for the quick response on this!
Also this looks very good and much better.

Can we maybe add a simple test case to prevent regressions in the future? Something like a quick model event test?
Also a small entry in the changelog would be nice.

Thank you so much!

@saibotk
Copy link
Member

saibotk commented May 17, 2024

I just saw, we do not have a proper eloquent test ready, so see this as optional if it is too much for now, we will do it later anyway.

@RomainMazB
Copy link
Contributor Author

I'll write a test to avoid future regression, it's not a problem.

Probably during the weekend or on Monday.

@RomainMazB
Copy link
Contributor Author

Just re-thinking about it.

Adding database tests means that github actions will now need to run postgres + postgis to valid the tests.

I am not familiar with github actions so I can't provide a PR on that. What do you recommend?

@saibotk
Copy link
Member

saibotk commented May 19, 2024

Dont worry i can add those later thank you 🙏

Copy link
Member

@saibotk saibotk left a comment

Choose a reason for hiding this comment

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

Sorry for taking so long! Was really swamped in the last weeks.

Just checked the code and this looks very good!
It is a much cleaner solution and both methods fit perfectly for our use case!

Note: I might add tests later on, but that depends on how we will implement this in v2, where we might switch to casters anyway.

Thank you so much for looking into this! We really really appreciate the effort!

@saibotk
Copy link
Member

saibotk commented Jun 3, 2024

Oh @RomainMazB, can you quickly run composer fix and add an entry to the CHANGELOG.md about this fix?

If not i can also do that :)

@saibotk saibotk enabled auto-merge July 21, 2024 21:19
Copy link
Member

@djfhe djfhe left a comment

Choose a reason for hiding this comment

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

LGTM!

@saibotk saibotk merged commit d63bd05 into clickbar:main Jul 21, 2024
35 checks passed
@maximepvrt
Copy link

@saibotk can you release this fix ?

@saibotk
Copy link
Member

saibotk commented Aug 8, 2024

done @maximepvrt sry should have done that sooner!

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.

Geometry fields are passed as Expression during Eloquent model event are fired.
4 participants