فهرست منبع

is a DML query as well, make sure it is prepared. Fixes #117

Nimi Wariboko Jr 11 سال پیش
والد
کامیت
cf160bc451
1فایلهای تغییر یافته به همراه8 افزوده شده و 1 حذف شده
  1. 8 1
      conn.go

+ 8 - 1
conn.go

@@ -359,9 +359,16 @@ func (c *Conn) executeQuery(qry *Query) *Iter {
 	stmtType := op.Stmt
 	if n := strings.IndexFunc(stmtType, unicode.IsSpace); n >= 0 {
 		stmtType = strings.ToLower(stmtType[:n])
+		switch stmtType {
+		case "begin":
+			stmtTail := strings.TrimSpace(stmtType[n:])
+			if n := strings.IndexFunc(stmtTail, unicode.IsSpace); n >= 0 {
+				stmtType = stmtType + " " + strings.ToLower(stmtTail[:n])
+			}
+		}
 	}
 	switch stmtType {
-	case "select", "insert", "update", "delete":
+	case "select", "insert", "update", "delete", "begin batch":
 		// Prepare all DML queries. Other queries can not be prepared.
 		info, err := c.prepareStatement(qry.stmt, qry.trace)
 		if err != nil {