]> git.ipfire.org Git - thirdparty/psycopg.git/log
thirdparty/psycopg.git
4 years agoFixed comments in tests
Daniele Varrazzo [Mon, 9 Nov 2020 01:46:54 +0000 (01:46 +0000)] 
Fixed comments in tests

4 years agoUse pytest tmpdir fixture
Daniele Varrazzo [Mon, 9 Nov 2020 01:16:44 +0000 (01:16 +0000)] 
Use pytest tmpdir fixture

4 years agoAsyncConnection.cursor() made async
Daniele Varrazzo [Sun, 8 Nov 2020 23:17:26 +0000 (23:17 +0000)] 
AsyncConnection.cursor() made async

4 years agoDropped excessive use of is [not] None
Daniele Varrazzo [Sat, 7 Nov 2020 02:24:09 +0000 (02:24 +0000)] 
Dropped excessive use of is [not] None

It was done with the assumption that it is faster, but it is only in
C/Cython, not in pure Python.

4 years agoDropped local variable micro-optimization
Daniele Varrazzo [Sat, 7 Nov 2020 01:58:06 +0000 (01:58 +0000)] 
Dropped local variable micro-optimization

A long time ago it was a thing. timeit shows it isn't anymore.

4 years agoAdded TypeInfo representation
Daniele Varrazzo [Fri, 6 Nov 2020 23:52:45 +0000 (23:52 +0000)] 
Added TypeInfo representation

4 years agoAdded int subtypes to cast to specific sizes
Daniele Varrazzo [Fri, 6 Nov 2020 23:51:43 +0000 (23:51 +0000)] 
Added int subtypes to cast to specific sizes

4 years agoUse oid 0 for unknown typed and string casting
Daniele Varrazzo [Thu, 5 Nov 2020 14:40:17 +0000 (15:40 +0100)] 
Use oid 0 for unknown typed and string casting

Using unknown (0) oid instead of text (25) works better to throw normal
strings at typed targets (e.g. columns) and expect them to work, a
behaviour similar to client-side binding. However Postgres < 10 refuse
to emit columns with unknown oid.

4 years agoDropped dumper param of Dumper.register
Daniele Varrazzo [Wed, 4 Nov 2020 17:22:49 +0000 (18:22 +0100)] 
Dropped dumper param of Dumper.register

Just use `cls`, as the class method is available to all the subclasses.

4 years agoAdded network types
Daniele Varrazzo [Wed, 4 Nov 2020 17:08:34 +0000 (18:08 +0100)] 
Added network types

4 years agoFast codec functions moved to an utility module
Daniele Varrazzo [Wed, 4 Nov 2020 14:15:40 +0000 (15:15 +0100)] 
Fast codec functions moved to an utility module

4 years agoText dumping raises DataError if it contains a NUL byte
Daniele Varrazzo [Wed, 4 Nov 2020 01:17:44 +0000 (02:17 +0100)] 
Text dumping raises DataError if it contains a NUL byte

Note that psycopg2 was raising ValueError, but DataError is more
appropriate. If the param is binary, Postgres will raise
.CharacterNotInRepertoire, which is a DataError subclass.

4 years agoCallproc can take both args and kwargs
Daniele Varrazzo [Wed, 4 Nov 2020 01:17:27 +0000 (02:17 +0100)] 
Callproc can take both args and kwargs

4 years agosql.Composible subclasses super c'tor before raise an exception in init
Daniele Varrazzo [Fri, 30 Oct 2020 14:23:30 +0000 (15:23 +0100)] 
sql.Composible subclasses super c'tor before raise an exception in init

If an exception is raised a test framework may raise an exception on
repr.

4 years agoAdded cursor.callproc()
Daniele Varrazzo [Fri, 30 Oct 2020 14:23:14 +0000 (15:23 +0100)] 
Added cursor.callproc()

4 years agoCursor is iterable
Daniele Varrazzo [Fri, 30 Oct 2020 02:21:29 +0000 (03:21 +0100)] 
Cursor is iterable

