Merge 2061f6a01287479b9c53d9bf200760ba2201a26e into 45fc640bf3042a9b424f7cd00ec096d919b2009f
This commit is contained in:
		
						commit
						12414b3d52
					
				
							
								
								
									
										37
									
								
								scope.go
									
									
									
									
									
								
							
							
						
						
									
										37
									
								
								scope.go
									
									
									
									
									
								
							@ -1227,21 +1227,50 @@ func (scope *Scope) getColumnAsArray(columns []string, values ...interface{}) (r
 | 
			
		||||
				var result []interface{}
 | 
			
		||||
				var object = indirect(indirectValue.Index(i))
 | 
			
		||||
				for _, column := range columns {
 | 
			
		||||
					result = append(result, object.FieldByName(column).Interface())
 | 
			
		||||
					field := object.FieldByName(column)
 | 
			
		||||
					if isNil(field) {
 | 
			
		||||
						continue
 | 
			
		||||
					}
 | 
			
		||||
					result = append(result, field.Interface())
 | 
			
		||||
				}
 | 
			
		||||
				if len(result) > 0 {
 | 
			
		||||
					results = append(results, result)
 | 
			
		||||
				}
 | 
			
		||||
				results = append(results, result)
 | 
			
		||||
			}
 | 
			
		||||
		case reflect.Struct:
 | 
			
		||||
			var result []interface{}
 | 
			
		||||
			for _, column := range columns {
 | 
			
		||||
				result = append(result, indirectValue.FieldByName(column).Interface())
 | 
			
		||||
				field := indirectValue.FieldByName(column)
 | 
			
		||||
				if isNil(field) {
 | 
			
		||||
					continue
 | 
			
		||||
				}
 | 
			
		||||
				result = append(result, field.Interface())
 | 
			
		||||
			}
 | 
			
		||||
			if len(result) > 0 {
 | 
			
		||||
				results = append(results, result)
 | 
			
		||||
			}
 | 
			
		||||
			results = append(results, result)
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	return
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func isNil(v reflect.Value) bool {
 | 
			
		||||
	if v.Kind() == reflect.Ptr && v.IsNil() {
 | 
			
		||||
		return true
 | 
			
		||||
	}
 | 
			
		||||
	switch v := v.Interface().(type) {
 | 
			
		||||
	case sql.NullBool:
 | 
			
		||||
		return !v.Valid
 | 
			
		||||
	case sql.NullFloat64:
 | 
			
		||||
		return !v.Valid
 | 
			
		||||
	case sql.NullInt64:
 | 
			
		||||
		return !v.Valid
 | 
			
		||||
	case sql.NullString:
 | 
			
		||||
		return !v.Valid
 | 
			
		||||
	}
 | 
			
		||||
	return false
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (scope *Scope) getColumnAsScope(column string) *Scope {
 | 
			
		||||
	indirectScopeValue := scope.IndirectValue()
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user