Commit Graph

467 Commits

Author SHA1 Message Date
Daniele Varrazzo
d3bbd19ccb Separate parse_dsn test in a test case of their own 2015-10-01 11:52:42 +01:00
Daniele Varrazzo
d1af12187c Merge branch 'master' into parse-dsn 2015-10-01 11:39:51 +01:00
Daniele Varrazzo
6803341f21 Report NotSupportedError for PGRES_COPY_BOTH and PGRES_SINGLE_TUPLE
Fixes #352.
2015-09-30 12:28:07 +01:00
Daniele Varrazzo
1f330e9cac Allow connection.notices and notifies to be replaced.
Close #326
2015-06-02 17:02:04 +01:00
Oleksandr Shulgin
d6041271bc Separate parse_dsn test on URI, for libpq >= 9.2 2015-06-02 14:02:29 +02:00
Daniele Varrazzo
b0058c0cc8 Fixed adaptation of lists of None
Note: lists of lists of None are not supported yet.
2015-06-02 12:48:24 +01:00
Oleksandr Shulgin
cc08e14162 Merge branch 'master' into feature/parse-dsn
Conflicts:
	lib/extensions.py
2015-06-02 12:42:03 +02:00
Oleksandr Shulgin
ffd98a82c0 Add test for libpq_version 2015-06-02 11:12:16 +02:00
Oleksandr Shulgin
4bb6f9cef2 Add libpq version discovery 2015-06-01 18:05:11 +02:00
Oleksandr Shulgin
3200cd77bf One more parse_dsn test for unquoted space 2015-06-01 15:18:03 +02:00
Oleksandr Shulgin
6a2f21aa14 Move parse_dsn to extensions, add tests 2015-06-01 15:11:12 +02:00
Hyunjun Kim
4eee1207f9 Fix several typos 2015-05-03 10:30:21 +01:00
Daniele Varrazzo
296caa4556 More tests tweaks
Named cursors on old server versions have a different prefetch behaviour.
This has hidden me the supported range of the 24:00 time format.
Let's have another go at full testing...
2015-02-08 12:51:36 +00:00
Daniele Varrazzo
6177823811 Don't test date 24:00 before PG 8.4 2015-02-08 10:30:48 +00: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
e490e3bfa3 Accept overflow errors testing for LO64 funcs
It is raised on 32 bits by PyArg_ParseTuple. We may work around on
truncate (maybe parsing a py_ssize_t) but we would have the same problem
on seek as the offset is signed.
2015-02-08 02:04:41 +00:00
Daniele Varrazzo
7ce7fef322 Propagate read error messages in COPY FROM
Fix ticket #270.
2015-02-08 01:42:21 +00:00
Daniele Varrazzo
d3c1ad5945 Convert Postgres time 24:00 into 00:00
Fix ticket #278.
2015-02-08 00:41:50 +00:00
Daniele Varrazzo
a338da9c19 Fixed typo in tests 2014-12-25 15:06:18 +01:00
Daniele Varrazzo
bc5e2aeead Keep into account psycopg build in lo64 tests 2014-12-25 15:06:18 +01:00
Blake Rouse
cd67d3d2fe Modify truncate to use lo_truncate64. Use HAVE_LO64 define to use new lo_*64 methods. Check size of offset and length for versions without LO64. 2014-12-25 15:06:18 +01:00
Blake Rouse
e13ec67da3 Use lseek64 and ltell64 to support large object greater than 2gb in size. 2014-12-25 15:06:18 +01:00
Hyunjun Kim
4dbda02145 Cast time into timetz when the tzinfo field is set. 2014-11-13 17:32:06 +09:00
Daniele Varrazzo
1b48033345 Don't try to close the server cursor in error state
`close()` is implicitly called by `__exit__()`, so an exit on error
would run a query on a inerr connection, causing another exception
hiding the original one. The fix is on `close()`, not on `__exit__()`,
because the semantic of the latter is simply to call the former.

