Skip to content

Commit

Permalink
Handle PostgreSQL duplicated db error better, fix: #8
Browse files Browse the repository at this point in the history
  • Loading branch information
hsluoyz committed Dec 7, 2018
1 parent 6d86407 commit e40cbd1
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func (a *Adapter) createDatabase() error {
if a.driverName == "postgres" {
if _, err = engine.Exec("CREATE DATABASE casbin"); err != nil {
// 42P04 is duplicate_database
if err.(*pq.Error).Code == "42P04" {
if pqerr, ok := err.(*pq.Error); ok && pqerr.Code == "42P04" {
return nil
}
}
Expand Down

0 comments on commit e40cbd1

Please sign in to comment.