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
Daniele Varrazzo
0fccc10777
Tests in order
...
Just to know where to put the next one
2011-11-18 00:10:53 +00:00
Daniele Varrazzo
417203f68e
Added test to check connect() with no parameters
2011-11-17 21:51:24 +00:00
Daniele Varrazzo
625cc1b402
Escape parameters to the connection strings as required by PQconnectdb
2011-11-17 21:51:24 +00:00
Daniele Varrazzo
99ac79511c
Added test module to verify the dsn manipulation
2011-11-17 21:51:24 +00:00
Daniele Varrazzo
dc94a3cb2d
Check for connection closed before getting the isolation level
...
Closes ticket #74
Also added test to check regressions in isolation_level,
set_isolation_level, set_session, autocommit.
2011-11-16 23:51:05 +00:00
Daniele Varrazzo
865fb2d792
Work around mxDateTime 3.2.0 segfault in tests
2011-11-01 07:42:08 +00:00
Daniele Varrazzo
6fc167a7b1
Unregister the composite array caster after the test
...
Otherwise the refcount script will report a leak.
2011-10-19 22:00:59 +01:00
Daniele Varrazzo
0f4fd0d828
Test suite fixed to make it compatible with the ctypes implementation
2011-10-19 02:25:53 +01:00
Daniele Varrazzo
d79661c87f
All unit test modules have a test_ prefix
...
Both for consistency and for test discovery.
2011-10-19 02:20:43 +01:00
Daniele Varrazzo
37a9eb3615
Test and document the named cursor stealing technique
2011-10-14 23:17:24 +01:00
Daniele Varrazzo
5fa1729000
Skip test on array of records on PG 8.3
2011-10-05 00:44:44 +01:00
Daniele Varrazzo
e4424bdfdc
Fixed tests to run with antebellum Postgres versions
2011-10-05 00:12:35 +01:00
Daniele Varrazzo
8963b8adcb
Added support for arrays of composite types
2011-09-22 19:57:42 +02:00
Daniele Varrazzo
2f9ceeac64
Added support for arrays of hstores
2011-09-22 19:56:58 +02:00
Daniele Varrazzo
c4e6d7d982
Fixed typecasting of arrays containing consecutive backslashes
2011-09-22 18:14:16 +01:00
Daniele Varrazzo
e3054ac9f3
Added new_array_type() function
...
Allows the creation of a generic array typecaster from Python.
2011-09-22 15:51:21 +01:00
Daniele Varrazzo
8fb08efae7
Allocate dynamically memory for the list of columns in COPY
...
Some bloke finds the limit of 8K too restrictive... ticket #68 .
2011-09-12 02:21:59 +01:00
Daniele Varrazzo
d67d50b434
Fixed interaction between RealDictCursor and named cursors
...
Closes ticket #67 .
2011-09-12 02:20:53 +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
a59d88c703
Merge remote-tracking branch 'piro/devel' into devel
2011-08-10 18:36:24 +02:00
Federico Di Gregorio
479bdf7458
New 'withhold' parameter for connection.cursor()
2011-08-10 18:25:46 +02:00
Daniele Varrazzo
9870ca4dce
Fixed NamedTupleCursor.executemany() (ticket #65 )
2011-08-09 11:44:30 +01:00
Federico Di Gregorio
2f6336ea78
First try at curs.withhold implementation
2011-07-05 10:28:34 +02:00
Daniele Varrazzo
d2b28abced
Method set_transaction() renamed to set_session()
...
In fact it doesn't change "the transaction", as there has to be no
transaction when invoked. The effect instead is to execute SET SESSION
CHARACTERISTICS.
2011-06-08 14:22:11 +01:00
Daniele Varrazzo
679af4a975
Fixed copyfile refcount in copy_expert
...
In case of early error, jumping to exit would have decref'd the borrowed
reference to file.
Issue spotted by Dave Malcolm, thanks!
2011-06-07 01:20:25 +01:00