Skip to content
This repository has been archived by the owner on Sep 20, 2021. It is now read-only.

Fix SQLite scroll cursors fail #36

Merged
merged 2 commits into from
Apr 13, 2016
Merged

Conversation

Metalaka
Copy link
Member

@Metalaka Metalaka commented Apr 6, 2016

Fix #35

Hi,

I don't really like the getAttribute call but I don't see any other way to fix that properly.

NB: We need Hoa\Protocol since we do a call to resolve in Dal.php.

Metalaka added 2 commits April 6, 2016 19:53
SQLite fail to handle the scroll cursor option.
We can know if the driver support cursors by doing
an attribute request before our query.
$options[\PDO::ATTR_CURSOR] = \PDO::CURSOR_SCROLL;
try {
$this->getConnection()->getAttribute(\PDO::ATTR_CURSOR);
$options[\PDO::ATTR_CURSOR] = \PDO::CURSOR_SCROLL;
Copy link
Member

Choose a reason for hiding this comment

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

Actually, the ATTR_CURSOR is supported, but not the CURSOR_SCROLL value.

Copy link
Member Author

Choose a reason for hiding this comment

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

Did you try with this branch ?

I had the same error as you and this patch fix it (with sqlite3 on win10 x64)

Copy link
Member

Choose a reason for hiding this comment

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

Hmm, I will try. However, iterator support will no be longer be available if scroll cursor is not enabled. Should we throw an error then?

Copy link
Member

Choose a reason for hiding this comment

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

Also, if this patch works, then this is a bug in PDO with SQLite driver and we should open a bug on bugs.php.net, do you agree?

Copy link
Member Author

Choose a reason for hiding this comment

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

Also, if this patch works, then this is a bug in PDO with SQLite driver and we should open a bug on bugs.php.net, do you agree?

Yes.

Hmm, I will try. However, iterator support will no be longer be available if scroll cursor is not enabled. Should we throw an error then?

Forward only iterator will be available. Scrollable cursor is used to customize the fetch orientation.

Throw an error if the user want to use a feature which is not supported by the driver is interesting but we have to re-think the way we prepare our statement.
Currently we enable the scroll cursor before the user has chosen if he want to use the feature so we can't throw an error according to his choice.

Copy link
Member

Choose a reason for hiding this comment

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

Agree with your strategy. Are you willing to do a PR?

$this->getConnection()->getAttribute(\PDO::ATTR_CURSOR);
$options[\PDO::ATTR_CURSOR] = \PDO::CURSOR_SCROLL;
} catch (\PDOException $e) {
// Cursors isn't supported by the driver, see issue #35.
Copy link
Member

Choose a reason for hiding this comment

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

- isn't
+ are not

Fixed by me.

@Hywan
Copy link
Member

Hywan commented Apr 13, 2016

Thanks for the PR!

@Bhoat Bhoat merged commit 8153868 into hoaproject:master Apr 13, 2016
@Hywan Hywan removed the in progress label Apr 13, 2016
@Metalaka Metalaka deleted the fix/sqliteCursor branch April 13, 2016 12:02
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

Successfully merging this pull request may close these issues.

PDO + SQLite + CURSOR_SCROLL failed
3 participants