4 years agoUsing type Iterator instead of Generator when possible
Daniele Varrazzo [Fri, 30 Oct 2020 02:13:38 +0000 (03:13 +0100)] 
Using type Iterator instead of Generator when possible

4 years agoAdded columns attributes
Daniele Varrazzo [Fri, 30 Oct 2020 01:57:24 +0000 (02:57 +0100)] 
Added columns attributes

4 years agooids module moved from psycopg3.types to psycog3 package
Daniele Varrazzo [Fri, 30 Oct 2020 01:55:43 +0000 (02:55 +0100)] 
oids module moved from psycopg3.types to psycog3 package

Importing it from types caused too many side effects.

4 years agoAdded UUID type load/dump
Daniele Varrazzo [Thu, 29 Oct 2020 22:02:45 +0000 (23:02 +0100)] 
Added UUID type load/dump

4 years agoUse static attributes to declare dumpers oid where possible
Daniele Varrazzo [Thu, 29 Oct 2020 21:00:02 +0000 (22:00 +0100)] 
Use static attributes to declare dumpers oid where possible

4 years agoDropped type guards for dumpers/loaders registration
Daniele Varrazzo [Thu, 29 Oct 2020 17:58:22 +0000 (18:58 +0100)] 
Dropped type guards for dumpers/loaders registration

Awkward to maintain and badly defined. Let the ducks quack.

4 years agoMore uniform loader/dumper names
Daniele Varrazzo [Thu, 29 Oct 2020 15:39:57 +0000 (16:39 +0100)] 
More uniform loader/dumper names

4 years agoAdded test to make sure binary minus in client-side binding works ok
Daniele Varrazzo [Thu, 29 Oct 2020 14:08:37 +0000 (15:08 +0100)] 
Added test to make sure binary minus in client-side binding works ok

4 years agoFixed tests with PostgreSQL 9.6 and previous
Daniele Varrazzo [Thu, 29 Oct 2020 14:06:19 +0000 (15:06 +0100)] 
Fixed tests with PostgreSQL 9.6 and previous

Such database version doesn't allow to emit unknown oid literals.
However specifying a different type for unknown, such as text, will fail
as soon as the value is used in a typed context, which is a far more
useful use case.

4 years agoFix test when a db name is not set
Daniele Varrazzo [Thu, 29 Oct 2020 14:05:40 +0000 (15:05 +0100)] 
Fix test when a db name is not set

4 years agoDropped duplicate tests
Daniele Varrazzo [Thu, 29 Oct 2020 13:54:59 +0000 (14:54 +0100)] 
Dropped duplicate tests

4 years agoDropped loader param of Loader.register
Daniele Varrazzo [Thu, 29 Oct 2020 03:22:23 +0000 (04:22 +0100)] 
Dropped loader param of Loader.register

Just use `cls`, as the class method is available to all the subclasses.

4 years agoFixed rowcount with DML queries, multiple results, executemany
Daniele Varrazzo [Thu, 29 Oct 2020 00:51:03 +0000 (01:51 +0100)] 
Fixed rowcount with DML queries, multiple results, executemany

4 years agoUse unknown oid passing NULL to queries
Daniele Varrazzo [Wed, 28 Oct 2020 23:29:41 +0000 (00:29 +0100)] 
Use unknown oid passing NULL to queries

Passing text makes for a cast rejected by fields with a stricter cast.

4 years agoDiagnostic objects can be pickled and error info survive pickling
Daniele Varrazzo [Wed, 28 Oct 2020 20:46:52 +0000 (21:46 +0100)] 
Diagnostic objects can be pickled and error info survive pickling

4 years agoErrors can be pickled
Daniele Varrazzo [Wed, 28 Oct 2020 19:26:01 +0000 (20:26 +0100)] 
Errors can be pickled

4 years agoRaise InterfaceError on operation on closed objects
Daniele Varrazzo [Wed, 28 Oct 2020 16:45:03 +0000 (17:45 +0100)] 
Raise InterfaceError on operation on closed objects

