-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
IBM_DB2 platform doesn't handle offset without limit #2463
Conversation
a0951db
to
fefc8fe
Compare
9175755
to
2f618f6
Compare
2f618f6
to
4399103
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Patch is good, just some minor CS adjustments required.
$where[] = sprintf('db22.DC_ROWNUM <= %d', $offset + $limit); | ||
} | ||
|
||
if (count($where) === 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you use empty()
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. Just trying to understand the requirements, is empty($array)
somehow better than count($array)
? IMO, empty()
is prone to typos like empty($were)
which one may not notice w/o running tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@morozov this is just about minor optimizations. empty()
is a language construct and much more efficient than using the function count()
. The point about typos is a good point, but in DBAL we try to code as much performance efficient as possible even if it seems neglible. Thanks for changing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@deeky666 gotcha, thanks, will keep that in mind in the future.
|
||
// Todo OVER() needs ORDER BY data! | ||
$sql = 'SELECT db22.* FROM (SELECT db21.*, ROW_NUMBER() OVER() AS DC_ROWNUM '. | ||
'FROM (' . $query . ') db21) db22 WHERE db22.DC_ROWNUM BETWEEN ' . ($offset+1) .' AND ' . ($offset+$limit); | ||
$sql = sprintf( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you return early here like return sprintf()
?
4399103
to
f8ca032
Compare
@morozov thanks for your effort! |
Backported to |
There's a non-empty table
users
. The following script should return all existing record IDs.It does so on Oracle, SQL Server and MySQL, but returns empty result on DB2. The reason is that resulting SQL has a condition like
WHERE db22.DC_ROWNUM BETWEEN 1 AND 0
.