Skip to content

Added option to bypass 'LIMIT 1' in find_one() - #115

Closed
numkem wants to merge 9 commits into
j4mie:masterfrom
numkem:master
Closed

numkem wants to merge 9 commits into
j4mie:masterfrom
numkem:master

Conversation

@numkem

@numkem numkem commented Apr 11, 2013

Copy link
Copy Markdown
Contributor

Hello,

I'm still working with SQL Server and idiorm and I noticed LIMIT isn't supported by SQL Server (there is another way to do it : SELECT TOP 1).

This cause a pretty big problem because it breaks the use of find_one() that forces a $this->limit(1) on every query.

Fixing _build_limit() could be the perfect option but because of how _build_limit() is implemented, it makes it a very hard thing to do.

This is a simple fix that includes a new option called find_one_limit. If this options is set to any value, the LIMIT 1 is bypassed.

Thanks.

@treffynnon

Copy link
Copy Markdown
Collaborator

Thank you for the pull request, but I am not sure I like this approach.
Have you seen the last pull request that was made for limit/top support in
Idiorm (now closed)?

@treffynnon

Copy link
Copy Markdown
Collaborator

Here is a link to the pull request I mentioned: #37

@numkem

numkem commented Apr 12, 2013

Copy link
Copy Markdown
Contributor Author

That would indeed be a lot better!

The only thing I would add is I'm using dblib as the pdo driver because mssql and sybase are only available on Windows.

If you want I could take this and apply the change for dblib and ask for another pull request?

Sebastien Bariteau and others added 4 commits April 12, 2013 07:29
…IT 1' done by find_one() by default. Useful for databases that doesn't support LIMIT (SQL Server)."

This reverts commit 5c195d5.
Conflicts:
	test/test_classes.php
	test/test_mssql.php
	test/test_queries.php
…idiorm.

Added case choice for dblib driver to use the TOP style limit.
@treffynnon

Copy link
Copy Markdown
Collaborator

I am not sure what is happening here with the code, but it doesn't look nice. Please could you create a new feature branch from idiorm:master and create a pull request against idiorm:develop by manually writing your code inspired by pull request #37. I think you have tried to merge their code in - it is worth noting that Idiorm has a changed a bit since that pull request was written.

There seems to be a load of old code coming back into Idiorm with your pull request. For example we do not want the old test files back in the project. New tests should be written with PHPUnit.

@numkem

numkem commented Apr 12, 2013

Copy link
Copy Markdown
Contributor Author

Oh I see... Sorry about that. Will do!

@numkem numkem closed this Apr 12, 2013
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.

2 participants