Fix update select clause with before/after expressions, close #5164
This commit is contained in:
		
							parent
							
								
									d402765f69
								
							
						
					
					
						commit
						540b47571a
					
				| @ -93,7 +93,11 @@ func (db *DB) Select(query interface{}, args ...interface{}) (tx *DB) { | |||||||
| 				return | 				return | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 		delete(tx.Statement.Clauses, "SELECT") | 
 | ||||||
|  | 		if clause, ok := tx.Statement.Clauses["SELECT"]; ok { | ||||||
|  | 			clause.Expression = nil | ||||||
|  | 			tx.Statement.Clauses["SELECT"] = clause | ||||||
|  | 		} | ||||||
| 	case string: | 	case string: | ||||||
| 		if strings.Count(v, "?") >= len(args) && len(args) > 0 { | 		if strings.Count(v, "?") >= len(args) && len(args) > 0 { | ||||||
| 			tx.Statement.AddClause(clause.Select{ | 			tx.Statement.AddClause(clause.Select{ | ||||||
| @ -123,7 +127,10 @@ func (db *DB) Select(query interface{}, args ...interface{}) (tx *DB) { | |||||||
| 				} | 				} | ||||||
| 			} | 			} | ||||||
| 
 | 
 | ||||||
| 			delete(tx.Statement.Clauses, "SELECT") | 			if clause, ok := tx.Statement.Clauses["SELECT"]; ok { | ||||||
|  | 				clause.Expression = nil | ||||||
|  | 				tx.Statement.Clauses["SELECT"] = clause | ||||||
|  | 			} | ||||||
| 		} | 		} | ||||||
| 	default: | 	default: | ||||||
| 		tx.AddError(fmt.Errorf("unsupported select args %v %v", query, args)) | 		tx.AddError(fmt.Errorf("unsupported select args %v %v", query, args)) | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Jinzhu
						Jinzhu