Commit Graph

714 Commits

Author SHA1 Message Date
Daniele Varrazzo
7b11b95908 Skipped a couple of tests failing on old dbs
I don't even know why - worth investigating.
2017-02-06 21:40:05 +00:00
Daniele Varrazzo
7f593d5eb0 Skip tests with server not supporting NULL in array 2017-02-06 21:40:05 +00:00
Daniele Varrazzo
2e18b42db0 Don't test with server not implementing INSERT with VALUES list 2017-02-06 21:40:05 +00:00
Daniele Varrazzo
3873c6c09f Deal consistently with E'' quotes in tests 2017-02-06 21:40:05 +00:00
Daniele Varrazzo
d23fe42873 Work around a race condition in async cancel test 2017-02-06 21:40:05 +00:00
Daniele Varrazzo
e599da6308 assertDsnEqual moved as TestSuite method 2017-02-06 21:40:05 +00:00
Daniele Varrazzo
9f467231d9 Merge branch 'conform-subclass-adapter' 2017-02-05 12:13:52 +01:00
Daniele Varrazzo
c6af16c3ae Slower timeout for a test that sometimes fail
At least it should fail with an error after 2 seconds, not waiting for
Travis timeout of 10 minutes.
2017-02-05 12:06:55 +01:00
Daniele Varrazzo
3fbff5d848 Give precedence to '__conform__()' over superclasses choosing adapter
Close #456
2017-02-05 11:54:50 +01:00
Daniele Varrazzo
9054eeccc0 Set default_transaction_* GUC if session state is changed in autocomit 2017-02-04 15:19:41 +00:00
Daniele Varrazzo
665e9dc665 Exposing ISOLATION_LEVEL_DEFAULT to Python
This is now the state that is returned to Python if nothing has been
explicitly set.
2017-02-04 14:43:54 +00:00
Daniele Varrazzo
ca59fd8b3f Test looking the transactions characteristics instead of the default
So we test the effect, not the implementation. Tests pass on master too
this way, three tests fail in this branch, related to autocommit
(sort-of-obviously).
2017-02-04 10:57:30 +00:00
Daniele Varrazzo
de8b335d80 Merge branch 'master' into sql-compose 2017-02-03 04:56:02 +00:00
Daniele Varrazzo
1911b250e3 Merge branch 'async-keyword'
Close #495
2017-02-03 04:45:17 +00:00
Daniele Varrazzo
ce9be69615 Added async_ as an alias for async
Added in argument for psycopg2.connect() and connection.__init__, and
for the connection.async attribute.
2017-02-03 04:43:49 +00:00
Daniele Varrazzo
8baf6aa372 Convert warnings into errors on test 2017-02-03 04:41:32 +00:00
Daniele Varrazzo
6e89db020c Merge branch 'fast-executemany' 2017-02-03 04:40:34 +00:00
Daniele Varrazzo
dc1b4fff90 Avoid an useless encode/decode roundtrip in execute_values()
Tests moved into a separate module.
2017-02-02 17:29:17 +00:00
Daniele Varrazzo
d8b1fbd905 Further skipping of slow tests 2017-02-02 03:02:29 +00:00
Daniele Varrazzo
626e57acda Merge branch 'fast-executemany' 2017-02-02 02:40:28 +00:00
Daniele Varrazzo
88a21689ce Added note about finding slow tests 2017-02-02 02:09:59 +00:00
Daniele Varrazzo
f24de0357f Allow skipping the slow test
It's not so much about tests being slow: some just get stuck and timeout
travis.

