(&mut self)
| 239 | |
| 240 | impl<'conn> Drop for Transaction<'conn> { |
| 241 | fn drop(&mut self) { |
| 242 | if self.committed { |
| 243 | return; // Already committed or rolled back |
| 244 | } |
| 245 | |
| 246 | match self.drop_behavior { |
| 247 | DropBehavior::Rollback => { |
| 248 | // Attempt to rollback, log error if it fails |
| 249 | if let Err(e) = self.rollback_internal() { |
| 250 | eprintln!("Warning: Failed to rollback transaction on drop: {}", e); |
| 251 | } |
| 252 | } |
| 253 | DropBehavior::Commit => { |
| 254 | // Attempt to commit, log error if it fails |
| 255 | if let Err(e) = self.commit_internal() { |
| 256 | eprintln!("Warning: Failed to commit transaction on drop: {}", e); |
| 257 | } |
| 258 | } |
| 259 | DropBehavior::Panic => { |
| 260 | if !std::thread::panicking() { |
| 261 | panic!("Transaction dropped without explicit commit or rollback"); |
| 262 | } |
| 263 | } |
| 264 | DropBehavior::Ignore => { |
| 265 | // Do nothing |
| 266 | } |
| 267 | } |
| 268 | } |
| 269 | } |
| 270 | |
| 271 | #[cfg(test)] |
nothing calls this directly
no test coverage detected