Browse Source

Merge pull request #240 from go-sql-driver/notes

strict mode: document how notes can be ignored + test
Julien Schmidt 11 years ago
parent
commit
ed0b6f16c2
2 changed files with 14 additions and 1 deletions
  1. 8 1
      README.md
  2. 6 0
      errors_test.go

+ 8 - 1
README.md

@@ -187,7 +187,9 @@ Valid Values:   true, false
 Default:        false
 Default:        false
 ```
 ```
 
 
-`strict=true` enables strict mode. MySQL warnings are treated as errors.
+`strict=true` enables the strict mode in which MySQL warnings are treated as errors.
+
+By default MySQL also treats notes as warnings. Use [`sql_notes=false`](http://dev.mysql.com/doc/refman/5.7/en/server-system-variables.html#sysvar_sql_notes) to ignore notes. See the [examples](#examples) for an DSN example.
 
 
 
 
 ##### `timeout`
 ##### `timeout`
@@ -234,6 +236,11 @@ root:pw@unix(/tmp/mysql.sock)/myDatabase?loc=Local
 user:password@tcp(localhost:5555)/dbname?tls=skip-verify&autocommit=true
 user:password@tcp(localhost:5555)/dbname?tls=skip-verify&autocommit=true
 ```
 ```
 
 
+Use the [strict mode](#strict) but ignore notes:
+```
+user:password@/dbname?strict=true&sql_notes=false
+```
+
 TCP via IPv6:
 TCP via IPv6:
 ```
 ```
 user:password@tcp([de:ad:be:ef::ca:fe]:80)/dbname?timeout=90s
 user:password@tcp([de:ad:be:ef::ca:fe]:80)/dbname?timeout=90s

+ 6 - 0
errors_test.go

@@ -28,3 +28,9 @@ func TestSetLogger(t *testing.T) {
 		t.Errorf("expected %q, got %q", expected, actual)
 		t.Errorf("expected %q, got %q", expected, actual)
 	}
 	}
 }
 }
+
+func TestErrorsStrictIgnoreNotes(t *testing.T) {
+	runTests(t, dsn+"&sql_notes=false", func(dbt *DBTest) {
+		dbt.mustExec("DROP TABLE IF EXISTS does_not_exist")
+	})
+}