1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249
|
Author: Angus Lees <gus@debian.org>
Date: Sun, 23 Dec 2001 17:47:22 +1100
Description: Replace several uses of '*Table' with '*MainTable' to try and avoid
some of the side affects of !LinkName.
Date: Tue, 29 Jan 2002 16:53:47 +1100
Description: patch (approved by upstream) to avoid "fully qualifying" fields that
aren't in %tab4f - since that means they aren't column names
(another side affect of !LinkName).
Date: Sat, 28 Sep 2002 17:20:44 +1000
Description:
* Call savecroak on *Recordset object, not $self.
* Use *LastRecordFetch as the "row before the first" indicator. This
prevents Next() looping back to the start in some cases.
* Remove *LastRecord "cache", fixing Next(), MoreRecords(), Next() bug.
* Allow TableAttr's to set an attribute to a false value.
(Thanks René Seindal)
* Don't return a tied row from Next when TieRow=0 (closes: #133165)
(Thanks René Seindal)
--- a/Recordset.pm
+++ b/Recordset.pm
@@ -735,8 +735,7 @@
{
my ($self) = @_ ;
- # 'begin' method is unhandled by DBI
- ## ?? $self->{'*DBHdl'} -> func('begin') unless $self->{'*DBHdl'}->{'AutoCommit'};
+ $self->{'*DBHdl'}->begin_work unless $self->{'*DBHdl'}->{'AutoCommit'};
}
## ----------------------------------------------------------------------------
@@ -866,7 +865,7 @@
sub TableName ($)
{
- return $_[0] -> {'*Table'} ;
+ return $_[0] -> {'*MainTable'} ;
}
## ----------------------------------------------------------------------------
@@ -880,7 +879,7 @@
sub TableNameWithoutFilter ($)
{
- my $tab = $_[0] -> {'*Table'} ;
+ my $tab = $_[0] -> {'*MainTable'} ;
return $1 if ($tab =~ /^$_[0]->{'*TableFilter'}(.*?)$/) ;
return $tab ;
@@ -1036,7 +1035,7 @@
$f = $v -> {'!MainField'} ;
$mf -> {$f} = $k ;
$mf -> {"$tab4f->{$f}.$f"} = $k ;
- print LOG "DB: Field $v->{'!MainField'} has link $k\n" ;
+ print LOG "DB: Field $v->{'!MainField'} has link $k\n" if ($self -> {'*Debug'} > 2) ;
}
$self -> {'*MainFields'} = $mf ;
}
@@ -1203,17 +1202,17 @@
{
my ($self, $fields, $vals, $bind_values, $bind_types) = @_ ;
- $self -> savecroak ("Insert disabled for table $self->{'*Table'}") if (!($self->{'*WriteMode'} & wmINSERT)) ;
+ $self -> savecroak ("Insert disabled for table $self->{'*MainTable'}") if (!($self->{'*WriteMode'} & wmINSERT)) ;
$self->{'*Stats'}{insert}++ ;
if (defined ($bind_values))
{
- return $self->do ("INSERT INTO $self->{'*Table'} ($fields) VALUES ($vals)", undef, $bind_values, $bind_types) ;
+ return $self->do ("INSERT INTO $self->{'*MainTable'} ($fields) VALUES ($vals)", undef, $bind_values, $bind_types) ;
}
else
{
- return $self->do ("INSERT INTO $self->{'*Table'} ($fields) VALUES ($vals)") ;
+ return $self->do ("INSERT INTO $self->{'*MainTable'} ($fields) VALUES ($vals)") ;
}
}
@@ -1233,17 +1232,17 @@
{
my ($self, $data, $where, $bind_values, $bind_types) = @_ ;
- $self -> savecroak ("Update disabled for table $self->{'*Table'}") if (!($self->{'*WriteMode'} & wmUPDATE)) ;
+ $self -> savecroak ("Update disabled for table $self->{'*MainTable'}") if (!($self->{'*WriteMode'} & wmUPDATE)) ;
$self->{'*Stats'}{update}++ ;
if (defined ($bind_values))
{
- return $self->do ("UPDATE $self->{'*Table'} SET $data WHERE $where", undef, $bind_values, $bind_types) ;
+ return $self->do ("UPDATE $self->{'*MainTable'} SET $data WHERE $where", undef, $bind_values, $bind_types) ;
}
else
{
- return $self->do ("UPDATE $self->{'*Table'} SET $data WHERE $where") ;
+ return $self->do ("UPDATE $self->{'*MainTable'} SET $data WHERE $where") ;
}
}
@@ -1262,18 +1261,18 @@
{
my ($self, $where, $bind_values, $bind_types) = @_ ;
- $self -> savecroak ("Delete disabled for table $self->{'*Table'}") if (!($self->{'*WriteMode'} & wmDELETE)) ;
- $self -> savecroak ("Clear (Delete all) disabled for table $self->{'*Table'}") if (!$where && !($self->{'*WriteMode'} & wmCLEAR)) ;
+ $self -> savecroak ("Delete disabled for table $self->{'*MainTable'}") if (!($self->{'*WriteMode'} & wmDELETE)) ;
+ $self -> savecroak ("Clear (Delete all) disabled for table $self->{'*MainTable'}") if (!$where && !($self->{'*WriteMode'} & wmCLEAR)) ;
$self->{'*Stats'}{'delete'}++ ;
if (defined ($bind_values))
{
- return $self->do ("DELETE FROM $self->{'*Table'} " . ($where?"WHERE $where":''), undef, $bind_values, $bind_types) ;
+ return $self->do ("DELETE FROM $self->{'*MainTable'} " . ($where?"WHERE $where":''), undef, $bind_values, $bind_types) ;
}
else
{
- return $self->do ("DELETE FROM $self->{'*Table'} " . ($where?"WHERE $where":'')) ;
+ return $self->do ("DELETE FROM $self->{'*MainTable'} " . ($where?"WHERE $where":'')) ;
}
}
@@ -1322,6 +1321,7 @@
$self->{'*EOD'} = undef ;
$self->{'*SelectFields'} = undef ;
$self->{'*LastRecord'} = undef ;
+ $self->{'*LastRecordFetch'} = undef ;
$order ||= '' ;
$expr ||= '' ;
@@ -1486,8 +1486,6 @@
$fetch += $self->{'*FetchStart'} ;
- return $self->{'*LastRecord'} if (defined ($self->{'*LastRecordFetch'}) && $fetch == $self->{'*LastRecordFetch'} && $self->{'*LastRecord'}) ;
-
my $max ;
my $key ;
my $dat ; # row data
@@ -1606,12 +1604,24 @@
if (ref $dat eq 'ARRAY')
{ # just an Array so tie it now
my $arr = $dat ;
- $dat = {} ;
- $obj = tie %$dat, 'DBIx::Recordset::Row', $self, $self->{'*SelectFields'} , $arr ;
- $data -> [$fetch] = $dat ;
- $self->{'*LastRow'} = $fetch ;
- $self->{'*LastKey'} = $obj -> FETCH ($self -> {'*PrimKey'}) ;
+
+ if ($self -> {'*TieRow'})
+ {
+ $dat = {} ;
+ $obj = tie %$dat, 'DBIx::Recordset::Row', $self, $self->{'*SelectFields'} , $arr ;
+ $data -> [$fetch] = $dat ;
+ $self->{'*LastRow'} = $fetch ;
+ $self->{'*LastKey'} = $obj -> FETCH ($self -> {'*PrimKey'}) ;
+ } else {
+ my $fld = $self->{'*SelectFields'} ;
+
+ $dat = {};
+ @$dat{@$fld} = @$arr ;
+
+ $self->{'*LastRow'} = $fetch ;
+ $self->{'*LastKey'} = $dat -> {$self -> {'*PrimKey'}} if ($self -> {'*PrimKey'}) ;
}
+ }
else
{
#my $v ;
@@ -1673,6 +1683,7 @@
my $self = shift ;
$self->{'*LastRecord'} = undef ;
+ $self->{'*LastRecordFetch'} = undef ;
$self ->{'*LastRow'} = 0 ;
}
@@ -1725,7 +1736,7 @@
$lr -= $self -> {'*FetchStart'} ;
$lr = 0 if ($lr < 0) ;
- $lr++ if (defined ($self -> {'*LastRecord'})) ;
+ $lr++ if (defined ($self -> {'*LastRecordFetch'})) ;
##$lr++ if ($_[0] ->{'*CurrRow'} > 0 || $_[0] ->{'*EOD'}) ;
my $rec = $self -> FETCH ($lr) ;
@@ -2729,7 +2740,7 @@
($self = $newself) or return undef ;
}
- $self -> savecroak ("Delete disabled for table $self->{'*Table'}") if (!($self->{'*WriteMode'} & wmDELETE)) ;
+ $self -> savecroak ("Delete disabled for table $self->{'*MainTable'}") if (!($self->{'*WriteMode'} & wmDELETE)) ;
my @bind_values ;
my @bind_types ;
@@ -2737,7 +2748,7 @@
my $clear_disabled_diag =
"(!$expr && !($self->{'*WriteMode'} & wmCLEAR))";
- $self -> savecroak ("Clear (Delete all) disabled for table $self->{'*Table'}: $clear_disabled_diag") if (!$expr && !($self->{'*WriteMode'} & wmCLEAR)) ;
+ $self -> savecroak ("Clear (Delete all) disabled for table $self->{'*MainTable'}: $clear_disabled_diag") if (!$expr && !($self->{'*WriteMode'} & wmCLEAR)) ;
my $links = $self -> {'*Links'} ;
@@ -3124,11 +3135,11 @@
$buttons .= "$esc<input type=$esc\"text$esc\" size=6 name=$esc\"\$gotorow$esc\"$esc>" ;
$buttons .= "$esc<input type=$esc\"submit$esc\" name=$esc\"\$goto$esc\" value=$esc\"$textgoto$esc\"$esc> " ;
}
- if ($more > 0 && $textnext)
+ if ($more && $textnext)
{
$buttons .= "$esc<input type=$esc\"submit$esc\" name=$esc\"\$next$esc\" value=$esc\"$textnext$esc\"$esc> " ;
}
- if ($more > 0 && $textlast)
+ if ($more && $textlast)
{
$buttons .= "$esc<input type=$esc\"submit$esc\" name=$esc\"\$last$esc\" value=$esc\"$textlast$esc\"$esc>" ;
}
@@ -3319,7 +3330,7 @@
print DBIx::Recordset::LOG "DB: ::CurrRow::DESTROY\n" if ($self -> {'*Recordset'} -> {'*Debug'} > 3) ;
}
} ;
- $self -> savecroak ($@) if (!$orgerr && $@) ;
+ $self -> {'*Recordset'} -> savecroak ($@) if (!$orgerr && $@) ;
warn $@ if ($orgerr && $@) ;
}
@@ -3682,7 +3693,7 @@
print DBIx::Recordset::LOG "DB: ::Hash::DESTROY\n" if ($self -> {'*Recordset'} -> {'*Debug'} > 3) ;
}
} ;
- $self -> savecroak ($@) if (!$orgerr && $@) ;
+ $self -> {'*Recordset'} -> savecroak ($@) if (!$orgerr && $@) ;
warn $@ if ($orgerr && $@) ;
}
@@ -4036,7 +4047,7 @@
{
$rc = $rs -> Update ($dat, {$pk => $pko} ) ;
}
- if ($rc != 1 && $rc ne '')
+ if ($rc ne '' && $rc != 1)
{ # must excatly be one row!
print DBIx::Recordset::LOG "DB: ERROR: Row Update has updated $rc rows instead of one ($rs->{'*LastSQLStatement'})\n" if ($rs->{'*Debug'}) ;
#$rs -> savecroak ("DB: ERROR: Row Update has updated $rc rows instead of one ($rs->{'*LastSQLStatement'})") ;
|