mirror of
				https://github.com/superseriousbusiness/gotosocial.git
				synced 2025-10-31 03:42:25 -05:00 
			
		
		
		
	Database updates (#144)
* start moving some database stuff around * continue moving db stuff around * more fiddling * more updates * and some more * and yet more * i broke SOMETHING but what, it's a mystery * tidy up * vendor ttlcache * use ttlcache * fix up some tests * rename some stuff * little reminder * some more updates
This commit is contained in:
		
					parent
					
						
							
								ce190d867c
							
						
					
				
			
			
				commit
				
					
						4920229a3b
					
				
			
		
					 164 changed files with 4850 additions and 2617 deletions
				
			
		
							
								
								
									
										25
									
								
								internal/db/pg/util.go
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								internal/db/pg/util.go
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,25 @@ | |||
| package pg | ||||
| 
 | ||||
| import ( | ||||
| 	"strings" | ||||
| 
 | ||||
| 	"github.com/go-pg/pg/v10" | ||||
| 	"github.com/superseriousbusiness/gotosocial/internal/db" | ||||
| ) | ||||
| 
 | ||||
| // processErrorResponse parses the given error and returns an appropriate DBError. | ||||
| func processErrorResponse(err error) db.Error { | ||||
| 	switch err { | ||||
| 	case nil: | ||||
| 		return nil | ||||
| 	case pg.ErrNoRows: | ||||
| 		return db.ErrNoEntries | ||||
| 	case pg.ErrMultiRows: | ||||
| 		return db.ErrMultipleEntries | ||||
| 	default: | ||||
| 		if strings.Contains(err.Error(), "duplicate key value violates unique constraint") { | ||||
| 			return db.ErrAlreadyExists | ||||
| 		} | ||||
| 		return err | ||||
| 	} | ||||
| } | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue