Commit Graph

710 Commits

Author SHA1 Message Date
Federico Di Gregorio
01f8475f53
Merge branch 'master' into feature-expose-pgconn 2018-11-07 14:15:29 +01:00
Daniele Varrazzo
a83696fc50 Fixed adaptation of lists of empty lists
...somehow. Postgres doesn't support them and converts them into a
simple empty array. However this is not really our concern: the syntax
we return is valid.

Close #788
2018-10-30 01:48:51 +00:00
Daniele Varrazzo
2f24a2e22d Use class decorators to decorate all tests
Test decorators changed so that they can be applied either to a method
or to a class. Of course their double nature is implemented by a
decorator.
2018-10-30 00:23:56 +00:00
Daniele Varrazzo
8fb0f694f7 Don't barf on Composite passed to execute_values()
Close #794
2018-10-23 01:57:48 +01:00
Daniele Varrazzo
05f9e231a0 Full flake8 3.5 cleanup 2018-10-23 00:39:14 +01:00
Daniele Varrazzo
0236c68da9 Merge branch 'connection-info' 2018-10-15 01:24:00 +01:00
Daniele Varrazzo
b205764fdd Merge branch 'master' into errors-module 2018-10-15 00:58:32 +01:00
Daniele Varrazzo
e7227ce87b Added errors.lookup() function 2018-10-15 00:56:51 +01:00
Daniele Varrazzo
44bd2927c5 Use the connection.info properties instead of the legacy methods 2018-10-13 03:28:42 +01:00
Daniele Varrazzo
704e6797e7 Guard from some info functions not available in some libpq versions 2018-10-13 03:09:39 +01:00
Daniele Varrazzo
d138e42ee5 Added ConnectionInfo.parameter_status() 2018-10-13 02:40:17 +01:00
Daniele Varrazzo
9f6a3a5e96 Added ConnectionInfo.ssl_attribute() 2018-10-13 02:21:38 +01:00
Daniele Varrazzo
cb3d5f9d92 Added all the missing ConnectionInfo attributes 2018-10-13 01:36:07 +01:00
Daniele Varrazzo
439dff974d Added ConnectionInfo.error_message 2018-10-13 00:47:04 +01:00
Daniele Varrazzo
d29aa1c437 Fixed refcount in connection's readonly and deferrable getters
Close #790
2018-10-12 23:32:13 +01:00
Daniele Varrazzo
1ac6359fef Added other members to the ConnectionInfo class
Starting deprecating softly some of the methods bloating the connection
class.
2018-10-12 04:18:59 +01:00
Daniele Varrazzo
0a04c8892d Added several ConnectionInfo attributes 2018-10-12 04:18:59 +01:00
Daniele Varrazzo
0e2b516a3c Moving host attribute to a connection.info object 2018-10-11 22:42:52 +01:00
Daniele Varrazzo
f99a8de6d0 Added table_oid, table_column on cursor.description items
Close #661
2018-10-11 03:37:09 +01:00
Daniele Varrazzo
c314512115 Fixed infinite loop in pq_get_last_result after COPY
There will be an error downstream but we have to get out of this
function first.

