update
This commit is contained in:
		
							parent
							
								
									d6c15a2353
								
							
						
					
					
						commit
						5f300756b8
					
				
							
								
								
									
										14
									
								
								gorm.go
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								gorm.go
									
									
									
									
									
								
							@ -210,13 +210,20 @@ func Open(dialector Dialector, opts ...Option) (db *DB, err error) {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (db *DB) Close() error {
 | 
					func (db *DB) Close() error {
 | 
				
			||||||
	sdb, isSdb := db.ConnPool.(*sql.DB)
 | 
					
 | 
				
			||||||
	stmt, isStmt := db.ConnPool.(*PreparedStmtDB)
 | 
						db.cacheStore.Delete(preparedStmtDBKey)
 | 
				
			||||||
 | 
						return close(db.ConnPool)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func close(cp ConnPool) error {
 | 
				
			||||||
 | 
						sdb, isSdb := cp.(*sql.DB)
 | 
				
			||||||
 | 
						stmt, isStmt := cp.(*PreparedStmtDB)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	switch {
 | 
						switch {
 | 
				
			||||||
	case isSdb:
 | 
						case isSdb:
 | 
				
			||||||
		return sdb.Close()
 | 
							return sdb.Close()
 | 
				
			||||||
	case isStmt:
 | 
						case isStmt:
 | 
				
			||||||
		db.cacheStore.Delete(preparedStmtDBKey)
 | 
					 | 
				
			||||||
		for _, v := range stmt.Stmts {
 | 
							for _, v := range stmt.Stmts {
 | 
				
			||||||
			v.Close()
 | 
								v.Close()
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
@ -227,7 +234,6 @@ func (db *DB) Close() error {
 | 
				
			|||||||
		return sdb.Close()
 | 
							return sdb.Close()
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return nil
 | 
						return nil
 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Session create new db session
 | 
					// Session create new db session
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user