Showing 3 changed files with 2 additions and 9 deletions
+1 -2
lib/DBIx/Custom.pm
... ...
@@ -51,7 +51,7 @@ has [qw/connector dsn password quote user/],
51 51
     },
52 52
     last_sql => '',
53 53
     models => sub { {} },
54
-    query_builder => sub { DBIx::Custom::QueryBuilder->new },
54
+    query_builder => sub { DBIx::Custom::QueryBuilder->new(_dbi => shift) },
55 55
     result_class  => 'DBIx::Custom::Result',
56 56
     safety_character => '\w',
57 57
     stash => sub { {} },
... ...
@@ -1114,7 +1114,6 @@ sub _create_query {
1114 1114
         # Create query
1115 1115
         my $builder = $self->query_builder;
1116 1116
         $builder->{_tag_parse} = $self->tag_parse;
1117
-        $builder->safety_character($self->safety_character);
1118 1117
         $query = $builder->build_query($source);
1119 1118
 
1120 1119
         # Remove reserved word quote
+1 -3
lib/DBIx/Custom/QueryBuilder.pm
... ...
@@ -10,8 +10,6 @@ use DBIx::Custom::Util '_subname';
10 10
 push @DBIx::Custom::CARP_NOT, __PACKAGE__;
11 11
 push @DBIx::Custom::Where::CARP_NOT, __PACKAGE__;
12 12
 
13
-has 'safety_character';
14
-
15 13
 sub build_query {
16 14
     my ($self, $source) = @_;
17 15
     
... ...
@@ -72,7 +70,7 @@ sub _parse_parameter {
72 70
     # Get and replace parameters
73 71
     my $sql = $source || '';
74 72
     my $columns = [];
75
-    my $c = $self->safety_character;
73
+    my $c = $self->{_dbi}->safety_character;
76 74
     # Parameter regex
77 75
     $sql =~ s/([^:]):(\d+):([^:])/$1\\:$2\\:$3/g;
78 76
     my $re = qr/(^|.*?[^\\]):([$c\.]+)(?:\{(.*?)\})?(.*)/s;
-4
t/dbix-custom-querybuilder.t
... ...
@@ -57,7 +57,6 @@ $datas = [
57 57
 for (my $i = 0; $i < @$datas; $i++) {
58 58
     my $data = $datas->[$i];
59 59
     my $builder = DBIx::Custom->new->query_builder;
60
-    $builder->safety_character('\w');
61 60
     my $query = $builder->build_query($data->{source});
62 61
     is($query->{sql}, $data->{sql_expected}, "$data->{name} : sql");
63 62
     is_deeply($query->columns, $data->{columns_expected}, "$data->{name} : columns");
... ...
@@ -66,7 +65,6 @@ for (my $i = 0; $i < @$datas; $i++) {
66 65
 
67 66
 test 'Original tag';
68 67
 $builder = DBIx::Custom->new->query_builder;
69
-$builder->safety_character('\w');
70 68
 
71 69
 $ret_val = $builder->register_tag(
72 70
     p => sub {
... ...
@@ -86,7 +84,6 @@ isa_ok($ret_val, 'DBIx::Custom::QueryBuilder');
86 84
 
87 85
 test "Tag error case";
88 86
 $builder = DBIx::Custom->new->query_builder;
89
-$builder->safety_character('\w');
90 87
 
91 88
 eval{$builder->build_query('{? }')};
92 89
 like($@, qr/\QColumn name must be specified in tag "{? }"/, "? not arguments");
... ...
@@ -122,7 +119,6 @@ $builder->register_tag(
122 119
 
123 120
 test 'General error case';
124 121
 $builder = DBIx::Custom->new->query_builder;
125
-$builder->safety_character('\w');
126 122
 $builder->register_tag(
127 123
     a => sub {
128 124
         return ["? ? ?", ['']];