Skip Menu |

This queue is for tickets about the Class-DBI-Loader CPAN distribution.

Report information
The Basics
Id: 13689
Status: open
Priority: 0/
Queue: Class-DBI-Loader

People
Owner: Nobody in particular
Requestors: jmanning [...] alisa-jon.net
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 0.22
Fixed in: (no value)



Subject: mysql DSN hostname syntax not supported
Class::DBI::Loader-0.22, perl v5.8.6 and perl v5.8.0. Linux 2.4 and 2.6 When starting Loader with a dsn="dbi:mysql:dbname:hostname.com", I get the following errors: Couldn't load tables "DBD::mysql::st execute failed: You have an error in your SQL syntax near ':hostname.com LIKE 'Environment'' at line 1 [for Statement "SHOW TABLE STATUS FROM dbname:hostname.com LIKE 'Environment'"] Clearly dbname is not correctly parsed out of the DSN - the error must be in _relationships at "$dsn =~ m/\Adbi:\w+(?:\(.*?\))?:(.+)\z/i" Perhaps adding an optional hostname to the regexp would work: "$dsn =~ m/\Adbi:\w+(?:\(.*?\))?:(.+)(?:\:.*?)\z/i"
From: jmanning
(Addendum) From mysql docs: $dbh = DBI->connect("DBI:mysql:$database", $user, $password); $dbh = DBI->connect("DBI:mysql:$database:$hostname", $user, $password); $dbh = DBI->connect("DBI:mysql:$database:$hostname:$port", $user, $password); So, perhaps these variants should all be supported. Just replacing '\z' with '\:?' from the original regex would work, or adding an explicit port field just like hostname was added above.
From: Raphael Kraus
Actually, replacing line 46: $dsn =~ m/\Adbi:\w+(?:\(.*?\))?:(.+)\z/i with: $dsn =~ /^dbi:\w+:(\w+):/i works well. (I didn't find that the other suggested replacement worked.) Thanks! Raphael
46c46 < $dsn =~ /^dbi:\w+:(\w+):/i --- > $dsn =~ m/\Adbi:\w+(?:\(.*?\))?:(.+)\z/i
From: Raphael Kraus
Erps - make that... On line 46 replace: $dsn =~ m/\Adbi:\w+(?:\(.*?\))?:(.+)\z/i With: $dsn =~ /^dbi:\w+:([\w=]+)/i (I realised that this wouldn't work if the user said db=database_name and the trailing : is redundant) Other alternative could be (or similar): $dsn =~ /^dbi:.*?:(.*?):/
46c46 < $dsn =~ m/\Adbi:\w+(?:\(.*?\))?:(.+)\z/i --- > $dsn =~ /^dbi:\w+:([\w=]+)/i