mirror of
https://github.com/writefreely/writefreely
synced 2024-11-24 17:43:05 +00:00
fca3019e4b
This adds a new `sqlite` build tag that you should include only if you want SQLite3 support built in. Both `make run` and `make release` create builds with SQLite included.
30 lines
725 B
Go
30 lines
725 B
Go
// +build !sqlite
|
|
|
|
/*
|
|
* Copyright © 2019 A Bunch Tell LLC.
|
|
*
|
|
* This file is part of WriteFreely.
|
|
*
|
|
* WriteFreely is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU Affero General Public License, included
|
|
* in the LICENSE file in this source code package.
|
|
*/
|
|
|
|
package writefreely
|
|
|
|
import (
|
|
"github.com/go-sql-driver/mysql"
|
|
"github.com/writeas/web-core/log"
|
|
)
|
|
|
|
func (db *datastore) isDuplicateKeyErr(err error) bool {
|
|
if db.driverName == driverMySQL {
|
|
if mysqlErr, ok := err.(*mysql.MySQLError); ok {
|
|
return mysqlErr.Number == mySQLErrDuplicateKey
|
|
}
|
|
} else {
|
|
log.Error("isDuplicateKeyErr: failed check for unrecognized driver '%s'", db.driverName)
|
|
}
|
|
|
|
return false
|
|
}
|