Further work on adjusting attribute, method and parameter names to be · jonaskriks/python-cx_Oracle@ba6e054 · GitHub
Skip to content

Commit ba6e054

Browse files
Further work on adjusting attribute, method and parameter names to be
consistent and to comply with PEP 8 naming guidelines.
1 parent 82fb398 commit ba6e054

5 files changed

Lines changed: 158 additions & 34 deletions

File tree

doc/src/api_manual/connection.rst

Lines changed: 22 additions & 8 deletions

doc/src/api_manual/cursor.rst

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ Cursor Object
9999

100100

101101
.. method:: Cursor.callfunc(name, returnType, parameters=[], \
102-
keywordParameters={})
102+
keyword_parameters={})
103103

104104
Call a function with the given name. The return type is specified in the
105105
same notation as is required by :meth:`~Cursor.setinputsizes()`. The
@@ -110,6 +110,13 @@ Cursor Object
110110

111111
See :ref:`plsqlfunc` for an example.
112112

113+
.. versionchanged:: 8.2
114+
115+
For consistency and compliance with the PEP 8 naming style, the
116+
parameter `keywordParameters` was renamed to `keyword_parameters`. The
117+
old name will continue to work as a keyword parameter for a period of
118+
time.
119+
113120
.. note::
114121

115122
The DB API definition does not define this method.
@@ -121,7 +128,7 @@ Cursor Object
121128
parameter list refers to the return value of the function.
122129

123130

124-
.. method:: Cursor.callproc(name, parameters=[], keywordParameters={})
131+
.. method:: Cursor.callproc(name, parameters=[], keyword_parameters={})
125132

126133
Call a procedure with the given name. The sequence of parameters must
127134
contain one entry for each parameter that the procedure expects. The result
@@ -132,6 +139,13 @@ Cursor Object
132139

133140
See :ref:`plsqlproc` for an example.
134141

142+
.. versionchanged:: 8.2
143+
144+
For consistency and compliance with the PEP 8 naming style, the
145+
parameter `keywordParameters` was renamed to `keyword_parameters`. The
146+
old name will continue to work as a keyword parameter for a period of
147+
time.
148+
135149
.. note::
136150

137151
The DB API definition does not allow for keyword parameters.
@@ -167,7 +181,7 @@ Cursor Object
167181
defined at the module level.
168182

169183

170-
.. method:: Cursor.execute(statement, [parameters], \*\*keywordParameters)
184+
.. method:: Cursor.execute(statement, parameters=[], ** keyword_parameters)
171185

172186
Execute a statement against the database. See :ref:`sqlexecution`.
173187

@@ -245,7 +259,7 @@ Cursor Object
245259
a TypeError exception.
246260

247261

248-
.. method:: Cursor.executemanyprepared(numIters)
262+
.. method:: Cursor.executemanyprepared(num_iters)
249263

250264
Execute the previously prepared and bound statement the given number of
251265
times. The variables that are bound must have already been set to their
@@ -276,7 +290,7 @@ Cursor Object
276290
See :ref:`fetching` for an example.
277291

278292

279-
.. method:: Cursor.fetchmany([numRows=cursor.arraysize])
293+
.. method:: Cursor.fetchmany(num_rows=cursor.arraysize)
280294

281295
Fetch the next set of rows of a query result, returning a list of tuples.
282296
An empty list is returned if no more rows are available. Note that the
@@ -302,17 +316,19 @@ Cursor Object
302316

303317
See :ref:`fetching` for an example.
304318

305-
.. method:: Cursor.fetchraw([numRows=cursor.arraysize])
319+
.. method:: Cursor.fetchraw(num_rows=cursor.arraysize)
306320

307321
Fetch the next set of rows of a query result into the internal buffers of
308322
the defined variables for the cursor. The number of rows actually fetched
309-
is returned. This method was designed for the case where optimal
310-
performance is required as it comes at the expense of compatibility with
311-
the DB API.
323+
is returned.
312324

313325
An exception is raised if the previous call to :meth:`~Cursor.execute()`
314326
did not produce any result set or no call was issued yet.
315327

328+
.. deprecated:: 8.2
329+
330+
Use :meth:`Cursor.fetchmany()` instead.
331+
316332
.. note::
317333

318334
The DB API definition does not define this method.

doc/src/api_manual/deprecations.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,26 @@ if applicable. The most recent deprecations are listed first.
4747
- Replace with parameter name `max_sessions_per_shard`
4848
* - `payloadType` parameter to :meth:`Connection.queue()`
4949
- Replace with parameter name `payload_type` if using keyword parmeters.
50+
* - `ipAddress` parameter to :meth:`Connection.subscribe()`
51+
- Replace with parameter name `ip_address`
52+
* - `groupingClass` parameter to :meth:`Connection.subscribe()`
53+
- Replace with parameter name `grouping_class`
54+
* - `groupingValue` parameter to :meth:`Connection.subscribe()`
55+
- Replace with parameter name `grouping_value`
56+
* - `groupingType` parameter to :meth:`Connection.subscribe()`
57+
- Replace with parameter name `grouping_type`
58+
* - `clientInitiated` parameter to :meth:`Connection.subscribe()`
59+
- Replace with parameter name `client_initiated`
5060
* - `Connection.callTimeout`
5161
- Replace with :data:`Connection.call_timeout`
62+
* - `Connection.tnsentry`
63+
- Replace with :data:`Connection.dsn`
64+
* - `keywordParameters` parameter to :meth:`Cursor.callfunc()`
65+
- Replace with parameter name `keyword_parameters`
66+
* - `keywordParameters` parameter to :meth:`Cursor.callproc()`
67+
- Replace with parameter name `keyword_parameters`
68+
* - `Cursor.fetchraw()`
69+
- Replace with :meth:`Cursor.fetchmany()`
5270
* - `Queue.deqMany`
5371
- Replace with :meth:`Queue.deqmany()`
5472
* - `Queue.deqOne`