Skipped all tests taking about more than 0.2s to run on my laptop.
Fast testing takes about 8s instead of 24.
2017-02-02 01:53:50 +00:00
Daniele Varrazzo
9bac37baf7 Fixed execute_values with unicode
Also added unicode tests.
2017-02-01 02:47:59 +00:00
Daniele Varrazzo
2e2dcd536b Fixed fast execute functions with Python 3 2017-02-01 02:36:54 +00:00
Daniele Varrazzo
a95fd3df1a Added execute_batch and execute_values functions 2017-02-01 01:59:47 +00:00
Daniele Varrazzo
a8a3a298f8 Autonumbered args not available in Python 2.6 2017-01-03 17:53:02 +01:00
Daniele Varrazzo
71a168797c Several improvements to the sql objects
Comparable, iterable, content accessible
2017-01-03 17:27:01 +01:00
Daniele Varrazzo
a76e665567 Use {} instead of %s placeholders in SQL composition 2017-01-03 15:02:34 +01:00
Daniele Varrazzo
cf40bff2e2 Dropped sql.compose
Use a SQL % operator instead.
2017-01-01 08:39:02 +01:00
Daniele Varrazzo
4a55b8018a Adding sql module documentation 2017-01-01 08:12:05 +01:00
Daniele Varrazzo
41b9bfe401 Added test for sql percents treatment 2017-01-01 06:37:09 +01:00
Daniele Varrazzo
828415d476 Typo: composible -> composable 2017-01-01 06:32:18 +01:00
Daniele Varrazzo
ad2643266f Fixed sql.compose with no args and added tests 2017-01-01 06:26:54 +01:00
Daniele Varrazzo
8c020ca47a Fixed sql.Composed representation 2017-01-01 06:26:42 +01:00
Daniele Varrazzo
600416aafc Fixed sql stuff in Py3 2017-01-01 05:59:21 +01:00
Daniele Varrazzo
f11e6d82b0 Added basic sql module implementation 2017-01-01 05:23:15 +01:00
Daniele Varrazzo
fad5100079 Adding some boilerplate for the new module 2017-01-01 03:53:08 +01:00
Daniele Varrazzo
faaef61c27 Merge branch 'master' into named-callproc 2016-12-26 01:49:42 +01:00
Daniele Varrazzo
c22093ddd4 Skip replication tests in green mode 2016-12-25 19:00:30 +01:00
Daniele Varrazzo
b73115ac41 Added test to verify bug #482 2016-12-25 18:30:27 +01:00
Daniele Varrazzo
a478ba9a47 Fixed tests failing on Python 2.6 2016-12-24 01:03:57 +01:00
Daniele Varrazzo
643ba70bad Added ipaddress objects conversion
Close #387
2016-10-11 04:54:41 +01:00
Daniele Varrazzo
706ad2f177 Conver network array types into array of strings by default 2016-10-11 02:31:45 +01:00
Daniele Varrazzo
05627ac0f9 Fix unicode mogrify test on python 2 2016-10-11 00:22:23 +01:00
Daniele Varrazzo
91d2158de7 Python source cleanup using flake8 2016-10-11 00:11:55 +01:00
Daniele Varrazzo
78649f8e90 Dropped use of b() "macro" and 2to3 fixer
Just use the b"" strings syntax supported from python 2.6.
2016-08-15 01:56:36 +01:00
Daniele Varrazzo
1d950748af Merge branch 'replication-protocol' 2016-08-14 21:09:54 +01:00
Daniele Varrazzo
bd95269c69 Merge branch 'master' into nul-terminator 2016-08-07 02:49:13 +01:00
Jonathan Ross Rogers
cde19c4d59 Make Range pickleable 2016-08-07 02:38:52 +01:00
Daniele Varrazzo
2a4d6027a4 Merge branch 'master' into replication-protocol
Conflicts:
	tests/testconfig.py
2016-08-07 01:53:21 +01:00
Alexander Schrijver
03824a1dba Throw an exception when a NUL character is used as a parameter. 2016-07-18 22:56:55 +02:00
Daniele Varrazzo
7566af145b Merge branch 'conn-get-parameters' 2016-07-01 20:12:01 +01:00
Daniele Varrazzo
5bcaf11f9d Allow adapting bytes using QuotedString on Python 3 too
Close #365.
2016-07-01 19:14:00 +01:00
Daniele Varrazzo
70af49c0a2 Fixed encoding tests on Py3 2016-07-01 18:50:24 +01:00
Daniele Varrazzo
4a450b63c4 Don't hope to encode stuff in an arbitrary encoding
libpq's PQescapeString will use the same encoding it has seen before in
a connection (static_client_encoding).

So I think I'll leave this feature here for people who know what is
doing, but won't really document it as a feature: it can't really work
in a generic way (unless adding some disgusting hack like creating a
fake connection with the encoding we want to call PQescapeStringConn
instead of PQescapeString).
2016-07-01 18:02:20 +01:00
Daniele Varrazzo
2e8e61b8d4 Test moved to the right module, cleanup, but same problem 2016-07-01 18:01:16 +01:00
Daniele Varrazzo
bada1f1f8e Work in progress on writable encoding
Would help using adapt(unicode) to quote strings without a connection,
see ticket #331.

Currently in heisenbug state: if test_connection_wins_anyway and
test_encoding_default run (in this order), the latter fail because the
returned value is "'\xe8 '", with an extra space. Skipping the first
test, the second succeed.

The bad value is returned by the libpq:

    ql = PQescapeString(to+eq+1, from, len);

