title: Error "query was not expected" on INSERT while unit testing using sqlmock
body: <p>I'm trying to run an unit test that executes an INSERT into DB, so I mocked exactly the same query string that the gorm log displays with the same arguments but I'm still having problem while trying to execute the test, (with postgres driver) because it seems like the sql-mock does not match the SQL that I defined in the mock and display an error like: </p>
  
  <pre><code>"**call to Query** 'INSERT  INTO "customer" ("customer_key","first_name","middle_name","last_surname") VALUES ($1,$2,$3,$4) RETURNING "customer"."customer_key"' with args 
  [{Name: Ordinal:1 Value:RLKuxK-wnj8SUn50iFMjsrCtikTLTEmUFP7fOSE2veI=}
   {Name: Ordinal:2 Value:Martín} {Name: Ordinal:3 Value:Constan} 
  {Name: Ordinal:4 Value:Smith}] 
  **was not expected** "
  </code></pre>
  
  <p><a href="https://play.golang.org/p/-HZ4YbexWsI" rel="nofollow noreferrer">GO Playgound Running example</a></p>
  
  <p><strong>repository.go</strong></p>
  
  <pre class="lang-golang prettyprint-override"><code>...
  func (r *repository) Register(customer *models.Customer) (*string, error) {
      err := r.db.Create(&amp;customer).Error
      if err != nil {
          return nil, err
      }
  
      return customer.CustomerKey, nil
  }
  ...
  </code></pre>
  
  <p><strong>repository_test.go</strong></p>
  
  <pre class="lang-golang prettyprint-override"><code>func TestRegister(t *testing.T) {
      qStr := `INSERT  INTO "customer" ("customer_key","first_name","middle_name","last_surname") 
      VALUES ($1,$2,$3,$4) RETURNING "customer"."customer_key"`
  
      t.Run("Must return the newly created customer key, if given customer input is valid", func(t *testing.T) {
          r := mocks.CustomerModel
  
          mock.MatchExpectationsInOrder(false)
          mock.ExpectBegin()
          mock.ExpectQuery(regexp.QuoteMeta(qStr)).
              WithArgs(r.CustomerKey, r.FirstName, r.MiddleName, r.LastSurname).
              WillReturnRows(sqlmock.NewRows([]string{"customer_key"}).AddRow(r.CustomerKey))
          mock.ExpectCommit()
          customerKey, err := repo.Register(r)
  
          assert.Nil(t, err)
          assert.NotNil(t, customerKey)
      })
  }
  </code></pre>
  
  <p>and I get the following error:</p>
  
  <pre><code>Running tool: /usr/local/go/bin/go test -timeout 30s /internal/customer -run ^(TestRegister)$
  call to Query 'INSERT  INTO "customer" ("customer_key","first_name","middle_name","last_surname") VALUES ($1,$2,$3,$4) RETURNING "customer"."customer_key"' with args [{Name: Ordinal:1 Value:RLKuxK-wnj8SUn50iFMjsrCtikTLTEmUFP7fOSE2veI=}
   {Name: Ordinal:2 Value:Martín} {Name: Ordinal:3 Value:Constan} 
  {Name: Ordinal:4 Value:Smith}] 
  was not expected &lt;----------------------ERROR-------------------------
  
  INSERT  INTO "customer" ("customer_key","first_name","middle_name","last_surname") VALUES ('RLKuxK-wnj8SUn50iFMjsrCtikTLTEmUFP7fOSE2veI=','Martín','','Constan','Smith'') RETURNING "customer"."customer_key"  
  [0 rows affected or returned ]
  
  [35m(data-repository/internal/customer/repository.go:57)[0m 
  [33m[2020-01-22 19:39:18][0m [31;1m call to Query 'INSERT INTO "customer" ("customer_key","first_name","middle_name","last_surname") VALUES ($1,$2,$3,$4) RETURNING "customer"."customer_key"' with args [{Name: Ordinal:1 Value:RLKuxK-wnj8SUn50iFMjsrCtikTLTEmUFP7fOSE2veI=} {Name: Ordinal:2 Value:Martín} {Name: Ordinal:3 Value:Constan} {Name: Ordinal:4 Value:Smith}] 
  was not expected &lt;----------------------ERROR AGAIN-------------------------
  
  --- FAIL: TestRegister (0.00s)
      --- FAIL: TestRegister/Must_return_the_newly_created_customer_key,_if_given_customer_input_is_valid (0.00s)
          data-repository/internal/customer/repository_test.go:89: 
                  Error Trace:    repository_test.go:89
                  Error:          Expected nil, but got: &amp;status.statusError{Code:13, Message:"An error occurred.", Details:[]*any.Any{(*any.Any)(0xc000215f90)}, XXX_NoUnkeyedLiteral:struct {}{}, XXX_unrecognized:[]uint8(nil), XXX_sizecache:0}
                  Test:           TestRegister/Must_return_the_newly_created_customer_key,_if_given_customer_input_is_valid
  FAIL
  FAIL    /internal/customer  0.008s
  FAIL
  Error: Tests failed.
  </code></pre>
  
  <p>I'm using the following versions:</p>
  
  <p><code>github.com/DATA-DOG/go-sqlmock v1.4.0</code> and
  <code>github.com/jinzhu/gorm v1.9.11</code></p>
  
  <p>I would appreciate any help... </p>