@@ -22,46 +22,49 @@ var testDSNs = []struct {
2222 out * Config
2323}{{
2424 "username:password@protocol(address)/dbname?param=value" ,
25- & Config {User : "username" , Passwd : "password" , Net : "protocol" , Addr : "address" , DBName : "dbname" , Params : map [string ]string {"param" : "value" }, Collation : "utf8_general_ci" , Loc : time .UTC },
25+ & Config {User : "username" , Passwd : "password" , Net : "protocol" , Addr : "address" , DBName : "dbname" , Params : map [string ]string {"param" : "value" }, Collation : "utf8_general_ci" , Loc : time .UTC , AllowNativePasswords : true },
2626}, {
2727 "username:password@protocol(address)/dbname?param=value&columnsWithAlias=true" ,
28- & Config {User : "username" , Passwd : "password" , Net : "protocol" , Addr : "address" , DBName : "dbname" , Params : map [string ]string {"param" : "value" }, Collation : "utf8_general_ci" , Loc : time .UTC , ColumnsWithAlias : true },
28+ & Config {User : "username" , Passwd : "password" , Net : "protocol" , Addr : "address" , DBName : "dbname" , Params : map [string ]string {"param" : "value" }, Collation : "utf8_general_ci" , Loc : time .UTC , AllowNativePasswords : true , ColumnsWithAlias : true },
2929}, {
3030 "username:password@protocol(address)/dbname?param=value&columnsWithAlias=true&multiStatements=true" ,
31- & Config {User : "username" , Passwd : "password" , Net : "protocol" , Addr : "address" , DBName : "dbname" , Params : map [string ]string {"param" : "value" }, Collation : "utf8_general_ci" , Loc : time .UTC , ColumnsWithAlias : true , MultiStatements : true },
31+ & Config {User : "username" , Passwd : "password" , Net : "protocol" , Addr : "address" , DBName : "dbname" , Params : map [string ]string {"param" : "value" }, Collation : "utf8_general_ci" , Loc : time .UTC , AllowNativePasswords : true , ColumnsWithAlias : true , MultiStatements : true },
3232}, {
3333 "user@unix(/path/to/socket)/dbname?charset=utf8" ,
34- & Config {User : "user" , Net : "unix" , Addr : "/path/to/socket" , DBName : "dbname" , Params : map [string ]string {"charset" : "utf8" }, Collation : "utf8_general_ci" , Loc : time .UTC },
34+ & Config {User : "user" , Net : "unix" , Addr : "/path/to/socket" , DBName : "dbname" , Params : map [string ]string {"charset" : "utf8" }, Collation : "utf8_general_ci" , Loc : time .UTC , AllowNativePasswords : true },
3535}, {
3636 "user:password@tcp(localhost:5555)/dbname?charset=utf8&tls=true" ,
37- & Config {User : "user" , Passwd : "password" , Net : "tcp" , Addr : "localhost:5555" , DBName : "dbname" , Params : map [string ]string {"charset" : "utf8" }, Collation : "utf8_general_ci" , Loc : time .UTC , TLSConfig : "true" },
37+ & Config {User : "user" , Passwd : "password" , Net : "tcp" , Addr : "localhost:5555" , DBName : "dbname" , Params : map [string ]string {"charset" : "utf8" }, Collation : "utf8_general_ci" , Loc : time .UTC , AllowNativePasswords : true , TLSConfig : "true" },
3838}, {
3939 "user:password@tcp(localhost:5555)/dbname?charset=utf8mb4,utf8&tls=skip-verify" ,
40- & Config {User : "user" , Passwd : "password" , Net : "tcp" , Addr : "localhost:5555" , DBName : "dbname" , Params : map [string ]string {"charset" : "utf8mb4,utf8" }, Collation : "utf8_general_ci" , Loc : time .UTC , TLSConfig : "skip-verify" },
40+ & Config {User : "user" , Passwd : "password" , Net : "tcp" , Addr : "localhost:5555" , DBName : "dbname" , Params : map [string ]string {"charset" : "utf8mb4,utf8" }, Collation : "utf8_general_ci" , Loc : time .UTC , AllowNativePasswords : true , TLSConfig : "skip-verify" },
4141}, {
4242 "user:password@/dbname?loc=UTC&timeout=30s&readTimeout=1s&writeTimeout=1s&allowAllFiles=1&clientFoundRows=true&allowOldPasswords=TRUE&collation=utf8mb4_unicode_ci&maxAllowedPacket=16777216" ,
43- & Config {User : "user" , Passwd : "password" , Net : "tcp" , Addr : "127.0.0.1:3306" , DBName : "dbname" , Collation : "utf8mb4_unicode_ci" , Loc : time .UTC , Timeout : 30 * time .Second , ReadTimeout : time .Second , WriteTimeout : time .Second , AllowAllFiles : true , AllowOldPasswords : true , ClientFoundRows : true , MaxAllowedPacket : 16777216 },
43+ & Config {User : "user" , Passwd : "password" , Net : "tcp" , Addr : "127.0.0.1:3306" , DBName : "dbname" , Collation : "utf8mb4_unicode_ci" , Loc : time .UTC , AllowNativePasswords : true , Timeout : 30 * time .Second , ReadTimeout : time .Second , WriteTimeout : time .Second , AllowAllFiles : true , AllowOldPasswords : true , ClientFoundRows : true , MaxAllowedPacket : 16777216 },
44+ }, {
45+ "user:password@/dbname?allowNativePasswords=false" ,
46+ & Config {User : "user" , Passwd : "password" , Net : "tcp" , Addr : "127.0.0.1:3306" , DBName : "dbname" , Collation : "utf8_general_ci" , Loc : time .UTC , AllowNativePasswords : false },
4447}, {
4548 "user:p@ss(word)@tcp([de:ad:be:ef::ca:fe]:80)/dbname?loc=Local" ,
46- & Config {User : "user" , Passwd : "p@ss(word)" , Net : "tcp" , Addr : "[de:ad:be:ef::ca:fe]:80" , DBName : "dbname" , Collation : "utf8_general_ci" , Loc : time .Local },
49+ & Config {User : "user" , Passwd : "p@ss(word)" , Net : "tcp" , Addr : "[de:ad:be:ef::ca:fe]:80" , DBName : "dbname" , Collation : "utf8_general_ci" , Loc : time .Local , AllowNativePasswords : true },
4750}, {
4851 "/dbname" ,
49- & Config {Net : "tcp" , Addr : "127.0.0.1:3306" , DBName : "dbname" , Collation : "utf8_general_ci" , Loc : time .UTC },
52+ & Config {Net : "tcp" , Addr : "127.0.0.1:3306" , DBName : "dbname" , Collation : "utf8_general_ci" , Loc : time .UTC , AllowNativePasswords : true },
5053}, {
5154 "@/" ,
52- & Config {Net : "tcp" , Addr : "127.0.0.1:3306" , Collation : "utf8_general_ci" , Loc : time .UTC },
55+ & Config {Net : "tcp" , Addr : "127.0.0.1:3306" , Collation : "utf8_general_ci" , Loc : time .UTC , AllowNativePasswords : true },
5356}, {
5457 "/" ,
55- & Config {Net : "tcp" , Addr : "127.0.0.1:3306" , Collation : "utf8_general_ci" , Loc : time .UTC },
58+ & Config {Net : "tcp" , Addr : "127.0.0.1:3306" , Collation : "utf8_general_ci" , Loc : time .UTC , AllowNativePasswords : true },
5659}, {
5760 "" ,
58- & Config {Net : "tcp" , Addr : "127.0.0.1:3306" , Collation : "utf8_general_ci" , Loc : time .UTC },
61+ & Config {Net : "tcp" , Addr : "127.0.0.1:3306" , Collation : "utf8_general_ci" , Loc : time .UTC , AllowNativePasswords : true },
5962}, {
6063 "user:p@/ssword@/" ,
61- & Config {User : "user" , Passwd : "p@/ssword" , Net : "tcp" , Addr : "127.0.0.1:3306" , Collation : "utf8_general_ci" , Loc : time .UTC },
64+ & Config {User : "user" , Passwd : "p@/ssword" , Net : "tcp" , Addr : "127.0.0.1:3306" , Collation : "utf8_general_ci" , Loc : time .UTC , AllowNativePasswords : true },
6265}, {
6366 "unix/?arg=%2Fsome%2Fpath.ext" ,
64- & Config {Net : "unix" , Addr : "/tmp/mysql.sock" , Params : map [string ]string {"arg" : "/some/path.ext" }, Collation : "utf8_general_ci" , Loc : time .UTC },
67+ & Config {Net : "unix" , Addr : "/tmp/mysql.sock" , Params : map [string ]string {"arg" : "/some/path.ext" }, Collation : "utf8_general_ci" , Loc : time .UTC , AllowNativePasswords : true },
6568}}
6669
6770func TestDSNParser (t * testing.T ) {
@@ -223,8 +226,9 @@ func TestDSNUnsafeCollation(t *testing.T) {
223226func TestParamsAreSorted (t * testing.T ) {
224227 expected := "/dbname?interpolateParams=true&foobar=baz&quux=loo"
225228 dsn := & Config {
226- DBName : "dbname" ,
227- InterpolateParams : true ,
229+ DBName : "dbname" ,
230+ InterpolateParams : true ,
231+ AllowNativePasswords : true ,
228232 Params : map [string ]string {
229233 "quux" : "loo" ,
230234 "foobar" : "baz" ,
0 commit comments