just returns len = 2 and an extra space in the string... meh.
2016-07-01 18:00:05 +01:00
Greg Ward
3ed2c54790 Fix scattered grammar/spelling errors in comments, debug output, etc. 2016-06-30 21:09:15 +01:00
Daniele Varrazzo
eb687103b4 Skip null array test on Postgres versions not supporting it 2016-03-10 12:04:41 +00:00
Oleksandr Shulgin
a7887fab07 Merge remote-tracking branch 'zalando/feature/replication-protocol' into feature/replication-protocol-c-connection-object 2016-03-08 18:56:58 +01:00
Oleksandr Shulgin
da6e061ee8 Use python-defined make_dsn() for ReplicationConnection class 2016-03-08 18:52:21 +01:00
Oleksandr Shulgin
cb7032554e Merge branch 'master' into feature/replication-protocol-c-connection-object 2016-03-04 10:52:10 +01:00
Daniele Varrazzo
c9fd828f8a Allow make_dsn to take no parameter
The behaviour of connect() is unchanged: either dsn or params must be
specified.
2016-03-03 17:09:15 +00:00
Daniele Varrazzo
7aab934ae5 Validate output result from make_dsn()
The output is not necessarily munged anyway: if no keyword is passed,
validate the input but return it untouched.
2016-03-03 17:09:15 +00:00
Daniele Varrazzo
7155d06cdc Test that the empty dsn is a valid make_dsn input 2016-03-03 17:09:15 +00:00
Daniele Varrazzo
52087a79d9 Added test suite specific for make_dsn 2016-03-03 15:31:37 +00:00
Daniele Varrazzo
2c55a1bd53 Verify that the dsn is not manipulated by make_dsn if not necessary 2016-03-03 15:07:38 +00:00
Daniele Varrazzo
1c4523f0ac Implementation of make_dsn in Python
This is equivalent to what proposed in #363, but with a much simpler
implementation.
2016-03-03 04:33:59 +00:00
Oleksandr Shulgin
5d33b39829 Fix error test for invalid START_REPLICATION command. 2016-01-21 15:56:27 +01:00
Oleksandr Shulgin
09a4bb70a1 Allow retrying start_replication after syntax or data error. 2016-01-05 12:31:57 +01:00
Daniele Varrazzo
5fd0f6c4ee Fixed race condition on import in errorcodes.lookup
Fixes #382.
2015-12-16 12:03:10 +00:00
Daniele Varrazzo
7302f348bc Added test with objects without length as callproc param 2015-12-12 17:51:08 -05:00
Daniele Varrazzo
d297976d6d Raise TypeError if the dict in callproc param contains non-strings
Check-and-conversion chain fixed and simplified. 'spname' was a
reference leak.
2015-12-12 17:51:08 -05:00
mrmilosz
c205f140a0 callproc: tests, docs, and comment/error-reporting touchups. 2015-12-12 17:49:59 -05:00
Oleksandr Shulgin
051e6d1364 Add skip_before_libpq for test_get_dsn_parameters 2015-10-30 13:02:45 +01:00
Oleksandr Shulgin
602fefcae3 Fix typo in a new test name 2015-10-30 11:38:28 +01:00
Oleksandr Shulgin
a4cbb088fe Add connection.get_dsn_parameters() 2015-10-30 11:10:41 +01:00
Oleksandr Shulgin
fbcf99ad07 Move replication connection to C level. 2015-10-27 18:21:24 +01:00
Oleksandr Shulgin
433fb957cb Merge branch 'feature/connect2' into feature/replication-protocol 2015-10-27 17:37:18 +01:00
Oleksandr Shulgin
7aba8b3ed0 Rework psycopg2.connect() interface. 2015-10-27 17:35:57 +01:00
Oleksandr Shulgin
8b79bf43ac Drop ReplicationCursor.flush_feedback(), rectify pq_*_replication_*() interface. 2015-10-23 18:30:18 +02:00
Oleksandr Shulgin
22cbfb26d6 Actually add replication tests to the test suite. 2015-10-20 13:05:43 +02:00
Oleksandr Shulgin
0bb81fc848 Properly subclass ReplicationCursor on C level. 2015-10-19 20:00:39 +02:00
Oleksandr Shulgin
7aea2cef6e Improve async replication test. 2015-10-19 17:02:18 +02:00
Oleksandr Shulgin
4ab7cf0157 Replace stop_replication with requirement for an exception. 2015-10-19 15:42:42 +02:00
Oleksandr Shulgin
0435320f34 Fix PSYCOPG2_TEST_REPL_DSN handling. 2015-10-16 16:36:03 +02:00
Oleksandr Shulgin
cf4f2411bf Fix async replication and test. 2015-10-15 18:01:43 +02:00
Oleksandr Shulgin
d14fea31a3 Use quote_ident from psycopg2.extensions 2015-10-15 12:56:21 +02:00
Oleksandr Shulgin
8e518d4954 Merge branch 'master' into feature/replication-protocol 2015-10-15 12:27:43 +02:00
Oleksandr Shulgin
89bb6b0711 Proper unicode handling in quote_ident. 2015-10-15 11:52:18 +02:00
Oleksandr Shulgin
9295bce154 Add psycopg2.extensions.quote_ident. 2015-10-14 17:00:25 +02:00
Oleksandr Shulgin
a0b42a12ff Update stop_repl, require replication consumer to be a callable. 2015-10-14 15:15:07 +02:00
Oleksandr Shulgin
fea2260fc5 Fix stop_replication: always raise outside the loop. 2015-10-14 12:50:08 +02:00
Oleksandr Shulgin
54079072db Fix ReplicationTest: no NotSupportedError now. 2015-10-14 12:43:26 +02:00
Daniele Varrazzo
7e94ce1f14 Drop spurious notices in test
Getting some "rehashing catalog" debug messages in PG 9.4
2015-10-01 13:31:13 +01:00
Daniele Varrazzo
5afeee3613 Added unicode support to parse_dsn
Also added support for the argument as a keyword.
2015-10-01 13:20:11 +01:00
Daniele Varrazzo
71d96293ab Fixed parse_dsn tests on Python 3
On Python 3 there is no Exception.message attribute.
2015-10-01 12:03:00 +01:00
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
Daniele Varrazzo
a701e36d16 Added containment tests for unbounded intervals 2012-09-23 22:59:49 +01:00
Daniele Varrazzo
841ddaba87 Range objects cannot be ordered 2012-09-23 22:54:50 +01:00
Daniele Varrazzo
25ef540aa3 Range objects are nonzero when not empty 2012-09-23 22:43:23 +01:00
Daniele Varrazzo
a96a4349ed Range objects are immutable and hashable 2012-09-23 22:40:13 +01:00
Daniele Varrazzo
d2cee6f9ad Added in operator for ranges 2012-09-23 22:01:39 +01:00
Daniele Varrazzo
94c6353d55 NumberRange renamed to NumericRange
I was avoiding Numeric to avoid conflicting with the 'numeric'
Postgres type, which is an alias for 'decimal'. But now that there
is a single numeric range I can use the preferred name
2012-09-23 21:11:06 +01:00
Daniele Varrazzo
45cbcc0713 Dropped Range classes for specific numeric types 2012-09-23 21:08:18 +01:00
Daniele Varrazzo
5e7c1d0b51 Added first implementation of Range type, adapter, typecaster 2012-09-23 21:03:36 +01:00
Daniele Varrazzo
9949e04c70 Added schema attribute to CompositeCaster 2012-09-22 15:10:40 +01:00
Daniele Varrazzo
1b2c2c34b6 Make CompositeCaster easier to subclass 2012-09-22 01:46:53 +01:00
Daniele Varrazzo
469b6f8aff Return memoryview object of type "c" instead of "B" from bytea
In Python 3.3 items are returned as int instead of chars.
I'm not sure the way I did it is correct: worth asking some
hardcore Python dev.

