libfic: update SQL modes to be compatible with lastest MySQL version

This commit is contained in:
Thibaut 2018-05-12 02:01:49 +02:00 committed by Pierre-Olivier Mercier
parent 76c10e92a4
commit 12cb4e95f4

View File

@ -43,9 +43,9 @@ func DBInit(dsn string) (err error) {
return return
} }
_, err = db.Exec(`SET SESSION sql_mode = 'STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';`) _, err = db.Exec(`SET SESSION sql_mode = 'STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO';`)
for i := 0; err != nil && i < 15; i += 1 { for i := 0; err != nil && i < 15; i += 1 {
if _, err = db.Exec(`SET SESSION sql_mode = 'STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';`); err != nil && i <= 5 { if _, err = db.Exec(`SET SESSION sql_mode = 'STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO';`); err != nil && i <= 5 {
log.Println("An error occurs when trying to connect to DB, will retry in 2 seconds: ", err) log.Println("An error occurs when trying to connect to DB, will retry in 2 seconds: ", err)
time.Sleep(2 * time.Second) time.Sleep(2 * time.Second)
} }