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

Remove LIMIT 1 for fetchOne #174

Merged
merged 1 commit into from
Oct 30, 2015
Merged

Remove LIMIT 1 for fetchOne #174

merged 1 commit into from
Oct 30, 2015

Conversation

jasin755
Copy link
Contributor

@jasin755 jasin755 commented Apr 2, 2015

setMaxResult(1) limits oneToMany/manyToMany associations.

setMaxResult(1) limits oneToMany/manyToMany associations.
@fprochazka
Copy link
Member

I'm not entirely sure about this... I know this criples toMany relations, but shouldn't it be a bit smarter? This might be a BC Break for some people. Better would be to use the doctrine paginator tool to fetch only first row.

@fprochazka fprochazka added the bug label Apr 4, 2015
@enumag
Copy link
Member

enumag commented Apr 4, 2015

Which makes this a duplicate of #118.

@fprochazka
Copy link
Member

Not really, since this is trying to solve it.

@jasin755
Copy link
Contributor Author

jasin755 commented Apr 7, 2015

In my opinion, fetchOne would be equivalent to getOneOrNullResult.

@fprochazka
Copy link
Member

@jasin755 I agree. But the problem is, what will it do, when I only remove the setMaxResults(1) and then run a query that returns more than one result? It throws. Which is a BC break.

Now that I think about it, I've opened 3.0-dev, so I might actually break it a bit.

@jasin755
Copy link
Contributor Author

jasin755 commented Apr 7, 2015

I would not see a problem in the exception. If used fetchOne and return to more rows the comrade made a mistake somewhere and can help him to reveal it (eg. by adding limit to query object)

@jasin755
Copy link
Contributor Author

Are you going to merge with 3.0@dev ?

@fprochazka
Copy link
Member

I probably will.

fprochazka added a commit that referenced this pull request Oct 30, 2015
Remove LIMIT 1 for fetchOne
@fprochazka fprochazka merged commit 03c2176 into Kdyby:master Oct 30, 2015
@matej21
Copy link
Contributor

matej21 commented Nov 13, 2015

yep, it is a bc break :\

Any idea how to setup maxResults? I cannot override fetchOne because getQuery is private..

@fprochazka
Copy link
Member

@matej21 what is your use case? do you wanna fetch one specific row, or just the first row from some result?

@matej21
Copy link
Contributor

matej21 commented Nov 13, 2015

@fprochazka I wanna fetch first row from the result

fprochazka added a commit that referenced this pull request Nov 13, 2015
This reverts commit 03c2176, reversing
changes made to 9c2f7dd.
@fprochazka
Copy link
Member

It was stupid of me to merge this in a hurry.

I'm reverting this 022976d and will tag v3.0.1 with the revert as a fix of the BC.
I'm also adding a new commit ed3ea61 that allows overriding the fetchOne, so you can change the behaviour if you know what you're doing (but you shouldn't, since that kills performance).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants