Subject: | [PATCH] fix float parser and add missing type |
The attached patch fixes a few issues I encountered while using version 0.2.2_01 of this module (perl 5.14.2, Ubuntu 12.04):
- add missing type to typemap: mediumtext
- fix float parser to optionally support ints as per MySQL dumps
- doc: make it clear that only one table is parsed (i.e. full dumps may need to be split)
- POD: fix warning
Note: float fields can contain integers e.g. (from the cur table):
`cur_random` double unsigned NOT NULL default '0',
The same table has (or had) a mediumtext field:
`cur_text` mediumtext NOT NULL,
Also: perhaps consider using one of the SQL parser modules (e.g SQL::Translator::Parser::MySQL or DBIx::MyParse) to simplify MediaWiki::DumpFile::SQL?
Thanks,
chocolateboy.
Subject: | 0001-add-missing-type-to-typemap-mediumtext.patch |
From: chocolateboy <chocolate@cpan.org>
Date: Wed, 8 May 2013 19:38:08
Subject: [PATCH] add missing type to typemap: mediumtext; fix float parser to
optionally support ints as per MySQL dumps; doc: make it
clear that only one table is parsed (i.e. full dumps may
need to be split); POD: fix warning
---
lib/MediaWiki/DumpFile/SQL.pm | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/lib/MediaWiki/DumpFile/SQL.pm b/lib/MediaWiki/DumpFile/SQL.pm
index de75633..0a77a12 100644
--- a/lib/MediaWiki/DumpFile/SQL.pm
+++ b/lib/MediaWiki/DumpFile/SQL.pm
@@ -230,6 +230,7 @@ sub create_type_map {
blob => 'varchar',
mediumblob => 'varchar',
+ mediumtext => 'varchar',
tinyblob => 'varchar',
varbinary => 'varchar',
@@ -311,7 +312,7 @@ sub new_int {
sub new_float {
return sub {
m/\GNULL/gc and return undef;
- m/\G(-?[\d]+\.[\d]+(e-?[\d]+)?)/gc or die "expected float"; return $1;
+ m/\G(-?[\d]+(?:\.[\d]+(e-?[\d]+)?)?)/gc or die "expected float"; return $1;
}
}
@@ -371,10 +372,10 @@ MediaWiki::DumpFile::SQL - Process SQL dump files from a MediaWiki instance
@schema = $sql->schema;
$name = $sql->table_name;
- while(defined($row = $sql->next) {
+ while(defined($row = $sql->next)) {
#do something with the data from the row
}
-
+
=head1 FUNCTIONS
=head2 new
@@ -382,6 +383,8 @@ MediaWiki::DumpFile::SQL - Process SQL dump files from a MediaWiki instance
This is the constructor for this package. It is called with a single parameter: the location of
a MediaWiki SQL dump file or a reference to an already open file handle.
+Only the definition and data for the B<first> table in a SQL dump file is processed.
+
=head2 next
Returns a hash reference where the key is the column name from the table and the value of the hash is
--
1.7.9.5