4 years agoAdded cursors context managers
Daniele Varrazzo [Wed, 28 Oct 2020 16:33:44 +0000 (17:33 +0100)] 
Added cursors context managers

4 years agoMerge branch 'sql-module'
Daniele Varrazzo [Wed, 28 Oct 2020 21:04:31 +0000 (22:04 +0100)] 
Merge branch 'sql-module'

4 years agoMore idiomatic python3 super()
Daniele Varrazzo [Wed, 28 Oct 2020 19:29:51 +0000 (20:29 +0100)] 
More idiomatic python3 super()

4 years agoAdded Dumper.quote()
Daniele Varrazzo [Wed, 28 Oct 2020 15:42:25 +0000 (16:42 +0100)] 
Added Dumper.quote()

Return a representation of the object in a format useful for embedding
in SQL. For most objects this is only the representation in quotes and
escaped, for some it's a different value (numbers, bools, NULL).

None can be quoted but not dumped, so it can be passed to an
sql.Literal() without the need of a special case.

4 years agosql.Placeholder can represent binary placeholders
Daniele Varrazzo [Wed, 28 Oct 2020 12:00:35 +0000 (13:00 +0100)] 
sql.Placeholder can represent binary placeholders

4 years agoMove conversion of Composible to query string into PostgresQuery
Daniele Varrazzo [Wed, 28 Oct 2020 11:38:59 +0000 (12:38 +0100)] 
Move conversion of Composible to query string into PostgresQuery

4 years agoAdded sql adaptation from None to NULL
Daniele Varrazzo [Wed, 28 Oct 2020 03:14:42 +0000 (04:14 +0100)] 
Added sql adaptation from None to NULL

This is a special case now, because None is no more a value to adapt, as
it's not passed to PQexecParams like other values are.

4 years agoAdded psycopg3.sql module
Daniele Varrazzo [Wed, 28 Oct 2020 03:01:48 +0000 (04:01 +0100)] 
Added psycopg3.sql module

A straight porting from psycopg2, with the addition of an utility
`quote()` function to provide a simple entry point to solve the problem
"adapt this object here".

4 years agoMerge branch 'date-adapt'
Daniele Varrazzo [Wed, 28 Oct 2020 03:20:47 +0000 (04:20 +0100)] 
Merge branch 'date-adapt'

4 years agoWork around the mypy method assignment false positive without `ignore`
Daniele Varrazzo [Tue, 27 Oct 2020 19:08:10 +0000 (20:08 +0100)] 
Work around the mypy method assignment false positive without `ignore`

`ignore` in unused branches triggers https://github.com/python/mypy/issues/8823
so use `setattr()` to avoid https://github.com/python/mypy/issues/2427.

4 years agoForce type checking with Python 3.8
Daniele Varrazzo [Tue, 27 Oct 2020 18:17:25 +0000 (19:17 +0100)] 
Force type checking with Python 3.8

Aligning Travis with my current dev environment to avoid cases where
it's not possible to type-check consistently with different Python
versions.

See https://github.com/python/mypy/issues/9652

4 years agoUse local functions for encode/decode in date adaptation
Daniele Varrazzo [Tue, 27 Oct 2020 15:31:13 +0000 (16:31 +0100)] 
Use local functions for encode/decode in date adaptation

4 years agoFixed timezone parsing on Python 3.6
Daniele Varrazzo [Tue, 27 Oct 2020 13:43:37 +0000 (14:43 +0100)] 
Fixed timezone parsing on Python 3.6

4 years agoAdded interval loading
Daniele Varrazzo [Tue, 27 Oct 2020 03:10:36 +0000 (04:10 +0100)] 
Added interval loading

4 years agoAdded timedelta dump
Daniele Varrazzo [Tue, 27 Oct 2020 01:40:29 +0000 (02:40 +0100)] 
Added timedelta dump

