github.com/octohelm/storage@v0.0.0-20240516030302-1ac2cc1ea347/internal/sql/scanner/nullable/null_ignore_scanner.go (about)

     1  package nullable
     2  
     3  import (
     4  	"database/sql"
     5  	_ "unsafe"
     6  )
     7  
     8  func NewNullIgnoreScanner(dest interface{}) *NullIgnoreScanner {
     9  	return &NullIgnoreScanner{
    10  		dest: dest,
    11  	}
    12  }
    13  
    14  type NullIgnoreScanner struct {
    15  	dest interface{}
    16  }
    17  
    18  func (scanner *NullIgnoreScanner) Scan(src interface{}) error {
    19  	if scanner, ok := scanner.dest.(sql.Scanner); ok {
    20  		return scanner.Scan(src)
    21  	}
    22  	if src == nil {
    23  		return nil
    24  	}
    25  	return convertAssign(scanner.dest, src)
    26  }
    27  
    28  //go:linkname convertAssign database/sql.convertAssign
    29  func convertAssign(dest, src interface{}) error