Fixed tests after the stricter memview comparison rules in Py 3.3.
2012-09-21 00:54:37 +01:00
Daniele Varrazzo
abe2df5f57 Merge branch 'fix-array-parsing' into devel 2012-09-20 03:26:07 +01:00
Daniele Varrazzo
62a54f64f7 Fixed infinite loop when parsing '{' as array 2012-09-20 03:24:47 +01:00
Daniele Varrazzo
0e644f6d95 Fixed return value after malformed arrays 2012-09-20 03:24:26 +01:00
Daniele Varrazzo
9b2ad7abb5 Fixed json typecaster with NULL input 2012-09-20 00:39:34 +01:00
Daniele Varrazzo
7386b8327c Dropped keywords passthrough in Json adapter
Pass a dumps function instead. Allow customizing by either arg passing or
subclassing.

The basic Json class now raises ImportError on getquoted() if json is not
available, thus allowing using a customized Json subclass even when the json
module is not available.
2012-09-19 16:32:57 +01:00
Daniele Varrazzo
d963b478e2 Added register_default_json() function
Register a typecaster for PostgreSQL 9.2 json.
2012-09-19 15:49:00 +01:00
Daniele Varrazzo
26d71b4cba First parameter of register_json defaults to None 2012-09-19 15:31:28 +01:00
Daniele Varrazzo
024f0dbada Added json typecaster 2012-09-19 04:26:35 +01:00
Daniele Varrazzo
b8e7f02256 Added Json adapter 2012-09-19 04:12:20 +01:00
Daniele Varrazzo
5fedaa5474 Fixed tests to run with PG 8.3 2012-09-04 21:23:19 +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
91c2ff9296 Fixed tpc_recover() with RealDictStuff
Same problem and correction of ticket #114.
2012-08-14 23:29:19 +01:00
Daniele Varrazzo
21d323d2c8 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
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