Closes #262.
2014-09-16 06:57:34 +01:00
Daniele Varrazzo
6210af2763 Fixed excessively strict notices test
Failing with PG 9.4 because it generates other debug messages during the
test run (rehashing catalog cache).
2014-08-31 03:06:33 +01:00
Daniele Varrazzo
ccc30e1877 Clear adapters in test to maintain reference count 2014-08-28 02:17:54 +01:00
Daniele Varrazzo
ea54aa77ed Added test to verify _psycopg can be imported 2014-08-28 02:17:49 +01: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
634fc004fb Added wishful test suite for jsonb type 2014-08-13 02:01:51 +01:00
Daniele Varrazzo
56adc590ff Fixed segfault if COPY statements are executed
Close ticket #219
2014-06-06 21:42:21 +02:00
Daniele Varrazzo
e076e935b9 Added test with objects without length as callproc param 2014-06-06 21:42:20 +02:00
Jason Erickson
8746b0c6b7 Skip test_cleanup_on_badconn_close on Windows
The Windows server version of PostgreSQL uses a function called pgkill in the
file kill.c in place of the UNIX kill function.  This pgkill function
simulates some of the SIGHUP like commands by passing signals through a named
pipe.  Because it is passing the signal through a pipe, the server doesn't get
the kill signal immediately and therefore fails the test on
test_connection.ConnectionTests.test_cleanup_on_badconn_close.
Ideally, the test should check to see if the server is running on Windows, not
the psycopg.
2014-05-19 12:15:53 +01:00
Jason Erickson
c5f2e29dde Added select.select timeout on AsyncTests.wait
On Windows, the select.select() hangs/waits forever on the
test_async_connection_error_message() test.  Adding a 10 second timeout
allows the tests to continue.
2014-05-19 12:15:52 +01:00
Daniele Varrazzo
35545e7374 Skip rowcount on copy test on postgres < 8.2
It looks like the server doesn't send the message.
2014-05-13 14:34:09 +01:00
Daniele Varrazzo
81b5f1fb26 Copy operations correctly set the cursor.rowcount attribute
Fixes ticket #180.
2014-05-05 23:53:50 +01:00
Daniele Varrazzo
69605e54ec Fixed explicit connection.cursor(cursor_factory=None)
Fixes issue #210.
2014-04-30 17:57:55 +01:00
Daniele Varrazzo
1654687d1b Check the connection is really bad on exception before closing it
We end up here without a pgres sometimes (e.g. from lobject errors)
2014-04-05 16:03:06 +01:00
Daniele Varrazzo
a8fdc74090 Fixed overflow opening a lobject with an oid not fitting in a signed int
Fixes 🎫`203`.
2014-04-03 02:35:56 +01:00
Daniele Varrazzo
dfacc483b5 Dropped unneeded pass in test 2014-04-03 02:32:05 +01:00
Daniele Varrazzo
e7fc7f31b9 Fixed dsn and closed attributes in failing connection subclasses.
From ticket #192 discussion.
2014-04-03 01:42:35 +01: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
283dbccf56 Merge branch 'range_sort' 2014-02-22 23:02:19 +00:00
Daniele Varrazzo
6192a4fb17 Added str() for the Json adapter
Fixes ticket #191.
2014-02-22 20:45:35 +00:00
Chris Withers
e60266c4c5 New implementation of Range sorting that works for Python 2.5 to 3.3, at least. 2014-02-18 20:55:00 +00:00
Chris Withers
bae508ffa6 Coding style changes. 2014-02-14 07:46:32 +00:00
Chris Withers
d469c32503 Provide a stable and consistent sort order for Range objects.
This matches postgres server-side behaviour and helps client applications that need to sort based on the primary key of tables where the primary key is or contains a range.
2014-02-12 08:11:59 +00:00
Daniele Varrazzo
e11d0d39ec Check connection type in lobject init
Fixes ticket #187.
2013-11-27 12:44:28 +00:00
Daniele Varrazzo
2e3833f7fb Really test named cursors in test_scroll_named() 2013-10-16 19:10:21 +01:00
Daniele Varrazzo
1e623a951c Meaningful connection errors report a meaningful message
Fixes issue #173.
2013-10-16 17:50:10 +01:00
Daniele Varrazzo
345077d5f7 Fixed pickling of exceptions with no pgerror/pgcode set
Fixes ticket #170.
2013-07-19 16:05:59 +01:00
Daniele Varrazzo
ea08f7e7c7 Merge branch 'range_eq_typerror' 2013-06-18 14:14:01 +01:00
Daniele Varrazzo
d50ea3d82b Uniform Range eq tests style 2013-06-18 14:10:49 +01:00
Chris Withers
28276e3eb1 cater for comparison of subclasses 2013-05-26 22:20:07 +01:00
Chris Withers
b6a9e0ffaf raising an exception here rather than returning False causes problems with SQLAlchemy's internal state tracking 2013-05-26 21:58:39 +01:00
Chris Withers
8bb44f3444 more useful error message when comparing ranges with non-ranges 2013-05-26 21:20:40 +01:00
Daniele Varrazzo
1ef234ebfc Added regression test for infinity parsing in dates
...and a couple of typos.
2013-05-11 02:19:59 +01:00
Daniele Varrazzo
c796bc2cbd 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
2013-05-06 10:48:10 +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
Piotr Kasprzyk
31b6ec63f8 Fix multiple misspellings 2013-04-26 09:59:40 +01:00
Daniele Varrazzo
5d86d07618 Testing external script independent from psycopg implementation
Patch needed to run the test suite on psycopg2cffi or psycopg2ct.
2013-04-19 23:01:28 +01:00
Daniele Varrazzo
9e15f54fe8 Added cursor_factory connection attribute and connect() parameter 2013-04-07 02:30:12 +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
c63d623f65 Merge branch 'drop-py24' into devel 2013-04-05 01:29:25 +01:00
Daniele Varrazzo
736a78f3f6 Avoid encoding strdup in qstring adapter
Dropped encoding parameter in the constructor: it is used
nowhere and not documented. Use directly the connection
encoding if available, else the previous latin1 fallback.
2013-04-05 00:00:42 +01:00
Daniele Varrazzo
546927d44a Use wrap to fix names of decorated test methods
Decorators not using wrap() prevent running the test from command line, e.g.
with:

    python tests/__init__.py test_module.TestSuite.test_method
