Commit Graph

47 Commits

Author SHA1 Message Date
mrmilosz
c205f140a0 callproc: tests, docs, and comment/error-reporting touchups. 2015-12-12 17:49:59 -05:00
Owen Raccuglia
5af5fb4cc6 Allow pickling of cursor.description
This is for people using dtuple.py; a dtuple.DatabaseTuple instance
keeps a reference to cursor.description, which is not picklable because
psycopg2 doesn't export the Column namedtuple it uses.

This commit exports the Column namedtuple, and includes a test to verify
the pickle/unpickle works after exporting Column.
2015-02-08 02:31:33 +00:00
Daniele Varrazzo
c81522079e Added test to verify withhold cursors work in autocommit 2014-08-21 05:35:11 +01:00
Daniele Varrazzo
283a422b4d Added test to verify withhold transaction behaviour
A withhold cursor can read its data when the transaction is closed, so
it shouldn't start a new one upon movement/close.
2014-08-21 05:35:10 +01:00
Daniele Varrazzo
e076e935b9 Added test with objects without length as callproc param 2014-06-06 21:42:20 +02:00
Daniele Varrazzo
7b82be936d Don't segfault on uninitialized cursor
It can happen with bad cursor subclasses not calling super's init. Raise
an exception instead of segfaulting.

Closes #195
2014-02-26 19:41:59 +00:00
Daniele Varrazzo
2e3833f7fb Really test named cursors in test_scroll_named() 2013-10-16 19:10:21 +01:00
Daniele Varrazzo
a44db81d9b Skip tests on python implementations without getrefcount()
PyPy is one of these.
2013-05-06 10:39:24 +01:00
Daniele Varrazzo
0e06addc9f Testing boilerplate unified in a single base class
The class makes a connection always available, allows creating
new connection and closes everything on tear down.
2013-04-07 00:23:30 +01:00
Daniele Varrazzo
a79a5292e7 Added support with cursors without scroll clause
Using nothing is different from NO SCROLL, see DECLARE notes
in PG docs.
2012-08-15 09:44:44 +01:00
Daniele Varrazzo
d074b096be Added test for scrollable cursor 2012-08-15 01:11:26 +01:00
Daniele Varrazzo
27421f1e41 Name can be passed as None to cursor()
Makes invocation from subclasses and generic code easier.

Code simplified by using default values for keyword arguments
and avoiding needless conversions back and forth between Python and C
strings. Also added connection type check to cursor's init.
2012-04-11 17:32:10 +01:00
Daniele Varrazzo
84f2a370f6 close() methods don't raise errors if called on closed objects 2012-03-04 05:10:07 +00:00
Daniele Varrazzo
7221ea9ec5 Added test to check rowcount behaves fine during named cursor iteration
Actually *it doesn't*: once we iterate the first itersize records, rowcount
is reset to zero. If we want to fix it we need an extra member in the
cursor.
2012-02-23 22:04:22 +00:00
Daniele Varrazzo
ede0e145dd Added tests for cursor scroll 2011-12-26 22:00:25 +01:00
Daniele Varrazzo
ad3a198919 Fixed reference leak with arguments referenced more than once in queries
Plus, some more care in objects life cycle, mostly in exceptions handling.

Closes ticket #81.
2011-12-11 02:52:06 +00:00
Daniele Varrazzo
37a9eb3615 Test and document the named cursor stealing technique 2011-10-14 23:17:24 +01:00
Daniele Varrazzo
e4424bdfdc Fixed tests to run with antebellum Postgres versions 2011-10-05 00:12:35 +01:00
Federico Di Gregorio
880aa07a58 WITH HOLD documentation a argument parsing changes
Now any true value will do for the withhold parameter.
2011-08-10 19:21:12 +02:00
Federico Di Gregorio
479bdf7458 New 'withhold' parameter for connection.cursor() 2011-08-10 18:25:46 +02:00
Federico Di Gregorio
2f6336ea78 First try at curs.withhold implementation 2011-07-05 10:28:34 +02:00
Daniele Varrazzo
fcbe0466a6 Correctly detect an empty query sent to the backend
Closes ticket #46.
2011-03-04 20:30:43 +00:00
Daniele Varrazzo
c01a7edbf4 Fixed test for execution with older PostgreSQL versions 2011-02-23 08:43:01 +00:00
Daniele Varrazzo
1db9c9b8ce The cursor name can be a non-valid PostgreSQL identifier 2011-02-23 01:53:25 +00:00
Daniele Varrazzo
c620f18be1 Provide cursor.description as named tuple if possible
If namedtuple() is not available, use regular tuples.
2011-02-19 00:05:43 +00:00
Daniele Varrazzo
99b3c72312 Some cleanup in mogrify
- Raise an exception on incomplete placeholders.
- Minor speedups.
- Don't change the string in place (??!!) if the placeholder is not s
  and the value is null.

