Mike Bayer [Thu, 5 Feb 2015 21:17:23 +0000 (16:17 -0500)]
- The MySQL dialect now renders TIMESTAMP with NULL / NOT NULL in
all cases, so that MySQL 5.6.6 with the
``explicit_defaults_for_timestamp`` flag enabled will
will allow TIMESTAMP to continue to work as expected when
``nullable=False``. Existing applications are unaffected as
SQLAlchemy has always emitted NULL for a TIMESTAMP column that
is ``nullable=True``. fixes #3155
Mike Bayer [Wed, 4 Feb 2015 23:51:24 +0000 (18:51 -0500)]
- Fixed bug in :class:`.Connection` and pool where the
:meth:`.Connection.invalidate` method, or an invalidation due
to a database disconnect, would fail if the
``isolation_level`` parameter had been used with
:meth:`.Connection.execution_options`; the "finalizer" that resets
the isolation level would be called on the no longer opened connection.
fixes #3302
Mike Bayer [Wed, 4 Feb 2015 22:07:15 +0000 (17:07 -0500)]
- A warning is emitted if the ``isolation_level`` parameter is used
with :meth:`.Connection.execution_options` when a :class:`.Transaction`
is in play; DBAPIs and/or SQLAlchemy dialects such as psycopg2,
MySQLdb may implicitly rollback or commit the transaction, or
not change the setting til next transaction, so this is never safe.
- Added new parameter :paramref:`.Session.connection.execution_options`
which may be used to set up execution options on a :class:`.Connection`
when it is first checked out, before the transaction has begun.
This is used to set up options such as isolation level on the
connection before the transaction starts.
- added new documentation section
detailing best practices for setting transaction isolation with
sessions.
fixes #3296
Mike Bayer [Tue, 3 Feb 2015 00:46:13 +0000 (19:46 -0500)]
- Fixed bug in lazy loading SQL construction whereby a complex
primaryjoin that referred to the same "local" column multiple
times in the "column that points to itself" style of self-referential
join would not be substituted in all cases. The logic to determine
substitutions here has been reworked to be more open-ended.
fixes #3300
Mike Bayer [Mon, 2 Feb 2015 00:00:07 +0000 (19:00 -0500)]
- Repaired support for Postgresql UUID types in conjunction with
the ARRAY type when using psycopg2. The psycopg2 dialect now
employs use of the psycopg2.extras.register_uuid() hook
so that UUID values are always passed to/from the DBAPI as
UUID() objects. The :paramref:`.UUID.as_uuid` flag is still
honored, except with psycopg2 we need to convert returned
UUID objects back into strings when this is disabled.
fixes #2940
Mike Bayer [Sun, 1 Feb 2015 00:04:54 +0000 (19:04 -0500)]
- Added support for the :class:`postgresql.JSONB` datatype when
using psycopg2 2.5.4 or greater, which features native conversion
of JSONB data so that SQLAlchemy's converters must be disabled;
additionally, the newly added psycopg2 extension
``extras.register_default_jsonb`` is used to establish a JSON
deserializer passed to the dialect via the ``json_deserializer``
argument. Also repaired the Postgresql integration tests which
weren't actually round-tripping the JSONB type as opposed to the
JSON type. Pull request courtesy Mateusz Susik.
- Repaired the use of the "array_oid" flag when registering the
HSTORE type with older psycopg2 versions < 2.4.3, which does not
support this flag, as well as use of the native json serializer
hook "register_default_json" with user-defined ``json_deserializer``
on psycopg2 versions < 2.5, which does not include native json.
Mike Bayer [Fri, 30 Jan 2015 18:38:51 +0000 (13:38 -0500)]
- The :class:`.CheckConstraint` construct now supports naming
conventions that include the token ``%(column_0_name)s``; the
constraint expression is scanned for columns. Additionally,
naming conventions for check constraints that don't include the
``%(constraint_name)s`` token will now work for :class:`.SchemaType`-
generated constraints, such as those of :class:`.Boolean` and
:class:`.Enum`; this stopped working in 0.9.7 due to :ticket:`3067`.
fixes #3299
Mike Bayer [Wed, 28 Jan 2015 16:48:20 +0000 (11:48 -0500)]
- Fixed bug in 0.9's foreign key setup system, such that
the logic used to link a :class:`.ForeignKey` to its parent could fail
when the foreign key used "link_to_name=True" in conjunction with
a target :class:`.Table` that would not receive its parent column until
later, such as within a reflection + "useexisting" scenario,
if the target column in fact had a key value different from its name,
as would occur in reflection if column reflect events were used to
alter the .key of reflected :class:`.Column` objects so that the
link_to_name becomes significant. Also repaired support for column
type via FK transmission in a similar way when target columns had a
different key and were referenced using link_to_name.
fixes #3298
Mike Bayer [Mon, 26 Jan 2015 23:02:46 +0000 (18:02 -0500)]
- additional test adjustments for pypy / psycopg2cffi. This
consists mainly of adjusting fixtures to ensure connections are closed
explicitly. psycopg2cffi also handles unicode bind parameter
names differently than psycopg2, and seems to possibly have a little less
control over floating point values at least in one test which is
marked as a "fail", though will see if it runs differently on linux
than osx..
- changelog for psycopg2cffi, fixes #3052
Mike Bayer [Sun, 25 Jan 2015 23:22:00 +0000 (18:22 -0500)]
- remove the clever approach w/ dialect events, and remove the need
for a for-loop through an empty tuple. we add one more local flag
to handle the logic without repetition of dialect.do_execute()
calls.
Mike Bayer [Sun, 25 Jan 2015 22:53:41 +0000 (17:53 -0500)]
- remove context-specific post-crud logic from Connection and inline post-crud
logic to some degree in DefaultExecutionContext. In particular
we are removing post_insert() which doesn't appear to be used
based on a survey of prominent third party dialects. Callcounts
aren't added to existing execute profiling tests and inserts might be
a little better.
- simplify the execution_options join in DEC. Callcounts don't
appear affected.
Mike Bayer [Tue, 20 Jan 2015 16:37:13 +0000 (11:37 -0500)]
- Added new user-space accessors for viewing transaction isolation
levels; :meth:`.Connection.get_isolation_level`,
:attr:`.Connection.default_isolation_level`.
- enhance documentation inter-linkage between new accessors,
existing isolation_level parameters, as well as in
the dialect-level methods which should be fully covered
by Engine/Connection level APIs now.
Mike Bayer [Mon, 19 Jan 2015 22:55:23 +0000 (17:55 -0500)]
- The primary :class:`.Mapper` of a :class:`.Query` is now passed to the
:meth:`.Session.get_bind` method when calling upon
:meth:`.Query.count`, :meth:`.Query.update`, :meth:`.Query.delete`,
as well as queries against mapped columns,
:obj:`.column_property` objects, and SQL functions and expressions
derived from mapped columns. This allows sessions that rely upon
either customized :meth:`.Session.get_bind` schemes or "bound" metadata
to work in all relevant cases.
fixes #3227 fixes #3242 fixes #1326
Mike Bayer [Sun, 18 Jan 2015 02:36:52 +0000 (21:36 -0500)]
- fix a regression from ref #3178, where dialects that don't actually support
sane multi rowcount (e.g. pyodbc) would fail on multirow update. add
a test that mocks this breakage into plain dialects
Mike Bayer [Sat, 17 Jan 2015 01:03:33 +0000 (20:03 -0500)]
- Custom dialects that implement :class:`.GenericTypeCompiler` can
now be constructed such that the visit methods receive an indication
of the owning expression object, if any. Any visit method that
accepts keyword arguments (e.g. ``**kw``) will in most cases
receive a keyword argument ``type_expression``, referring to the
expression object that the type is contained within. For columns
in DDL, the dialect's compiler class may need to alter its
``get_column_specification()`` method to support this as well.
The ``UserDefinedType.get_col_spec()`` method will also receive
``type_expression`` if it provides ``**kw`` in its argument
signature.
fixes #3074
Mike Bayer [Fri, 16 Jan 2015 23:03:45 +0000 (18:03 -0500)]
- Fixed bug where Postgresql dialect would fail to render an
expression in an :class:`.Index` that did not correspond directly
to a table-bound column; typically when a :func:`.text` construct
was one of the expressions within the index; or could misinterpret the
list of expressions if one or more of them were such an expression.
fixes #3174
Mike Bayer [Tue, 13 Jan 2015 22:04:35 +0000 (17:04 -0500)]
- The "wildcard" loader options, in particular the one set up by
the :func:`.orm.load_only` option to cover all attributes not
explicitly mentioned, now takes into account the superclasses
of a given entity, if that entity is mapped with inheritance mapping,
so that attribute names within the superclasses are also omitted
from the load. Additionally, the polymorphic discriminator column
is unconditionally included in the list, just in the same way that
primary key columns are, so that even with load_only() set up,
polymorphic loading of subtypes continues to function correctly.
fixes #3287
Mike Bayer [Tue, 13 Jan 2015 19:33:33 +0000 (14:33 -0500)]
- The multi-values version of :meth:`.Insert.values` has been
repaired to work more usefully with tables that have Python-
side default values and/or functions, as well as server-side
defaults. The feature will now work with a dialect that uses
"positional" parameters; a Python callable will also be
invoked individually for each row just as is the case with an
"executemany" style invocation; a server- side default column
will no longer implicitly receive the value explicitly
specified for the first row, instead refusing to invoke
without an explicit value. fixes #3288
Mike Bayer [Tue, 6 Jan 2015 02:38:19 +0000 (21:38 -0500)]
- Fixed bug where if an exception were thrown at the start of a
:class:`.Query` before it fetched results, particularly when
row processors can't be formed, the cursor would stay open with
results pending and not actually be closed. This is typically only
an issue on an interpreter like Pypy where the cursor isn't
immediately GC'ed, and can in some circumstances lead to transactions/
locks being open longer than is desirable.
fixes #3285
Mike Bayer [Tue, 6 Jan 2015 00:02:08 +0000 (19:02 -0500)]
- add MemoizedSlots, a generalized solution to using __getattr__
for memoization on a class that uses slots.
- apply many more __slots__. mem use for nova now at 46% savings
Mike Bayer [Mon, 5 Jan 2015 00:28:08 +0000 (19:28 -0500)]
- Structural memory use has been improved via much more significant use
of ``__slots__`` for many internal objects. This optimization is
particularly geared towards the base memory size of large applications
that have lots of tables and columns, and greatly reduces memory
size for a variety of high-volume objects including event listening
internals, comparator objects and parts of the ORM attribute and
loader strategy system.
Mike Bayer [Mon, 5 Jan 2015 00:05:31 +0000 (19:05 -0500)]
- scale back _Dispatch and _JoinedDispatcher to use a __getitem__ scheme
to start up listener collections; this pulls the overhead off of construction
and makes performance much like the descriptor version, while still allowing
slots. Fix up some profiles.
Mike Bayer [Sun, 4 Jan 2015 06:53:42 +0000 (01:53 -0500)]
- start trying to move things into __slots__. This seems to reduce the
size of the many per-column objects we're hitting, but somehow the overall memory is
hardly being reduced at all in initial testing
Mike Bayer [Sun, 4 Jan 2015 01:43:45 +0000 (20:43 -0500)]
- The :class:`.mysql.SET` type has been overhauled to no longer
assume that the empty string, or a set with a single empty string
value, is in fact a set with a single empty string; instead, this
is by default treated as the empty set. In order to handle persistence
of a :class:`.mysql.SET` that actually wants to include the blank
value ``''`` as a legitimate value, a new bitwise operational mode
is added which is enabled by the
:paramref:`.mysql.SET.retrieve_as_bitwise` flag, which will persist
and retrieve values unambiguously using their bitflag positioning.
Storage and retrieval of unicode values for driver configurations
that aren't converting unicode natively is also repaired.
fixes #3283
Mike Bayer [Thu, 1 Jan 2015 18:47:08 +0000 (13:47 -0500)]
- restate sort_tables in terms of a more fine grained
sort_tables_and_constraints function.
- The DDL generation system of :meth:`.MetaData.create_all`
and :meth:`.Metadata.drop_all` has been enhanced to in most
cases automatically handle the case of mutually dependent
foreign key constraints; the need for the
:paramref:`.ForeignKeyConstraint.use_alter` flag is greatly
reduced. The system also works for constraints which aren't given
a name up front; only in the case of DROP is a name required for
at least one of the constraints involved in the cycle.
fixes #3282
Mike Bayer [Thu, 1 Jan 2015 18:24:32 +0000 (13:24 -0500)]
- Added a new accessor :attr:`.Table.foreign_key_constraints`
to complement the :attr:`.Table.foreign_keys` collection,
as well as :attr:`.ForeignKeyConstraint.referred_table`.
Mike Bayer [Tue, 30 Dec 2014 01:01:21 +0000 (20:01 -0500)]
- fix some RST whitespace syntactical issues in toctrees
- have the topmost toctree only include page names
- add glossary to toctree, remove search by itself
Mike Bayer [Fri, 19 Dec 2014 17:14:52 +0000 (12:14 -0500)]
- Fixed bug where using a :class:`.TypeDecorator` that implemented
a type that was also a :class:`.TypeDecorator` would fail with
Python's "Cannot create a consistent method resolution order (MRO)"
error, when any kind of SQL comparison expression were used against
an object using this type.
Mike Bayer [Wed, 17 Dec 2014 22:24:23 +0000 (17:24 -0500)]
- squash-merge the improve_toc branch, which moves all the Sphinx styling
and extensions into an external library, and also reorganizes most large documentation
pages into many small areas to reduce scrolling and better present the context
into a more fine-grained hierarchy.
Mike Bayer [Sat, 13 Dec 2014 23:04:11 +0000 (18:04 -0500)]
- rework sqlite FK and unique constraint system to combine both PRAGMA
and regexp parsing of SQL in order to form a complete picture of
constraints + their names. fixes #3244 fixes #3261
- factor various PRAGMA work to be centralized into one call