2013-03-20 23:53:20 +00:00
Daniele Varrazzo
31265e3439 Fixed broken test decorator preventing 3 tests to run 2013-03-20 23:53:19 +00:00
Daniele Varrazzo
b6873ee1ab Dropped support for Python 2.4 2013-03-20 23:40:13 +00:00
Daniele Varrazzo
09629a6dbc Use wrap to fix names of decorated test methods
Decorators not using wrap() prevent running the test from command line, e.g.
with:

    python tests/__init__.py test_module.TestSuite.test_method
2013-03-20 17:26:10 +00:00
Daniele Varrazzo
0c0e2a2455 Fixed broken test decorator preventing 3 tests to run 2013-03-20 17:13:33 +00:00
Daniele Varrazzo
73949cd1b8 Merge branch 'diagnostics' into devel 2013-03-20 01:47:14 +00:00
Daniele Varrazzo
114c62fac8 Added tests to verify the new Diagnostics properties
diag can be used on exceptions raised without cursor and is independent from
the cursor.

Docs updated to reflect the changes.
2013-03-20 00:03:58 +00:00
Daniele Varrazzo
294e7ae080 Tests tweaked to run on all the supported versions 2013-03-18 10:06:07 +00:00
Daniele Varrazzo
97311967e8 Merge branch 'diagnostics' into devel 2013-03-18 02:21:09 +00:00
Daniele Varrazzo
70b756b8c7 Added test to verify Diagnostics works after copy errors 2013-03-18 00:31:25 +00:00
Daniele Varrazzo
660386929f Added test to verify Diagnostics reference disposal 2013-03-18 00:24:46 +00:00
Daniele Varrazzo
42b063b562 Added all supported properties to the Diagnostic object 2013-03-17 23:58:10 +00:00
Matthew Woodcraft
c75a3bbab4 Work-in-progress support for retrieving PG_DIAG result error fields. 2013-03-17 16:41:15 +00:00
Daniele Varrazzo
af18c29f0b Fixed exception handling in disconnection test
OperationalError is DatabaseError's subclass.
2013-03-16 21:43:11 +00:00
Daniele Varrazzo
c5de7b5ac6 Fixed Decimal range tests 2013-03-16 17:58:58 +00:00
Daniele Varrazzo
594a4d79ec Fixed handling of database disconnection in tests in green mode 2013-03-16 17:41:59 +00:00
Daniele Varrazzo
66d6c68dcc Properly cleanup memory of broken connections
Fixed ticket #148.
2013-03-16 11:56:38 +00:00
Catalin Iacob
7abe1775d0 Fix tests for Postgres 9.3
Postgres 9.3 turns messages about implicit indexes and sequences from NOTICE
to DEBUG1 so the tests fail with a default 9.3 server configuration because
the client doesn't get any NOTICE. Fix it by also asking for DEBUG1 messages
from the server when testing against Postgres >= 9.3.
2013-03-16 00:54:11 +00:00
Daniele Varrazzo
16d96fd43c Merge branch 'py33' into devel 2012-12-22 00:58:17 +01:00
Daniele Varrazzo
6df6e6adfe Fixed pickling of DictRow objects too 2012-12-11 01:10:45 +00:00
Daniele Varrazzo
99bedd1bb2 Fixed pickling of RealDictRow objects 2012-12-10 23:54:25 +00:00
Daniele Varrazzo
e6fbf47c46 Merge branch 'contextmanager' into devel 2012-12-04 00:38:01 +00:00
Daniele Varrazzo
9a031db8b9 Fixed empty strings handling in composite caster
Closes ticket #141.
2012-12-03 14:19:09 +00:00
Daniele Varrazzo
12645db754 Make sure to call subclasses methods on context exit 2012-12-03 03:37:47 +00:00
Daniele Varrazzo
cc605032f5 Added support for with statement for connection and cursor
The implementation should be conform to the DBAPI, although the "with"
extension has not been released yet.
2012-12-03 02:50:24 +00:00
Daniele Varrazzo
1feb179fba 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
b61a2a34c4 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-06 11:58:52 +01:00
Daniele Varrazzo
4244d5953a Merge branch 'range-type' into devel 2012-09-27 00:48:05 +01:00
Daniele Varrazzo
dda24f082f Merge branch 'json' into devel 2012-09-27 00:41:04 +01:00
Daniele Varrazzo
33043cd038 Merge branch 'composite-custom' into devel 2012-09-27 00:38:00 +01:00
Daniele Varrazzo
20d3d0f66d 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
cd316a94f1 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
a3418052e9 Don't create/register a json array typecaster if no oid provided 2012-09-24 11:23:09 +01:00
Daniele Varrazzo
a858987844 Fixed search of types into schemas.
We don't need to look for stuff implicitly into pg_catalog as all
the builtin ranges are already registered. So just search into
'public' if the schema is not specified.
2012-09-24 00:49:02 +01:00
Daniele Varrazzo
a1a2772a79 Added test for range not found 2012-09-24 00:48:56 +01:00