Skip to content

Commit e40cbd1

Browse files
committed
Handle PostgreSQL duplicated db error better, fix: #8
1 parent 6d86407 commit e40cbd1

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

adapter.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ func (a *Adapter) createDatabase() error {
9090
if a.driverName == "postgres" {
9191
if _, err = engine.Exec("CREATE DATABASE casbin"); err != nil {
9292
// 42P04 is duplicate_database
93-
if err.(*pq.Error).Code == "42P04" {
93+
if pqerr, ok := err.(*pq.Error); ok && pqerr.Code == "42P04" {
9494
return nil
9595
}
9696
}

0 commit comments

Comments
 (0)