forked from dexidp/dex
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
db: protect the sqlite3 import with a cgo tag
- Loading branch information
1 parent
350571a
commit 93b89ad
Showing
4 changed files
with
53 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package db | ||
|
||
// Register the postgres driver. | ||
|
||
import "github.com/lib/pq" | ||
|
||
func init() { | ||
registerAlreadyExistsChecker(func(err error) bool { | ||
sqlErr, ok := err.(*pq.Error) | ||
if !ok { | ||
return false | ||
} | ||
return sqlErr.Code == pgErrorCodeUniqueViolation | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// +build cgo | ||
|
||
package db | ||
|
||
// Register the sqlite3 driver. | ||
|
||
import "github.com/mattn/go-sqlite3" | ||
|
||
func init() { | ||
registerAlreadyExistsChecker(func(err error) bool { | ||
sqlErr, ok := err.(*sqlite3.Error) | ||
if !ok { | ||
return false | ||
} | ||
return sqlErr.ExtendedCode == sqlite3.ErrConstraintUnique | ||
}) | ||
} |