4 years agoAdded time with timezone loader
Daniele Varrazzo [Tue, 27 Oct 2020 00:27:54 +0000 (01:27 +0100)] 
Added time with timezone loader

4 years agoRaise DataError for dates and times that can't be represented
Daniele Varrazzo [Mon, 26 Oct 2020 23:15:03 +0000 (00:15 +0100)] 
Raise DataError for dates and times that can't be represented

4 years agoAdded time load/dump, and tests refactoring
Daniele Varrazzo [Mon, 26 Oct 2020 22:32:43 +0000 (23:32 +0100)] 
Added time load/dump, and tests refactoring

4 years agoAdded timestamptz loader
Daniele Varrazzo [Mon, 26 Oct 2020 15:32:14 +0000 (16:32 +0100)] 
Added timestamptz loader

Won't deal with formats other than ISO because they return the timezone
name and that requires interpretation by the client, using a tz library
such as pytz or Python 3.9

4 years agoMore compact date/time tests
Daniele Varrazzo [Sun, 18 Oct 2020 19:42:21 +0000 (20:42 +0100)] 
More compact date/time tests

4 years agoAdded timestamp text loading
Daniele Varrazzo [Sun, 18 Oct 2020 16:06:00 +0000 (17:06 +0100)] 
Added timestamp text loading

4 years agoAdded datetime dump
Daniele Varrazzo [Sun, 6 Sep 2020 11:50:12 +0000 (12:50 +0100)] 
Added datetime dump

4 years agoRaise a polite exception for dates >= Y10K
Daniele Varrazzo [Sun, 23 Aug 2020 20:41:15 +0000 (21:41 +0100)] 
Raise a polite exception for dates >= Y10K

4 years agoRaise a polite exception for BC dates
Daniele Varrazzo [Sun, 23 Aug 2020 20:13:34 +0000 (21:13 +0100)] 
Raise a polite exception for BC dates

4 years agoAdded date text loader
Daniele Varrazzo [Sun, 23 Aug 2020 18:20:53 +0000 (19:20 +0100)] 
Added date text loader

THe loader can already deal with all the Postgres DateStyle

4 years agoAdded date text dumper
Daniele Varrazzo [Sun, 23 Aug 2020 17:23:23 +0000 (18:23 +0100)] 
Added date text dumper

4 years agoMerge branch 'json-adapt'
Daniele Varrazzo [Wed, 28 Oct 2020 03:17:47 +0000 (04:17 +0100)] 
Merge branch 'json-adapt'

4 years agoAdded JSON loaders
Daniele Varrazzo [Tue, 27 Oct 2020 18:47:05 +0000 (19:47 +0100)] 
Added JSON loaders

4 years agoAdded tests to verify json dump customisation
Daniele Varrazzo [Tue, 27 Oct 2020 17:35:13 +0000 (18:35 +0100)] 
Added tests to verify json dump customisation

4 years agoAdded json binary dumpers
Daniele Varrazzo [Tue, 27 Oct 2020 16:17:21 +0000 (17:17 +0100)] 
Added json binary dumpers

4 years agoAdded json text dump
Daniele Varrazzo [Tue, 27 Oct 2020 16:09:08 +0000 (17:09 +0100)] 
Added json text dump

4 years agoAdded missing methods to psycopg3.pq.Escaping proto
Daniele Varrazzo [Wed, 28 Oct 2020 00:45:45 +0000 (01:45 +0100)] 
Added missing methods to psycopg3.pq.Escaping proto

4 years ago'psycopg3.transform' module made private
Daniele Varrazzo [Wed, 28 Oct 2020 00:11:39 +0000 (01:11 +0100)] 
'psycopg3.transform' module made private

It's too easy to import psycopg3.transform.Transformer when instead
the C module is the one enabled. This will make some isinstance fail,
and e.g. _connecion_from_context would throw a TypeError.

4 years agoAdded PQescapeString wrapper
Daniele Varrazzo [Tue, 27 Oct 2020 23:32:07 +0000 (00:32 +0100)] 
Added PQescapeString wrapper

