@@ -29,6 +29,9 @@ use warnings;
29
29
use version;
30
30
our $VERSION = qv(' 2.0.1' );
31
31
32
+ use Debuggit;
33
+ # local $Debuggit::formatter = sub { return (caller(2))[3] . ':bmoogle: ' . Debuggit::default_formatter(@_) };
34
+
32
35
use DBI;
33
36
use Carp;
34
37
use Storable;
@@ -65,7 +68,7 @@ my $QUERY_SUB = qr/^\{.+\}$/;
65
68
66
69
67
70
our $data_store_dir = DEBUG ? " ." : " /etc/data_store" ;
68
- # our $data_store_dir = "/etc/data_store" ;
71
+ debuggit( 4 => ' DataStore load: data store dir set to ' , $data_store_dir ) ;
69
72
70
73
our $base_types =
71
74
{
@@ -542,7 +545,7 @@ sub _transform_query
542
545
# now put the quoted strings back (note that it's okay to have a _variable_ inside a quoted string, so we
543
546
# don't do anything in particular to avoid those)
544
547
$query =~ s / {Q(\d +)}/ ${$quoted_strings [$1 ]}/ g ;
545
-
548
+
546
549
# sort out parameters according to whether they're the query (first param), hash or array placeholder
547
550
# (a.k.a. "non-scalar placeholder") values (any hashrefs or arrayrefs), or variables (everything else)
548
551
my (@ns_placeholders , @var_stuff );
@@ -872,7 +875,7 @@ sub create
872
875
873
876
# RDBMS has to be present
874
877
croak(" must specify RDBMS to data store" ) unless exists $attribs {' rdbms' };
875
-
878
+
876
879
# user has to be present, and should be moved out of config section
877
880
croak(" must specify user to data store" ) unless exists $attribs {' user' };
878
881
$this -> {' user' } = $attribs {' user' };
@@ -895,6 +898,22 @@ sub create
895
898
}
896
899
897
900
901
+ sub derive
902
+ {
903
+ my $class = shift ;
904
+ my ($dbh , %attribs ) = @_ ;
905
+
906
+ # RDBMS has to be present
907
+ croak(" must specify RDBMS to data store" ) unless exists $attribs {' rdbms' };
908
+
909
+ my $this = {};
910
+ $this -> {' dbh' } = $dbh ;
911
+
912
+ bless $this , $class ;
913
+ return $this ;
914
+ }
915
+
916
+
898
917
sub DESTROY
899
918
{
900
919
my $this = shift ;
@@ -1130,6 +1149,7 @@ sub replace_table
1130
1149
sub create_table
1131
1150
{
1132
1151
my ($this , $table_name , $columns , $opts ) = @_ ;
1152
+ debuggit(4 => ' DataStore::create_table: table' , $table_name , ' columns' , DUMP => $columns , ' opts' , DUMP => $opts );
1133
1153
$opts ||= {};
1134
1154
$opts -> {' DATADICT' } ||= ' ' ;
1135
1155
0 commit comments