src/cxoConnection.c

Lines changed: 62 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1536,11 +1536,15 @@ static PyObject *cxoConnection_subscribe(cxoConnection *conn, PyObject* args,
15361536
PyObject* keywordArgs)
15371537
{
15381538
static char *keywordList[] = { "namespace", "protocol", "callback",
1539-
"timeout", "operations", "port", "qos", "ipAddress",
1540-
"groupingClass", "groupingValue", "groupingType", "name",
1541-
"clientInitiated", NULL };
1542-
PyObject *callback, *ipAddress, *name;
1539+
"timeout", "operations", "port", "qos", "ip_address",
1540+
"grouping_class", "grouping_value", "grouping_type", "name",
1541+
"client_initiated", "ipAddress", "groupingClass", "groupingValue",
1542+
"groupingType", "clientInitiated", NULL };
1543+
PyObject *callback, *ipAddress, *ipAddressDeprecated, *name;
1544+
uint8_t groupingClassDeprecated, groupingTypeDeprecated;
15431545
cxoBuffer ipAddressBuffer, nameBuffer;
1546+
uint32_t groupingValueDeprecated;
1547+
int clientInitiatedDeprecated;
15441548
dpiSubscrCreateParams params;
15451549
cxoSubscr *subscr;
15461550

@@ -1549,17 +1553,68 @@ static PyObject *cxoConnection_subscribe(cxoConnection *conn, PyObject* args,
15491553
return cxoError_raiseAndReturnNull();
15501554

15511555
// validate parameters
1552-
callback = name = ipAddress = NULL;
1553-
if (!PyArg_ParseTupleAndKeywords(args, keywordArgs, "|IIOIIIIObIbOp",
1556+
groupingValueDeprecated = 0;
1557+
clientInitiatedDeprecated = 0;
1558+
groupingClassDeprecated = groupingTypeDeprecated = 0;
1559+
callback = name = ipAddress = ipAddressDeprecated = NULL;
1560+
if (!PyArg_ParseTupleAndKeywords(args, keywordArgs, "|IIOIIIIObIbOpObIbp",
15541561
keywordList, &params.subscrNamespace, &params.protocol, &callback,
15551562
&params.timeout, &params.operations, &params.portNumber,
15561563
&params.qos, &ipAddress, &params.groupingClass,
15571564
&params.groupingValue, &params.groupingType, &name,
1558-
&params.clientInitiated))
1565+
&params.clientInitiated, &ipAddressDeprecated,
1566+
&groupingClassDeprecated, &groupingValueDeprecated,
1567+
&groupingTypeDeprecated, &clientInitiatedDeprecated))
15591568
return NULL;
15601569
if (cxoConnection_isConnected(conn) < 0)
15611570
return NULL;
15621571

1572+
// check duplicate parameters to ensure that both are not specified
1573+
if (ipAddressDeprecated) {
1574+
if (ipAddress) {
1575+
cxoError_raiseFromString(cxoProgrammingErrorException,
1576+
"ip_address and ipAddress cannot both be specified");
1577+
return NULL;
1578+
}
1579+
ipAddress = ipAddressDeprecated;
1580+
}
1581+
if (groupingClassDeprecated != 0) {
1582+
if (params.groupingClass != 0) {
1583+
cxoError_raiseFromString(cxoProgrammingErrorException,
1584+
"grouping_class and groupingClass cannot both be "
1585+
"specified");
1586+
return NULL;
1587+
}
1588+
params.groupingClass = groupingClassDeprecated;
1589+
}
1590+
if (groupingValueDeprecated != 0) {
1591+
if (params.groupingValue != 0) {
1592+
cxoError_raiseFromString(cxoProgrammingErrorException,
1593+
"grouping_value and groupingValue cannot both be "
1594+
"specified");
1595+
return NULL;
1596+
}
1597+
params.groupingValue = groupingValueDeprecated;
1598+
}
1599+
if (groupingTypeDeprecated != 0) {
1600+
if (params.groupingType != 0) {
1601+
cxoError_raiseFromString(cxoProgrammingErrorException,
1602+
"grouping_type and groupingType cannot both be "
1603+
"specified");
1604+
return NULL;
1605+
}
1606+
params.groupingType = groupingTypeDeprecated;
1607+
}
1608+
if (clientInitiatedDeprecated != 0) {
1609+
if (params.clientInitiated != 0) {
1610+
cxoError_raiseFromString(cxoProgrammingErrorException,
1611+
"client_initiated and clientInitiated cannot both be "
1612+
"specified");
1613+
return NULL;
1614+
}
1615+
params.clientInitiated = clientInitiatedDeprecated;
1616+
}
1617+
15631618
// populate IP address in parameters, if applicable
15641619
cxoBuffer_init(&ipAddressBuffer);
15651620
if (ipAddress) {

src/cxoCursor.c

Lines changed: 31 additions & 10 deletions

0 commit comments

Comments
 (0)