From eb3dc55fdfd4d3bfd8c8ece928dd87af92e1ef68 Mon Sep 17 00:00:00 2001 From: Salvador Ortiz Date: Thu, 24 Mar 2016 03:05:54 -0600 Subject: [PATCH] Support for .execute method at Connection level Prepared statements can be expensive or unavailable for some drivers, so Connection.do can skip 'prepare' when no @params given and the driver support direct execution implementing the .execute method in its Connection class. MySQL in particular can't prepare some kinds of statements. --- lib/DBDish/Connection.pm6 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/DBDish/Connection.pm6 b/lib/DBDish/Connection.pm6 index dff875dc..88f0f26d 100644 --- a/lib/DBDish/Connection.pm6 +++ b/lib/DBDish/Connection.pm6 @@ -45,7 +45,9 @@ method new(*%args) { method prepare(Str $statement, *%args) { ... } method do(Str $statement, *@params, *%args) { - with self.prepare($statement) { + if !@params && self.can('execute') { + self.execute($statement, |%args); + } orwith self.prepare($statement, |%args) { LEAVE { .finish } .execute(@params, |%args); }