Close #781
2018-10-10 23:57:34 +01:00
Daniele Varrazzo
9148157697 Merge branch 'master' into https 2018-10-10 22:07:33 +01:00
Daniele Varrazzo
cd9d74c462 Merge branch 'conn-get-host' 2018-10-10 22:03:36 +01:00
Daniele Varrazzo
f5f6b420b2 Merge remote-tracking branch 'origin/diag-schema-name-nonloc' 2018-10-10 21:46:51 +01:00
Federico Di Gregorio
296c80d1f2 Commented out test to avoid beaking master 2018-10-10 11:05:02 +02:00
Federico Di Gregorio
1fe9f1ac5b Fixed test for issue #788 2018-10-10 09:35:18 +02:00
Federico Di Gregorio
ebcfbe03f9 Added test for issue #788 2018-10-10 09:14:56 +02:00
Federico Di Gregorio
81addddaee Added connection.get_native_connection() 2018-10-07 13:54:24 +02:00
Marco De Paoli
1c553bb703 Added connection.host
Return the server host name of the current connect.
2018-10-06 15:19:01 +02:00
Daniele Varrazzo
4e0b2ec9c9 Added Diagnostics.severity_nonlocalized attribute
Close #783.
2018-10-04 16:13:46 +01:00
Daniele Varrazzo
4aa02b7855 sql.Identifier can wrap a sequence of strings to represent qualified names
Close #732.
2018-10-04 12:46:10 +01:00
Michel Albert
d317977205 Implement __str__ for range types 2018-09-30 10:15:55 +02:00
Jon Dufresne
b07e34e0b8 Prefer https:// URLs when available 2018-09-22 19:02:33 -07:00
Daniele Varrazzo
344ce15261 Better testing of encryption function with libpq < 10 2018-08-17 02:09:22 +01:00
Daniele Varrazzo
ce1ac3aea9 Read exceptions to raise from a Python module 2018-08-17 02:00:01 +01:00
Daniele Varrazzo
466efe4461 Bump tests for selective closure of named cursor to pg 8.2
Previous versions don't support the features as they don't have the
pg_cursors view. But they are too old to care.
2018-07-24 21:16:36 +01:00
Daniele Varrazzo
6d8f4f9f0d Close named cursor if exist, even if we didn't run execute
Close #746
2018-07-24 21:16:36 +01:00
Daniele Varrazzo
0bb7d0db48 DictCursor and RealDictCursor rows maintain columns order
Close #177.
2018-05-21 03:14:08 +01:00
Daniele Varrazzo
e8a831dda2 Merge branch 'master' into drop-2to3 2018-05-20 23:56:29 +01:00
Daniele Varrazzo
a0f7027ad5 Added tests to verify iter methods on dict cursors
ISTM the refactoring in #648 broke something
2018-05-20 23:55:18 +01:00
Daniele Varrazzo
82ae44ac3a DictCursor/RealDictCursor tests split 2018-05-20 23:35:26 +01:00
Daniele Varrazzo
9cf658ec6e Fixed refcount handling in encrypt_password
Added tests to check bad types, which discovered the above problem: on
type error we would have decref'd on exit something that was only
borrowed (because we wouldn't have performed matching increfs).
2018-05-20 21:18:36 +01:00
Daniele Varrazzo
abca14d601 Fixed keywords support for encrypt_password and tests completed 2018-05-20 20:50:04 +01:00
Daniele Varrazzo
a3063900ee Fixed code flow in encrypt_password()
Fixed several shortcomings highlighted in #576 and not fixed as
requested.

Also fixed broken behaviour of ignoring the algorithm if the connection
is missing.
2018-05-20 19:18:42 +01:00
Daniele Varrazzo
0161d54dbb Merge branch 'master' into encrypt-pass 2018-05-20 17:57:34 +01:00
Daniele Varrazzo
068b15c57f Merge branch 'fix-716' 2018-05-20 17:00:13 +01:00
Daniele Varrazzo
c4da939909 Don't raise an exception closing an unused named cursor
Close #716
2018-05-20 14:00:09 +01:00
Daniele Varrazzo
49d9edce01 Set minimal postgres version for intervalstyle test 2018-05-20 13:40:57 +01:00
Daniele Varrazzo
3f389593f5 Raise NotSupportedError fetching iso_8601 intervals
Previously it would have failed parsing and resulted in ValueError

Close #707
2018-05-20 13:22:38 +01:00
Daniele Varrazzo
098c00d73e Merge remote-tracking branch 'nested-array-nulls' 2018-05-20 12:51:13 +01:00
Daniele Varrazzo
dd7e5c906f Skipped test on db version not supporting unicode identifiers 2018-05-18 12:16:43 +01:00
Daniele Varrazzo
bc84b6233e Allow non-ascii chars in namedtuple fields
They can be valid chars in Python 3. Or maybe not? In which case Python
will throw an exception, but that's fine.

Fix regression introduced fixing #211
2018-05-18 12:15:50 +01:00
Daniele Varrazzo
8dd00ee874 Hstore test fixed after adapting arrays dropped space after commas 2018-05-18 12:11:02 +01:00
Daniele Varrazzo
b5e4a040f8 Fixed adaptation of arrays of arrays of nulls
Close #325, close #706.
2018-05-18 12:10:20 +01:00
Ashesh Vashi
1bec2bdc43
Merge branch 'master' into master 2018-05-08 15:17:59 +05:30
Daniele Varrazzo
ea923b63a4 Allow strings subclasses in ensure_bytes
Fix #679
2018-02-21 10:27:28 +00:00
Daniele Varrazzo
ddb87b7727 Convert fields names into valid Python identifiers in NamedTupleCursor
Close #211.
2018-01-29 03:30:46 +00:00
Daniele Varrazzo
76f3e196d3 Silence warning on import failing a test 2018-01-29 03:23:59 +00:00
Daniele Varrazzo
74d2c4bef9 Fixed idempotence check changing connection characteristics 2018-01-11 02:23:27 +00:00
Daniele Varrazzo
6da3e7ee69 Merge branch 'mogrify-on-closed-cursor' 2018-01-11 00:16:01 +00:00
Daniele Varrazzo
a78ac3c125 Fixed test in asian time zones
Fix #652
2018-01-10 23:58:28 +00:00
Daniele Varrazzo
e0226fc46a 'cursor.mogrify()' can be called on closed cursors
Fix #579.
2018-01-11 08:55:31 +09:00
Jon Dufresne
be3b1ba1eb In tests, use compat.py where there is overlap 2017-12-11 20:27:52 -08:00
Jon Dufresne
389f6c08d9 Avoid installing tests to site-packages
For library end users, there is no need to install tests alongside the
package itself. This keeps the tests available for development without
adding extra packages to user's site-packages directory. Reduces the
size of the installed package. Avoids accidental execution of test code
by an installed package.
2017-12-10 10:55:58 -08:00
Jon Dufresne
c86e682153 Skip register_hstore(..., unicode=True) tests on Python 3
Per the functions documentation, this argument is not supported on
Python 3. Skip it during tests.

> :param unicode: if `!True`, keys and values returned from the database
> will be `!unicode` instead of `!str`. The option is not available on
> Python 3

Work towards moving tests outside of the installed package.
2017-12-10 10:51:07 -08:00
Jon Dufresne
1a8e992fcc Use relative imports throughout tests
The tests relied on Python2 relative import semantics. Python3 changed
import semantics to always search sys.path by default. To import using a
relative path it must have a leading dot.

Forward compatible with newer Pythons.

Works towards the goal of moving tests outside of the installed package.

For more information, see PEP-328:

https://www.python.org/dev/peps/pep-0328/
2017-12-10 10:51:07 -08:00
Jon Dufresne
9de46e416e Use print() function instead of print statement throughout project
Forward compatible with newer Pythons.
2017-12-10 10:51:07 -08:00
Jon Dufresne
ef64493b89 Fix use of "async" in test_cursor.py
"async" will be a keyword starting with Python 3.7. On Python 3.6, use
of "async" causes a deprecation warning. Use the alias "async_" instead.
2017-12-10 10:49:04 -08:00
Daniele Varrazzo
2218e73c28 Merge branch 'master' into ws 2017-12-02 14:47:29 +00:00
Daniele Varrazzo
06396e5162 Merge remote-tracking branch 'jdufresne/import-unittest' 2017-12-02 12:10:26 +00:00
Daniele Varrazzo
aae5d6364f Merge remote-tracking branch 'jdufresne/leading0' 2017-12-02 12:07:57 +00:00
Daniele Varrazzo
5a3cf32fe5 Merge remote-tracking branch 'jdufresne/next-func' 2017-12-02 12:07:47 +00:00
Daniele Varrazzo
2c5cad1525 Merge remote-tracking branch 'jdufresne/more-json' 2017-12-02 12:07:06 +00:00
Jon Dufresne
699be52e8b Remove unnecessary script_to_py3; make scripts compatible instead
Part of the work towards moving tests out of the installed package.
2017-12-01 22:50:16 -08:00
Jon Dufresne
e335d6d223 Trim trailing whitespace from all files throughout project
Many editors automatically trim whitespace on save. By trimming all
 files in one go, makes future diffs cleaner without extraneous
 whitespace changes.
2017-12-01 21:42:14 -08:00
Jon Dufresne
d0c7126aa8 Remove test decorators for json module
The json module is available in all Python versions supported by
psycopg2. No need to check for its presence when executing tests.

Should have been included with d58844e548
but was missed.
2017-12-01 21:06:10 -08:00
Jon Dufresne
f5703dc3e5 Use builtin function next() throughout project
Available since Python 2.6. Use of .next() is deprecated and not
supported in Python 3. Forward compatible with modern Python.

https://docs.python.org/2/library/functions.html#next
2017-12-01 19:57:37 -08:00
Jon Dufresne
56ec575351 Drop leading 0's from numeric literals
Not compatible with Python3. Makes the code more forward compatible with
modern Pythons.

In Python2, it was an alternative syntax for octal.

$ python3
>>> 01
  File "<stdin>", line 1
    01
     ^
SyntaxError: invalid token
2017-12-01 19:00:53 -08:00
Jon Dufresne
fcc083dc12 Always import the system unittest
There is no need to import testutils.unittest instead of simply
unittest. They are simple aliases. Use system unittest to be more
regular, consistent as well as idiomatic with the wider Python
community.
2017-12-01 18:35:30 -08:00
Daniele Varrazzo
65ed5478d1 Collect rowcount in executemany even when discarding results
Closes #633.
2017-11-29 15:42:04 +00:00
Daniele Varrazzo
c3ee9cac41 Dropped unused test functions 2017-11-28 16:11:06 +00:00
Hugo
283de27098 Remove redundant parentheses 2017-11-28 16:06:52 +00:00
Hugo
7282ef0d14 Rewrite list creation as list literal 2017-11-28 16:03:23 +00:00
Hugo
955526b200 Replace comparison with None with equality operator 2017-11-28 16:03:23 +00:00
Hugo
53c1c5dcc1 Remove redundant hasattr checks 2017-11-28 16:03:23 +00:00
Hugo
ffcc65d4f0 Drop support for EOL Python 2.6 2017-11-28 16:02:12 +00:00
Jon Dufresne
4c95668c72 Remove "from __future__ import with_statement"
All versions of Python supported by psycopg2 have builtin support for
the with statement. The import is unnecessary noise.
2017-11-28 06:03:46 -08:00
Daniele Varrazzo
fc8574fdd8 Merge remote-tracking branch 'jdufresne/decimal' 2017-11-28 03:05:06 +00:00
Daniele Varrazzo
e0ce35ef72 Merge remote-tracking branch 'jdufresne/skip-before' 2017-11-28 03:04:44 +00:00
Daniele Varrazzo
db0c081d03 Merge remote-tracking branch 'jdufresne/uuid' 2017-11-28 03:04:26 +00:00
Daniele Varrazzo
a39d794308 Merge remote-tracking branch 'jdufresne/iobase' 2017-11-28 03:04:03 +00:00
Jon Dufresne
048f1bb95a Remove workaround for decimal module
The decimal module is available on all Python versions supported by
psycopg2. It has been available since Python 2.4. No need to catch an
ImportError.

https://docs.python.org/2/library/decimal.html
2017-11-26 17:55:24 -08:00
Jon Dufresne
dfc9932f27 Remove use of skip_before_python for unsupported Python versions
psycopg2 does not support Python < 2.6, remove all test guards for these
versions.
2017-11-26 16:43:18 -08:00
Jon Dufresne
582ec189cc Remove uuid workaround for older Pythons
uuid is available on all Python versions supported by psycopg2.
2017-11-26 14:46:53 -08:00
Jon Dufresne
f7d5d25651 Remove io.TextIOBase workaround for Python <= 2.5
io.TextIOBase is available on all Python versions supported by psycopg2.
Can remove all workarounds.
2017-11-26 14:32:35 -08:00
Jon Dufresne
05c28cce78 Remove workarounds for namedtuple on Python <= 2.5
namedtuple is available on all Python versions supported by psycopg2. It
was first introduced in Python 2.6. Can remove all workarounds and
special documentation.
2017-11-26 13:55:30 -08:00
Jon Dufresne
390e43fcb1 Use modern except syntax throughout project
The syntax "except Exception, exc:" is deprecated. All Python versions
supported by psycopg2 support the newer, modern syntax. Forward
compatible with future Python versions.
2017-11-20 20:00:35 -08:00
Federico Di Gregorio
5983b96c55 Don't cast point arrays to float arrays (fixes: #613) 2017-11-16 10:07:27 +01:00
Ashesh Vashi
84d405894c Moving the encrypt_password method from the connection class to the
psycopgmodule, and exported it from psycopg2.extensions as per review
comments.
2017-09-14 23:42:54 +05:30
Ashesh Vashi
6e0edf7779 Merge remote-tracking branch 'psycopg2/master' 2017-09-11 18:26:34 +05:30
Daniele Varrazzo
775de754cf Added back timestamptz[] default cast
It was registered as side effect of an excessive definition that got
cleaned up in 338dbe70a6.

Looking at other removed redundant type oids, this was the only one
missing from the `string_types` map.

Close #578.
2017-07-24 14:23:36 +01:00