Skip to content

Commit f6c9f17

Browse files
committed
Removed mistake in errors
1 parent 9d896e3 commit f6c9f17

File tree

6 files changed

+25
-23
lines changed

6 files changed

+25
-23
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
[![PyPI - Python Version](https://img.shields.io/badge/PYTHON-3.9%20%7C%203.10%20%7C%203.11%20%7C%203.12%20%7C%203.13-blue?style=for-the-badge
22
)](https://pypi.org/project/psqlpy/)
3+
[![PyPI - Python Version](https://img.shields.io/badge/Tested%20On%20PostgreSQL-14%20%7C%2015%20%7C%2016%20%7C17-2be28a?style=for-the-badge
4+
)](https://pypi.org/project/psqlpy/)
35
[![PyPI](https://img.shields.io/pypi/v/psqlpy?style=for-the-badge)](https://pypi.org/project/psqlpy/)
46
[![PyPI - Downloads](https://img.shields.io/pypi/dm/psqlpy?style=for-the-badge)](https://pypistats.org/packages/psqlpy)
57

src/driver/common.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ macro_rules! impl_transaction_methods {
194194
pub async fn commit(&mut self) -> PSQLPyResult<()> {
195195
let conn = self.conn.clone();
196196
let Some(conn) = conn else {
197-
return Err(RustPSQLDriverError::TransactionClosedError("1".into()));
197+
return Err(RustPSQLDriverError::TransactionClosedError);
198198
};
199199
let mut write_conn_g = conn.write().await;
200200
write_conn_g.commit().await?;
@@ -209,7 +209,7 @@ macro_rules! impl_transaction_methods {
209209
pub async fn rollback(&mut self) -> PSQLPyResult<()> {
210210
let conn = self.conn.clone();
211211
let Some(conn) = conn else {
212-
return Err(RustPSQLDriverError::TransactionClosedError("2".into()));
212+
return Err(RustPSQLDriverError::TransactionClosedError);
213213
};
214214
let mut write_conn_g = conn.write().await;
215215
write_conn_g.rollback().await?;

src/driver/cursor.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@ impl Cursor {
5454

5555
async fn query_portal(&self, size: i32) -> PSQLPyResult<PSQLDriverPyQueryResult> {
5656
let Some(transaction) = &self.transaction else {
57-
return Err(RustPSQLDriverError::TransactionClosedError("3".into()));
57+
return Err(RustPSQLDriverError::TransactionClosedError);
5858
};
5959
let Some(portal) = &self.inner else {
60-
return Err(RustPSQLDriverError::TransactionClosedError("4".into()));
60+
return Err(RustPSQLDriverError::TransactionClosedError);
6161
};
6262
transaction.query_portal(&portal, size).await
6363
}
@@ -162,10 +162,10 @@ impl Cursor {
162162
let py_future = Python::with_gil(move |gil| {
163163
rustdriver_future(gil, async move {
164164
let Some(txid) = &txid else {
165-
return Err(RustPSQLDriverError::TransactionClosedError("5".into()));
165+
return Err(RustPSQLDriverError::TransactionClosedError);
166166
};
167167
let Some(portal) = &portal else {
168-
return Err(RustPSQLDriverError::TransactionClosedError("6".into()));
168+
return Err(RustPSQLDriverError::TransactionClosedError);
169169
};
170170
let result = txid.query_portal(&portal, size).await?;
171171

src/driver/prepared_statement.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ impl PreparedStatement {
3939
impl PreparedStatement {
4040
async fn execute(&self) -> PSQLPyResult<PSQLDriverPyQueryResult> {
4141
let Some(conn) = &self.conn else {
42-
return Err(RustPSQLDriverError::TransactionClosedError("12".into()));
42+
return Err(RustPSQLDriverError::TransactionClosedError);
4343
};
4444

4545
let read_conn_g = conn.read().await;

src/driver/transaction.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ impl Transaction {
7171
});
7272

7373
let Some(conn) = conn else {
74-
return Err(RustPSQLDriverError::TransactionClosedError("7".into()));
74+
return Err(RustPSQLDriverError::TransactionClosedError);
7575
};
7676
let mut write_conn_g = conn.write().await;
7777
write_conn_g
@@ -98,7 +98,7 @@ impl Transaction {
9898
});
9999

100100
let Some(conn) = conn else {
101-
return Err(RustPSQLDriverError::TransactionClosedError("8".into()));
101+
return Err(RustPSQLDriverError::TransactionClosedError);
102102
};
103103
let mut write_conn_g = conn.write().await;
104104
if is_exception_none {
@@ -121,7 +121,7 @@ impl Transaction {
121121
pub async fn begin(&mut self) -> PSQLPyResult<()> {
122122
let conn = &self.conn;
123123
let Some(conn) = conn else {
124-
return Err(RustPSQLDriverError::TransactionClosedError("9".into()));
124+
return Err(RustPSQLDriverError::TransactionClosedError);
125125
};
126126
let mut write_conn_g = conn.write().await;
127127
write_conn_g
@@ -139,7 +139,7 @@ impl Transaction {
139139
prepared: Option<bool>,
140140
) -> PSQLPyResult<PSQLDriverPyQueryResult> {
141141
let Some(conn) = &self.conn else {
142-
return Err(RustPSQLDriverError::TransactionClosedError("10".into()));
142+
return Err(RustPSQLDriverError::TransactionClosedError);
143143
};
144144

145145
let read_conn_g = conn.read().await;
@@ -154,7 +154,7 @@ impl Transaction {
154154
prepared: Option<bool>,
155155
) -> PSQLPyResult<PSQLDriverPyQueryResult> {
156156
let Some(conn) = &self.conn else {
157-
return Err(RustPSQLDriverError::TransactionClosedError("11".into()));
157+
return Err(RustPSQLDriverError::TransactionClosedError);
158158
};
159159

160160
let read_conn_g = conn.read().await;
@@ -169,7 +169,7 @@ impl Transaction {
169169
prepared: Option<bool>,
170170
) -> PSQLPyResult<Py<PyAny>> {
171171
let Some(conn) = &self.conn else {
172-
return Err(RustPSQLDriverError::TransactionClosedError("12".into()));
172+
return Err(RustPSQLDriverError::TransactionClosedError);
173173
};
174174

175175
let read_conn_g = conn.read().await;
@@ -180,7 +180,7 @@ impl Transaction {
180180

181181
pub async fn execute_batch(&self, querystring: String) -> PSQLPyResult<()> {
182182
let Some(conn) = &self.conn else {
183-
return Err(RustPSQLDriverError::TransactionClosedError("13".into()));
183+
return Err(RustPSQLDriverError::TransactionClosedError);
184184
};
185185

186186
let read_conn_g = conn.read().await;
@@ -195,7 +195,7 @@ impl Transaction {
195195
prepared: Option<bool>,
196196
) -> PSQLPyResult<()> {
197197
let Some(conn) = &self.conn else {
198-
return Err(RustPSQLDriverError::TransactionClosedError("14".into()));
198+
return Err(RustPSQLDriverError::TransactionClosedError);
199199
};
200200

201201
let read_conn_g = conn.read().await;
@@ -212,7 +212,7 @@ impl Transaction {
212212
prepared: Option<bool>,
213213
) -> PSQLPyResult<PSQLDriverSinglePyQueryResult> {
214214
let Some(conn) = &self.conn else {
215-
return Err(RustPSQLDriverError::TransactionClosedError("15".into()));
215+
return Err(RustPSQLDriverError::TransactionClosedError);
216216
};
217217

218218
let read_conn_g = conn.read().await;
@@ -223,7 +223,7 @@ impl Transaction {
223223

224224
pub async fn create_savepoint(&mut self, savepoint_name: String) -> PSQLPyResult<()> {
225225
let Some(conn) = &self.conn else {
226-
return Err(RustPSQLDriverError::TransactionClosedError("16".into()));
226+
return Err(RustPSQLDriverError::TransactionClosedError);
227227
};
228228

229229
let read_conn_g = conn.read().await;
@@ -236,7 +236,7 @@ impl Transaction {
236236

237237
pub async fn release_savepoint(&mut self, savepoint_name: String) -> PSQLPyResult<()> {
238238
let Some(conn) = &self.conn else {
239-
return Err(RustPSQLDriverError::TransactionClosedError("17".into()));
239+
return Err(RustPSQLDriverError::TransactionClosedError);
240240
};
241241

242242
let read_conn_g = conn.read().await;
@@ -249,7 +249,7 @@ impl Transaction {
249249

250250
pub async fn rollback_savepoint(&mut self, savepoint_name: String) -> PSQLPyResult<()> {
251251
let Some(conn) = &self.conn else {
252-
return Err(RustPSQLDriverError::TransactionClosedError("18".into()));
252+
return Err(RustPSQLDriverError::TransactionClosedError);
253253
};
254254

255255
let read_conn_g = conn.read().await;
@@ -305,6 +305,6 @@ impl Transaction {
305305
return future::try_join_all(futures).await;
306306
}
307307

308-
Err(RustPSQLDriverError::TransactionClosedError("19".into()))
308+
Err(RustPSQLDriverError::TransactionClosedError)
309309
}
310310
}

src/exceptions/rust_errors.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ pub enum RustPSQLDriverError {
4949
TransactionSavepointError(String),
5050
#[error("Transaction execute error: {0}")]
5151
TransactionExecuteError(String),
52-
#[error("Underlying connection is returned to the pool: {0}")]
53-
TransactionClosedError(String),
52+
#[error("Underlying connection is returned to the pool")]
53+
TransactionClosedError,
5454

5555
// Cursor Errors
5656
#[error("Cursor error: {0}")]
@@ -162,7 +162,7 @@ impl From<RustPSQLDriverError> for pyo3::PyErr {
162162
RustPSQLDriverError::TransactionExecuteError(_) => {
163163
TransactionExecuteError::new_err((error_desc,))
164164
}
165-
RustPSQLDriverError::TransactionClosedError(_) => {
165+
RustPSQLDriverError::TransactionClosedError => {
166166
TransactionClosedError::new_err((error_desc,))
167167
}
168168
RustPSQLDriverError::BaseCursorError(_) => BaseCursorError::new_err((error_desc,)),

0 commit comments

Comments
 (0)