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

[5.6] add withSum to framework #25290

Closed
wants to merge 7 commits into from
Closed

[5.6] add withSum to framework #25290

wants to merge 7 commits into from

Conversation

spyp
Copy link

@spyp spyp commented Aug 22, 2018

check it out. in the past people try to add withSum withAvg and ...
and they try to extends the withCount method but i think this methods should be separate because in these methods we play with specific column but in withCount * is enough for that
i test it if you see this is useful add withAvg and etc because im not pro to do that. withSum is useful in
analyze funds and ...

add withSum to framework . in the past people try to add withMax withMin withAvg withSum and ... together and implements withCount
i think its should be separte because in withSum withAvg and... we should determine what column but in withCount we dont 
so i add withSum if you think its ok( i test it ) add withAvg and .... . im not pro to do that soory for my bad english
@deleugpn
Copy link
Contributor

Missing tests, but it's indeed one of the features I miss the most in the framework.

@spyp
Copy link
Author

spyp commented Aug 22, 2018

mm simple test
Operators::withSum('internet','amount')->get():
for simple and with conditions
Operators::withSum(['internet'=>function($query){ .... }] ,'amount')->get();:
hope this feature added to laravel for now its working and my problem solved but of course . you should check it .

@decadence
Copy link
Contributor

Not a chance it will be merged without tests.

@deleugpn
Copy link
Contributor

@decadence Agreed, but if there's a positive feedback, I can pick this up, write the tests and re-propose if the author can't write it.

@spyp I was talking about automation tests. Inside the framework there's a folder tests containing automation tests for every feature the framework offers. A feature like this requires test-code for quality purposes and to avoid other people from proposing changes that break it's functionality.

@spyp
Copy link
Author

spyp commented Aug 22, 2018

@deleugpn
i can write test but im not sure i create good coding . so if other peoples like this you test it and check my code its complicated and maybe i have mistake on that.
thanks

@decadence
Copy link
Contributor

decadence commented Aug 22, 2018

@deleugpn as far as I remember there was positive feedback on these PRs but they all missed proper tests which satisfy @taylorotwell. Anyway this is needed and would be cool if you can write them.

Ref:
#16815
#18303
#19363

laravel/ideas#600 (comment)

@spyp
Copy link
Author

spyp commented Aug 22, 2018

i will added and update here :)

add Tests for withSum
@deleugpn
Copy link
Contributor

Hey spyp, it's better if you add integration tests (tests/integration) instead of unit tests for this kind of feature.
It's good to have an automation process that checks if the code works against a real database because it's possible that the assertion passes but the query is incorrect.
They are pretty easy to write as well and you get to make assertion on real values.

@spyp
Copy link
Author

spyp commented Aug 22, 2018

ok i'll add real database too.

@taylorotwell
Copy link
Member

I don't see a big point in adding functions like getRelationshipSumQuery. It feels like it should be generalized to handle all aggregates. Not just sum.

@spyp
Copy link
Author

spyp commented Aug 22, 2018

you are right. i will try to add other aggregates too .

@spyp spyp mentioned this pull request Aug 24, 2018
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.

5 participants