Commit Graph

315 Commits

Author SHA1 Message Date
Daniele Varrazzo
eddb0e3d90 Fixed dsn and closed attributes in failing connection subclasses.
From ticket #192 discussion.

Conflicts:

	NEWS
	tests/test_connection.py
2014-04-07 17:53:38 +01:00
Daniele Varrazzo
6b43b0088e 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

Conflicts:

	NEWS
2014-04-07 17:51:53 +01:00
Daniele Varrazzo
ff341077e0 Check connection type in lobject init
Fixes ticket #187.

Conflicts:

	NEWS
2014-04-07 17:43:37 +01:00
Daniele Varrazzo
5a55339e11 Really test named cursors in test_scroll_named() 2014-04-07 17:40:32 +01:00
Daniele Varrazzo
fb5e14c701 Meaningful connection errors report a meaningful message
Fixes issue #173.

Conflicts:

	NEWS
2014-04-07 17:38:17 +01:00
Daniele Varrazzo
00c1d867c2 Added regression test for infinity parsing in dates
...and a couple of typos.
2014-04-07 17:30:58 +01:00
Daniele Varrazzo
0914323328 Added test to verify copysize handling in copy_expert
Not an original psycopg2 bug but present in pure python implementation,
e.g. ctypes issue #25 and cffi issue #5.

https://github.com/mvantellingen/psycopg2-ctypes/issues/25
https://github.com/chtd/psycopg2cffi/pull/5
2014-04-07 17:29:50 +01:00
Daniele Varrazzo
d0f49f9887 Skip tests on python implementations without getrefcount()
PyPy is one of these.

Conflicts:

	tests/test_cursor.py
	tests/test_module.py
2014-04-07 17:29:36 +01:00
Piotr Kasprzyk
5a74117118 Fix multiple misspellings
Conflicts:

	NEWS
	doc/src/usage.rst
	psycopg/pqpath.c
	setup.cfg
2013-04-26 10:17:17 +01:00
Daniele Varrazzo
802381358a Fixed broken test decorator preventing 3 tests to run 2013-03-20 17:33:42 +00:00
Daniele Varrazzo
c111ef5dff Properly cleanup memory of broken connections
Fixed ticket #148.
2013-03-20 11:45:17 +00:00
Daniele Varrazzo
67445dfbea Fixed pickling of DictRow objects too 2012-12-11 01:40:02 +00:00
Daniele Varrazzo
5bee4d3379 Fixed pickling of RealDictRow objects 2012-12-11 01:40:02 +00:00
Daniele Varrazzo
0653861bc4 Fixed empty strings handling in composite caster
Closes ticket #141.
2012-12-03 14:20:08 +00:00
Daniele Varrazzo
5e6eabd9f8 Fixed pickling of FixedOffsetTimezone objects
I have also verified that the fixed class can unpickle instance pickled with
the buggy one and viceversa.

Fixes ticket #135.
2012-10-21 21:47:32 +01:00
Daniele Varrazzo
58d048198f Close the connection on error in callback
Unfortunately PQcancel blocks, so it's not better than PQgetResult.
It has been suggested to use PQreset in non-blocking way but this would give
the Python program the burden of handling a connection done but not configured
in an unexpected place.
2012-10-09 02:01:29 +01:00
Daniele Varrazzo
74e6efd717 Raise TypeError instead of InterfaceError on bad params on connect()
TypeError is the standard Python error raised in this case:

    $ python -c "(lambda a: None)(b=10)"
    TypeError: <lambda>() got an unexpected keyword argument 'b'

We only used to raise InterfaceError when connect was used without
any parameter at all, so it's hard to think a program depending on
that design. Furthermore the function has always raised (and still
does) OperationalError too, if the bad argument is detected by the
libpq, and that cannot be changed because we can't tell the
difference from a normal connection error.
2012-09-26 11:55:21 +01:00
Daniele Varrazzo
32fae728b3 Dropped quirks in connection arguments handling
Now connect() raises an exception instead of swallowing keyword arguments
when a connection string is specified as well

