title: Confused about custom types in SQL when sql.DB.Exec
body: <p>Having this table structure:</p>
  
  <pre><code>CREATE TABLE `tableName` (
      `Id` int unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY,
      `Status` enum('pending','rejected','sent','invalid') NOT NULL,
      `Body` varchar(255) NULL
  ) ENGINE='MyISAM' COLLATE 'utf8_general_ci';
  </code></pre>
  
  <p>I have this (not complete) code <strong>working fine</strong>:</p>
  
  <pre><code>type StatusEnum string
  
  const (
      STATUS_PENDING  StatusEnum = "pending"
      STATUS_REJECTED StatusEnum = "rejected"
      STATUS_SENT     StatusEnum = "sent"
      STATUS_INVALID  StatusEnum = "invalid"
  )
  
  func (s *StatusEnum) Scan(src interface{}) error {
      if src == nil {
          return errors.New("This field cannot be NULL")
      }
  
      if stringStatus, ok := src.([]byte); ok {
          *s = StatusEnum(string(stringStatus[:]))
  
          return nil
      }
  
      return errors.New("Cannot convert enum to string")
  }
  
  func (s *StatusEnum) Value() (driver.Value, error) {
      return []byte(*s), nil
  }
  
  type EmailQueue struct {
      Id        uint64
      Status    StatusEnum
      Body      sql.NullString
  }
  
  func Save (db *sql.DB) error {
      _, err = db.Exec(
          "UPDATE `tableName` SET `Status` = ?, `Body` = ? WHERE `id` = ?",
          &amp;eqi.Status,
          eqi.Body,
          eqi.Id,
      )
  
      return err
  }
  </code></pre>
  
  <p>So my question is: <strong>Why do I need to use pointer reference (<code>&amp;eqi.Status</code>) on <code>db.Exec</code>?</strong></p>
  
  <p>Both <code>sql.NullString</code> and my custom <code>StatusEnum</code> are not implemented in <code>github.com/go-sql-driver/mysql</code>, so why the difference?</p>
  
  <p>If I don't use the pointer reference (<code>eqi.Status</code>), I'm getting this error (throwing in <a href="https://golang.org/src/database/sql/convert.go#L37" rel="nofollow" title="database/sql/convert.go">database/sql/convert.go</a>):</p>
  
  <pre><code>sql: converting Exec argument #0's type: unsupported type emailqueue.StatusEnum, a string
  </code></pre>
  
  <p>I was trying to implement some other interfaces I've found with no luck.</p>
  
  <p>I have other custom types implemented with <code>sql.Scanner</code> and <code>sql.driver.Valuer</code> interfaces, but the problem is the same.</p>
  
  <p>I was guessing about <code>struct</code> and type inheritance differentiation, but I couldn't get any hint on that... :(</p>
  
  <p>Please help to understand what's going on. Thanks!!! :)</p>