Skip to content

Commit

Permalink
MySQL: Use strict SQL mode instead of just ANSI_QUOTES
Browse files Browse the repository at this point in the history
  • Loading branch information
lippserd committed Jul 31, 2023
1 parent 204f727 commit 9e7f109
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion pkg/config/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ func (d *Database) Open(logger *logging.Logger) (*icingadb.DB, error) {

config.DBName = d.Database
config.Timeout = time.Minute
config.Params = map[string]string{"sql_mode": "ANSI_QUOTES"}
// Set strict SQL mode, i.e. trigger an error if an incorrect value is inserted into a column.
config.Params = map[string]string{"sql_mode": "TRADITIONAL"}

tlsConfig, err := d.TlsOptions.MakeConfig(d.Host)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/icingadb/quoter.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func NewQuoter(db *sqlx.DB) *Quoter {

switch db.DriverName() {
case driver.MySQL:
qc = `"`
qc = "`"
case driver.PostgreSQL:
qc = `"`
default:
Expand Down

0 comments on commit 9e7f109

Please sign in to comment.