Closes ticket #131.
2012-09-25 23:46:46 +01:00
Daniele Varrazzo
c7bee92160 Fixed infinite loop when parsing '{' as array 2012-09-20 03:19:24 +01:00
Daniele Varrazzo
72e9cf7b6d Fixed return value after malformed arrays 2012-09-10 04:20:39 +01:00
Daniele Varrazzo
bc400f6961 Fixed tests to run with PG 8.3 2012-09-04 21:23:19 +01:00
Daniele Varrazzo
cc951b5fbe Fixed tpc_recover() with RealDictStuff
Same problem and correction of ticket #114.
2012-08-14 23:29:19 +01:00
Daniele Varrazzo
fd4153d632 Fixed register_hstore and register_composite with non-dbapi objects
Closed ticket #114.
2012-08-14 23:26:17 +01:00
Daniele Varrazzo
365a1b20a7 Added tests to verify cursor() arguments propagation 2012-04-11 18:00:18 +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
37aa62ca52 Merge branch 'close-idempotent' into devel 2012-03-05 02:47:52 +00: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
2cbedbee45 Dropped test about close() on closed connection raising an exception
This seems unnecessary and has caused problems to a few. The DB-SIG seems
agreeing on the change:
http://mail.python.org/pipermail/db-sig/2011-October/005811.html
2012-03-04 05:10:06 +00:00
Marti Raudsepp
b97599166e Update all links to PostgreSQL docs to the current version.
I also checked all links and anchors to make sure they're still valid.
2012-02-28 18:28:07 +02:00
Daniele Varrazzo
5fcbe7bd0f Check/set connection status at commit inside the critical section
Failing to do so was causing the issue reported in ticket #103. The issue
as reported was fixed when SET ISOLATION LEVEL was dropped, but the real
problem wasn't fixed.
2012-02-24 03:28:20 +00:00
Daniele Varrazzo
0c337a2029 Added support for inet array 2012-02-23 23:56:55 +00:00
Daniele Varrazzo
9ffa1f4b59 Fixed inet test that wasn't testing anything 2012-02-23 23:35:05 +00:00
Daniele Varrazzo
98d6d96ee3 Fixed exception testing on Python 3
...and so caught exceptions are local to the except suite in Py3.
(Lo sapevate? Sapevatelo!)
2012-02-23 23:15:42 +00:00
Daniele Varrazzo
b8597dc1d3 Fixed NamedTupleCursor rownumber during iteration.
The correction is similar to the other one for the other subclasses.

Also added tests for rowcount and rownumber during different fetch styles.
Just in case.
2012-02-23 22:58:58 +00:00
Daniele Varrazzo
ebec522a07 Fixed rownumber for cursor subclasses during iterations
Regression introduced to fix ticket #80. Don't use fetchmany to get the
chunks of values. I did it that way because I was ending up into infinite
recursion calling __iter__ from __iter__: the solution has been the
"while 1: yield next()" idiom.
2012-02-23 22:55:13 +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
71d1690870 Test methods reordered to improve readability 2012-02-23 21:27:45 +00:00
Menno Smits
bca7200b3f Cache FixedOffsetTimezone instances
Avoid creating new a new FixedOffsetTimezone instance if one with the
same offset and name has been created before. This will save memory
when returning many rows containing "timestamp with timezone" columns,
and also improves comparability.
2012-01-30 13:27:40 +00:00
Menno Smits
1469a56512 Fixed repr for FixedOffsetTimezone for offsets west of UTC (negative)
The offset displayed was always positive and somewhat confusing. The
offset displayed now is the offset that the instance was created
with.

Also added some tests for initialisation.
2012-01-30 13:27:01 +00:00
Menno Smits
35ff2def34 Renamed shadowed test method 2012-01-29 19:35:38 +00:00
Daniele Varrazzo
43daba38e7 Make Error and subclasses picklable
Useful for multiprocessing interaction.
Closes ticket #90.
2012-01-14 17:34:09 +00:00
Daniele Varrazzo
28f1013c2a Dropped duplicate import 2012-01-14 17:28:37 +00:00
Daniele Varrazzo
05fb0e2fbf Added tests to verify ticket #84
fetchmany() with no arg is broken in cursor subclasses.
2012-01-10 01:27:43 +00:00
Daniele Varrazzo
702ae0a904 Force GC during weakref tests
Required to run the tests under PyPy with no refcount. See
https://github.com/mvantellingen/psycopg2-ctypes/pull/15#issuecomment-3274618
2011-12-26 22:35:33 +01:00
Daniele Varrazzo
ede0e145dd Added tests for cursor scroll 2011-12-26 22:00:25 +01:00
Daniele Varrazzo
2cf35b69de 'register_composite()' also works with tables
Skip dropped and hidden columns when inspecting the schema.
2011-12-15 20:11:17 +00:00
Daniele Varrazzo
bb8e1e9455 Fixed error in schema mismatch in composite caster 2011-12-15 19:56:52 +00:00
Daniele Varrazzo
b5de04d2ff Put back a distinct ISOLATION_LEVEL_READ_UNCOMMITTED value 2011-12-15 12:53:48 +00:00
Federico Di Gregorio
d2d94e203f Reverted isolation level values to backward compatible values
This basically removes the READ UNCOMMITED level (that internally
PostgreSQL maps to READ COMMITED anyway) to keep the numeric values
compattible with old psycopg versions. For full details and discussion
see this thread:
http://archives.postgresql.org/psycopg/2011-12/msg00008.php
2011-12-15 12:25:19 +01:00
Daniele Varrazzo
8473209d24 Named DictCursor/RealDictCursor honour itersize
Closes ticket #80.
2011-12-11 22:06:15 +00:00