Coder Social home page Coder Social logo

Comments (8)

rjmcguire avatar rjmcguire commented on May 12, 2024

This still happens for me. Just upgraded to this version. The above commit is in the source so I assume that I
am using the version where this is supposed to be fixed.
Any ideas?

from mysql.

rjmcguire avatar rjmcguire commented on May 12, 2024

It seems that you have made affectedrows=0 an error. Is that your intention?

from mysql.

julienschmidt avatar julienschmidt commented on May 12, 2024

No sorry, it seems like some code remained there after a (too) long coding night ...

from mysql.

rjmcguire avatar rjmcguire commented on May 12, 2024

I don't know how to commit back to my github.com repo to do a pull request
but here are the changes I did:
diff --git a/connection.go b/connection.go
index 3a3bb4c..4b6a09e 100644
--- a/connection.go
+++ b/connection.go
@@ -206,7 +206,7 @@ func (mc *mysqlConn) Exec(query string, args
[]driver.Value) (driver.Result, err
}

    if mc.affectedRows == 0 && mc.insertId == 0 {
  •           return driver.ResultNoRows, e
    
  •           return &mysqlResult{}, nil //driver.ResultNoRows, e
    }
    
    return &mysqlResult{
    

    diff --git a/statement.go b/statement.go
    index 746c9dc..dccc64f 100644
    --- a/statement.go
    +++ b/statement.go
    @@ -73,7 +73,7 @@ func (stmt mysqlStmt) Exec(args []driver.Value)
    (driver.Result, error) {
    }

    if stmt.mc.affectedRows == 0 {
    
  •           return driver.ResultNoRows, nil
    
  •           return &mysqlResult{}, nil //driver.ResultNoRows, nil
    }
    
    return mysqlResult{
    

On Wed, Feb 20, 2013 at 4:46 PM, Julien Schmidt [email protected]:

No sorry, it seems like some code remained there after a (too) long coding
night ...

β€”
Reply to this email directly or view it on GitHubhttps://github.com//issues/16#issuecomment-13835105.

from mysql.

julienschmidt avatar julienschmidt commented on May 12, 2024

Oops.. forgot the prepared statements.
The ResultNoRows error is for situations when LastInserID and AffectedRows aren't available, but in fact this is in MySQL never the case (every OK response packet contains these) so this code passage was complete nonsense.

The result of returning &mysqlResult{} is the same as returning just the normal result - both report 0 (default value) for LastInserID and AffectedRows

from mysql.

rjmcguire avatar rjmcguire commented on May 12, 2024

Thanks, I'm not sure if we're talking about the same thing but the reason I
had to change those lines is because driver.ResultNoRows.AffectedRows()
always returns an error.

BTW, thanks for implementing go-sql-driver. It works, and its always good
when something does what it says on the tin.

Cheers,

On Wed, Feb 20, 2013 at 5:03 PM, Julien Schmidt [email protected]:

Oops.. forgot the statements.
The ResultNoRows error is for situations when LastInserID and AffectedRowsaren't available, but in fact this is in MySQL never the case (every
OK response packet contains these) so this code passage was complete
nonsense.

The result of returning &mysqlResult{} is the same as returning just the
normal result - both repotz 0 for LastInserID and AffectedRows

β€”
Reply to this email directly or view it on GitHubhttps://github.com//issues/16#issuecomment-13836004.

from mysql.

julienschmidt avatar julienschmidt commented on May 12, 2024

Which error do you get? no RowsAffected available after DDL statement? This one should be fixed now πŸ˜„

BTW, thanks for reporting that something didn't work as expected πŸ˜‰

from mysql.

rjmcguire avatar rjmcguire commented on May 12, 2024

Thats the one.

Its from database/sql/sql.go if I remember correctly.

On Wed, Feb 20, 2013 at 5:17 PM, Julien Schmidt [email protected]:

Which error do you get? no RowsAffected available after DDL statement?
This one should be fixed now [image: πŸ˜„]

BTW, thanks for reporting that something didn't work as expected [image:
πŸ˜‰]

β€”
Reply to this email directly or view it on GitHubhttps://github.com//issues/16#issuecomment-13836777.

from mysql.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.