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

Why can't "do" return rows? #185

Closed
JJ opened this issue May 29, 2020 · 2 comments
Closed

Why can't "do" return rows? #185

JJ opened this issue May 29, 2020 · 2 comments

Comments

@JJ
Copy link
Contributor

JJ commented May 29, 2020

Aparently, it's just a matter of adding a "return" in the two alternative statements.

https://github.com/raku-community-modules/DBIish/blob/master/lib/DBDish/Connection.pm6#L103-L119

As a matter of fact, it's doing a prepare + execute.
If it does not, couldn't a multi or another method do that, instead of just returning an error? It does not seem fair to force the user to do a prepare + execute.

@rbt
Copy link
Collaborator

rbt commented May 29, 2020

I'm in favour of changing do() to issue the query and return results. Docs can warn about the inefficiencies of preparing a statement multiple times.

There are lots of statements taking parameters will be executed infrequently (or once).

@rbt
Copy link
Collaborator

rbt commented Jun 4, 2020

In Perl the DBI module avoids prepare/execute for do() statements. They are generally executed directly. It appears to be largely a work-around for drivers which cannot prepare DDL commands.

Raku doesn't have any of those drivers yet and the driver should probably handle it transparently by letting prepare() do different things internally.

Also, both README.pod and examples/*p6 files show my $sth = $dbh.do(...). That's actually incorrect as it returns the number of records modified (in at least some cases) and does not return a statement handle; but I think the docs have the right approach and the code should be changed.

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

No branches or pull requests

2 participants