A clean, Markdown-based publishing platform made for writers. Write together, and build a community. https://writefreely.org
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 
 
 

31 řádky
732 B

  1. // +build !sqlite,!wflib
  2. /*
  3. * Copyright © 2019 A Bunch Tell LLC.
  4. *
  5. * This file is part of WriteFreely.
  6. *
  7. * WriteFreely is free software: you can redistribute it and/or modify
  8. * it under the terms of the GNU Affero General Public License, included
  9. * in the LICENSE file in this source code package.
  10. */
  11. package writefreely
  12. import (
  13. "github.com/go-sql-driver/mysql"
  14. "github.com/writeas/web-core/log"
  15. )
  16. func (db *datastore) isDuplicateKeyErr(err error) bool {
  17. if db.driverName == driverMySQL {
  18. if mysqlErr, ok := err.(*mysql.MySQLError); ok {
  19. return mysqlErr.Number == mySQLErrDuplicateKey
  20. }
  21. } else {
  22. log.Error("isDuplicateKeyErr: failed check for unrecognized driver '%s'", db.driverName)
  23. }
  24. return false
  25. }