`psycopg3.pq.Escaping.escape_string()` can now work without a connection
too, with the limitation explained in the libpq docs.

Also fixed memory leak. Oops.

4 years agoSubclasses of dumpable objects are dumpable too
Daniele Varrazzo [Tue, 27 Oct 2020 17:30:50 +0000 (18:30 +0100)] 
Subclasses of dumpable objects are dumpable too

4 years agoFixed test run on non-local server
Daniele Varrazzo [Tue, 27 Oct 2020 13:44:19 +0000 (14:44 +0100)] 
Fixed test run on non-local server

4 years agoFixed hacking instruction, again
Daniele Varrazzo [Tue, 27 Oct 2020 13:43:56 +0000 (14:43 +0100)] 
Fixed hacking instruction, again

4 years agoAllow multiple commands in _exec_command()
Daniel Fortunov [Thu, 6 Aug 2020 23:09:30 +0000 (00:09 +0100)] 
Allow multiple commands in _exec_command()

4 years agoconnection: Move lock acquisition out of _exec_commit_rollback()
Daniel Fortunov [Sat, 25 Jul 2020 11:36:47 +0000 (12:36 +0100)] 
connection: Move lock acquisition out of _exec_commit_rollback()

4 years agoFixed hacking instructions in readme
Daniele Varrazzo [Mon, 26 Oct 2020 16:40:45 +0000 (17:40 +0100)] 
Fixed hacking instructions in readme

4 years agoConnection encoding renamed to client_encoding
Daniele Varrazzo [Sat, 25 Jul 2020 18:18:15 +0000 (19:18 +0100)] 
Connection encoding renamed to client_encoding

More precise and consistent with set_client_encoding()

4 years agoConnection.encoding made writable again
Daniele Varrazzo [Sat, 25 Jul 2020 11:17:51 +0000 (12:17 +0100)] 
Connection.encoding made writable again

I'm so flipflopping on this...

4 years agoSetting autocommit made thread safe
Daniele Varrazzo [Sat, 25 Jul 2020 10:52:07 +0000 (11:52 +0100)] 
Setting autocommit made thread safe

Using a setter on sync connections, a function on async connections.
Should review why this approach was abandoned for the client encoding,
because it seems working alright.

4 years agotest_ssl_in_use(): Adapt for Windows
Daniel Fortunov [Sun, 19 Jul 2020 23:22:37 +0000 (00:22 +0100)] 
test_ssl_in_use(): Adapt for Windows

4 years agoTrailing comma dropped from where black would reformat
Daniele Varrazzo [Fri, 16 Oct 2020 14:37:05 +0000 (15:37 +0100)] 
Trailing comma dropped from where black would reformat

The changes are detected by black 20.8b1

4 years agoFixed dev mode readme instructions
Daniele Varrazzo [Fri, 16 Oct 2020 14:05:32 +0000 (15:05 +0100)] 
Fixed dev mode readme instructions

4 years agoMerge branch 'simplify-adapt'
Daniele Varrazzo [Sun, 23 Aug 2020 18:24:08 +0000 (19:24 +0100)] 
Merge branch 'simplify-adapt'

4 years agoTransformer._lookup_dumper/loader dropped altogether
Daniele Varrazzo [Fri, 7 Aug 2020 03:14:33 +0000 (04:14 +0100)] 
Transformer._lookup_dumper/loader dropped altogether

4 years agoTransformer.lookup_loader/dumper dropped from interface
Daniele Varrazzo [Fri, 7 Aug 2020 03:00:48 +0000 (04:00 +0100)] 
Transformer.lookup_loader/dumper dropped from interface

4 years agoDropped Transformer.get_load_function
Daniele Varrazzo [Fri, 7 Aug 2020 02:58:52 +0000 (03:58 +0100)] 
Dropped Transformer.get_load_function