The latter point can be done because downstream we don't accept anything
different from s anyway (in the Bytes_Format function).

Notice that now the format string is constant whatever the arguments.
This means that executemany is still more inefficient than it should be
as mogrify may work only on the parameters. However this is an
implementation only worthwhile if we start supporting real parameters.

Let's talk about that for the next release.
2011-02-18 02:33:42 +00:00
Daniele Varrazzo
63ac6cdde5 Added cursor.itersize
The value is used to control the number of records to fetch per network
roundtrip in named cursors iteration. Used to avoid the inefficient
arraysize default of 1 without giving this value the magic meaning of
2000.
2011-02-17 12:36:02 +00:00
Daniele Varrazzo
c96ba553da Cleanup of skipping of testing methods on certain Py/PG versions 2011-02-15 17:11:07 +00:00
Daniele Varrazzo
be22dfb765 Skip test if clock_timestamp function is not available 2011-02-15 15:25:14 +00:00
Daniele Varrazzo
9e9c221637 Work around a 2to3 next fixer bug in a test 2011-02-11 17:54:41 +00:00
Federico Di Gregorio
da27142882 Merge branch 'python3' into python2 2011-02-06 16:47:05 +01:00
Daniele Varrazzo
fab31e9441 Fetch 'arraysize' records per roundtrip in named cursors iteration
Closes ticket #33.
2011-02-05 15:24:00 +01:00
Daniele Varrazzo
8a1de1ec4e Added test to verify named cursor efficiency.
Iter shouldn't fetch one record at time.
2011-02-01 03:01:47 +00:00
Daniele Varrazzo
79048ff19a Merge branch 'python2' into python3
Conflicts:
	NEWS-2.3
	tests/__init__.py
	tests/test_lobject.py
	tests/test_quote.py
	tests/testutils.py
2011-01-10 00:46:02 +00:00
Daniele Varrazzo
15a09da96d Added license to unit tests
As the test suite is now part of the source distribution.
2011-01-09 23:44:35 +00:00
Daniele Varrazzo
7c1b03bd45 All tests made executable. 2011-01-07 00:58:29 +00:00
Daniele Varrazzo
80bd6e2794 Merge branch 'python2' into python3
Conflicts:
	NEWS-2.3
	psycopg/connection_type.c
	tests/test_connection.py
	tests/types_basic.py
2011-01-03 21:43:02 +01:00
Daniele Varrazzo
19ff51ae75 The cursor is weakly referenceable 2011-01-03 21:34:49 +01:00
Daniele Varrazzo
929d62053a Merge branch 'python2' into python3
Conflicts:
	NEWS-2.3
	setup.py
2011-01-02 03:28:00 +01:00
Daniele Varrazzo
159cda3688 Added cursor.cast() method
The method exposes the typecasters lookup algorithm. Useful to create
recursive typecasters.
2011-01-01 22:55:10 +01:00
Daniele Varrazzo
b78ff4a273 Several tests ported to Python 3. 2010-12-31 03:18:27 +01:00
Daniele Varrazzo
ade1b2cc7b Test suite converted into a proper package.
Dropped cyclic import from modules to tests: they were only working
because a second copy of the package was found in the project dir.
Use relative import so that 2to3 can do a good conversion.
2010-12-21 05:02:19 +00:00
Daniele Varrazzo
31093a7a58 Some light cleanup for Py3 conversion.
Either flagged as warning by python2.6 -3 or converted by 2to3.
2010-12-21 04:02:13 +00:00
Daniele Varrazzo
361786f4a8 More careful connections handling during tests. 2010-11-28 17:29:37 +00:00
Daniele Varrazzo
985425fb38 Added test to verify the ticket #7 is fixed. 2010-11-06 02:24:28 +00:00
Daniele Varrazzo
bc2aefeacf cursor.mogrify() accepts unicode queries. 2010-10-05 03:13:44 +01:00
Daniele Varrazzo
bd6a4139da Added test to verify executemany doesn't propagate exceptions. 2010-07-09 15:23:02 +01:00