Scan with Rows interface
This commit is contained in:
		
							parent
							
								
									6c827ff2e3
								
							
						
					
					
						commit
						9dd6ed9c65
					
				| @ -72,3 +72,13 @@ type Valuer interface { | ||||
| type GetDBConnector interface { | ||||
| 	GetDBConn() (*sql.DB, error) | ||||
| } | ||||
| 
 | ||||
| // Rows rows interface
 | ||||
| type Rows interface { | ||||
| 	Columns() ([]string, error) | ||||
| 	ColumnTypes() ([]*sql.ColumnType, error) | ||||
| 	Next() bool | ||||
| 	Scan(dest ...interface{}) error | ||||
| 	Err() error | ||||
| 	Close() error | ||||
| } | ||||
|  | ||||
							
								
								
									
										4
									
								
								scan.go
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								scan.go
									
									
									
									
									
								
							| @ -50,7 +50,7 @@ func scanIntoMap(mapValue map[string]interface{}, values []interface{}, columns | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| func (db *DB) scanIntoStruct(rows *sql.Rows, reflectValue reflect.Value, values []interface{}, fields []*schema.Field, joinFields [][2]*schema.Field) { | ||||
| func (db *DB) scanIntoStruct(rows Rows, reflectValue reflect.Value, values []interface{}, fields []*schema.Field, joinFields [][2]*schema.Field) { | ||||
| 	for idx, field := range fields { | ||||
| 		if field != nil { | ||||
| 			values[idx] = field.NewValuePool.Get() | ||||
| @ -99,7 +99,7 @@ const ( | ||||
| ) | ||||
| 
 | ||||
| // Scan scan rows into db statement
 | ||||
| func Scan(rows *sql.Rows, db *DB, mode ScanMode) { | ||||
| func Scan(rows Rows, db *DB, mode ScanMode) { | ||||
| 	var ( | ||||
| 		columns, _          = rows.Columns() | ||||
| 		values              = make([]interface{}, len(columns)) | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Jinzhu
						Jinzhu