4 years agoDropped Transformer.load()
Daniele Varrazzo [Fri, 7 Aug 2020 02:49:20 +0000 (03:49 +0100)] 
Dropped Transformer.load()

4 years agoPyxLoader renamed to CLoader
Daniele Varrazzo [Fri, 7 Aug 2020 02:43:21 +0000 (03:43 +0100)] 
PyxLoader renamed to CLoader

4 years agoAll C loaders converted to the PyxLoader class
Daniele Varrazzo [Fri, 7 Aug 2020 02:38:26 +0000 (03:38 +0100)] 
All C loaders converted to the PyxLoader class

4 years agoUse a C fast path to use the Loader.cload where available
Daniele Varrazzo [Fri, 7 Aug 2020 01:52:14 +0000 (02:52 +0100)] 
Use a C fast path to use the Loader.cload where available

4 years agoDropped unused Transform._oids
Daniele Varrazzo [Fri, 7 Aug 2020 01:20:57 +0000 (02:20 +0100)] 
Dropped unused Transform._oids

4 years agoAdded guard to avoid importing psycog3_c without psycopg3
Daniele Varrazzo [Fri, 7 Aug 2020 00:52:23 +0000 (01:52 +0100)] 
Added guard to avoid importing psycog3_c without psycopg3

Doing so result in mysterious import error.

4 years agoAllow overriding of Py loaders by C loaders
Daniele Varrazzo [Fri, 7 Aug 2020 00:51:29 +0000 (01:51 +0100)] 
Allow overriding of Py loaders by C loaders

Only registering our toy bytea loader for the moment, other will follow
a similar pattern.

4 years agoCreating a Cython Loader with the same interface as Python
Daniele Varrazzo [Thu, 6 Aug 2020 21:22:52 +0000 (22:22 +0100)] 
Creating a Cython Loader with the same interface as Python

Added C implementation of the BinaryByteaLoader to test the interface

4 years agoDropped support for loader functions
Daniele Varrazzo [Thu, 6 Aug 2020 18:52:44 +0000 (19:52 +0100)] 
Dropped support for loader functions

4 years agoAll loader functions converted to classes
Daniele Varrazzo [Thu, 6 Aug 2020 18:41:34 +0000 (19:41 +0100)] 
All loader functions converted to classes

4 years agoDropped Transform.dump_sequence(), Transform.types_sequence()
Daniele Varrazzo [Thu, 6 Aug 2020 02:51:12 +0000 (03:51 +0100)] 
Dropped Transform.dump_sequence(), Transform.types_sequence()

4 years agoDropped Transformer.dump()
Daniele Varrazzo [Thu, 6 Aug 2020 02:29:08 +0000 (03:29 +0100)] 
Dropped Transformer.dump()

4 years agoDropped MaybeOid type and optional second return value from Dumper.dump()
Daniele Varrazzo [Thu, 6 Aug 2020 02:18:53 +0000 (03:18 +0100)] 
Dropped MaybeOid type and optional second return value from Dumper.dump()

4 years agoDropped oids from Transform.dump_sequence() return value
Daniele Varrazzo [Thu, 6 Aug 2020 01:15:52 +0000 (02:15 +0100)] 
Dropped oids from Transform.dump_sequence() return value

4 years agoAdded Transformer.types_sequence
Daniele Varrazzo [Thu, 6 Aug 2020 01:09:35 +0000 (02:09 +0100)] 
Added Transformer.types_sequence

Not entirely sure yet if it will be needed, but this allows to free
dump_sequence() from returning the oids as second argument.

Dropped Transformer.get_dump_function() too.

4 years agoAdded oid property on Dumper object
Daniele Varrazzo [Thu, 6 Aug 2020 00:08:59 +0000 (01:08 +0100)] 
Added oid property on Dumper object

4 years agoDropped use of plain functions to define dumpers
Daniele Varrazzo [Wed, 5 Aug 2020 22:25:56 +0000 (23:25 +0100)] 
Dropped use of plain functions to define dumpers