Commit Graph

2280 Commits

Author SHA1 Message Date
Mike Bayer b0308a7b3a - Fixed an issue in baked queries where the .get() method, used either
directly or within lazy loads, didn't consider the mapper's "get clause"
as part of the cache key, causing bound parameter mismatches if the
clause got re-generated.  This clause is cached by mappers
on the fly but in highly concurrent scenarios may be generated more
than once when first accessed.
fixes #3597
2015-11-29 11:42:55 -05:00
Mike Bayer c90f0a49f3 - Added support for parameter-ordered SET clauses in an UPDATE
statement.  This feature is available by passing the
:paramref:`~.sqlalchemy.sql.expression.update.preserve_parameter_order`
flag either to the core :class:`.Update` construct or alternatively
adding it to the :paramref:`.Query.update.update_args` dictionary at
the ORM-level, also passing the parameters themselves as a list of 2-tuples.
Thanks to Gorka Eguileor for implementation and tests.
adapted from pullreq github:200
2015-11-28 14:30:05 -05:00
Mike Bayer 1202e140b9 - Fixed bug which is actually a regression that occurred between
versions 0.8.0 and 0.8.1, due 🎫`2714`.  The case where
joined eager loading needs to join out over a subclass-bound
relationship when "with_polymorphic" were also used would fail
to join from the correct entity.
fixes #3593
2015-11-25 15:29:04 -05:00
Mike Bayer 60c36ca841 - Fixed joinedload bug which would occur when a. the query includes
limit/offset criteria that forces a subquery b. the relationship
uses "secondary" c. the primaryjoin of the relationship refers to
a column that is either not part of the primary key, or is a PK
col in a joined-inheritance subclass table that is under a different
attribute name than the parent table's primary key column d. the
query defers the columns that are present in the primaryjoin, typically
via not being included in load_only(); the necessary column(s) would
not be present in the subquery and produce invalid SQL.
fixes #3592
2015-11-21 16:36:50 -05:00
Mike Bayer a6fe4dc0c8 - A rare case which occurs when a :meth:.Session.rollback fails in the
scope of a :meth:`.Session.flush` operation that's raising an
exception, as has been observed in some MySQL SAVEPOINT cases, prevents
the original  database exception from being observed when it was
emitted during  flush, but only on Py2K because Py2K does not support
exception  chaining; on Py3K the originating exception is chained.  As
a workaround, a warning is emitted in this specific case showing at
least the string message of the original database error before we
proceed to raise  the rollback-originating exception.
fixes #2696
2015-11-19 15:45:17 -05:00
Mike Bayer 1dc805dd4d - add documentation that describes, then proceeds to warn about
the many caveats and confusing effects of, the popular approach
of using contains_eager() to alter the natural result of a
related collection.  I'm not a fan of this technique as it changes
the semantics of a relationship in such a way that the rest of the
ORM isn't aware of and it also can be undone very easily; hence the
section needs as much text for warnings as for describing the
technique itself.   fixes #3563
2015-11-19 15:24:22 -05:00
Mike Bayer 9ed36c2eed - Fixed the `.python_type attribute of :class:.postgresql.INTERVAL`
to return ``datetime.timedelta`` in the same way as that of
:obj:`.types.Interval.python_type`, rather than raising
``NotImplementedError``.
fixes #3571

(cherry picked from commit 29d6f6e19b)
2015-11-19 15:11:37 -05:00
Mike Bayer c7f9aa2818 - rewrite the docs and add a test for the bake_queries=True
relationship flag; this flag *does* have an effect when the baked
lazy loader plugin has been invoked.  clarify the intent of this
flag as an "opt out" but only has an effect when the baked system
is loaded anyway.  fixes #3572
2015-11-19 14:23:08 -05:00
Mike Bayer 14498364f8 - Added support for reflecting the source of materialized views
to the Postgresql version of the :meth:`.Inspector.get_view_definition`
method.
fixes #3587
2015-11-18 09:06:33 -05:00
Mike Bayer 0847097c29 - extend pullreq github:213 to also include DATETIMEOFFSET and TIME,
which also accept zero precision
- extend test case here to include a backend-agnostic suite
- changelog for MSSQL date fix
2015-11-14 12:38:45 -05:00
Mike Bayer 33c378f768 - Fixed bug where the "single table inheritance" criteria would be
added onto the end of a query in some inappropriate situations, such
as when querying from an exists() of a single-inheritance subclass.

fixes #3582
2015-11-11 12:57:32 -05:00
Mike Bayer 1dbd3a0706 Merge branch 'jeffwidman/fix-typo-foriegn-foreign-1446862160653' of https://bitbucket.org/jeffwidman/sqlalchemy-1 into typos 2015-11-10 12:56:01 -05:00
Mike Bayer 5d8bb1f4a6 - fix ambiguous documentation re: after_flush_postexec(), the
looping nature of it only occurs within the context of a commit.
2015-11-09 16:48:58 -05:00
Mike Bayer 2d54e3819f - fix broken link to loader behavior 2015-11-07 14:24:12 -05:00
Jeff Widman 8660883e1a Fix typo: foriegn --> foreign 2015-11-07 02:09:28 +00:00
Mike Bayer 07a199d929 - cross-linking for pool recycle feature 2015-10-30 11:47:32 -04:00
Mike Bayer 382950b701 Merge branch 'pr204' 2015-10-29 14:38:34 -04:00
Mike Bayer e31211c578 - convert wrap_callable() to a general purpose update_wrapper-like
function; the caller still passes in the "wrapper"
- move tests for wrap_callable() to be generic util tests
- changelog for pullreq github:204
2015-10-29 14:28:00 -04:00
Mike Bayer c2c4fc14d5 Merge remote-tracking branch 'origin/pr/196' into pr196 2015-10-22 17:27:44 -04:00
Mike Bayer 2daaacef04 - update the pool pessimistic invalidation recipe to refer to the
engine_connect event, allowing easy detection of disconnects
and full invalidation of the pool
2015-10-22 11:58:25 -04:00
Mike Bayer 8a4a1fd70a - release date for 1.0.9 2015-10-20 18:14:26 -04:00
Mike Bayer 1e0afd584c - Fixed regression in 1.0 where new feature of using "executemany"
for UPDATE statements in the ORM (e.g. :ref:`feature_updatemany`)
would break on Postgresql and other RETURNING backends
when using server-side version generation
schemes, as the server side value is retrieved via RETURNING which
is not supported with executemany.
fixes #3556
2015-10-19 12:17:37 -04:00
Mike Bayer 9d08c6abc2 - Added the :paramref:.AssociationProxy.info parameter to the
:class:`.AssociationProxy` constructor, to suit the
:attr:`.AssociationProxy.info` accessor that was added in
🎫`2971`.  This is possible because :class:`.AssociationProxy`
is constructed explicitly, unlike a hybrid which is constructed
implicitly via the decorator syntax.
fixes #3551
2015-10-09 18:01:43 -04:00
Mike Bayer 845500280d - open up autoincrement for columns that have a default; autoinc is usually
"auto" now so True can indicate the dialect would support this
2015-10-08 17:02:55 -04:00
Mike Bayer 414af7b612 - The system by which a :class:.Column considers itself to be an
"auto increment" column has been changed, such that autoincrement
is no longer implicitly enabled for a :class:`.Table` that has a
composite primary key.  In order to accommodate being able to enable
autoincrement for a composite PK member column while at the same time
maintaining SQLAlchemy's long standing behavior of enabling
implicit autoincrement for a single integer primary key, a third
state has been added to the :paramref:`.Column.autoincrement` parameter
``"auto"``, which is now the default. fixes #3216
- The MySQL dialect no longer generates an extra "KEY" directive when
generating CREATE TABLE DDL for a table using InnoDB with a
composite primary key with AUTO_INCREMENT on a column that isn't the
first column;  to overcome InnoDB's limitation here, the PRIMARY KEY
constraint is now generated with the AUTO_INCREMENT column placed
first in the list of columns.
2015-10-07 10:02:45 -04:00
Mike Bayer 4578ab54a5 - Fixed bug in Oracle dialect where reflection of tables and other
symbols with names quoted to force all-lower-case would not be
identified properly in reflection queries.  The :class:`.quoted_name`
construct is now applied to incoming symbol names that detect as
forced into all-lower-case within the "name normalize" process.
fixes #3548
2015-10-05 09:49:34 -04:00
Mike Bayer d84dea62de - add an additional note regarding select_from, fixes #3546 2015-10-02 11:23:50 -04:00
Mike Bayer ac08920284 - remove ambiguous use of the phrase "joined together by AND" as this
may be construed as the Python "and" keyword
- add notes to ORM tutorial for beginners that Python "and" keyword
is not to be used
fixes #3545
2015-10-01 09:38:22 -04:00
Mike Bayer 5bb2536cc5 - limit the search for schemas to not include "temp", which is sort of an implicit schema
- repair the CREATE INDEX ddl for schemas
- update provisioning to include support for setting up ATTACH DATABASE up front
for the test_schema; enable "schemas" testing for SQLite
- changelog / migration notes for new SQLite schema support
- include the "schema" as the "remote_schema" when we reflect SQLite FKs
2015-09-28 17:48:55 -04:00
Mike Bayer 5b71858533 - replicate Query.one_or_none to BakedQuery
- changelog / version note finishing
2015-09-24 13:52:25 -04:00
Eric Siegerman a9b5fb3f49 Add Query.one_or_none() 2015-09-24 13:22:45 -04:00
Mike Bayer 47fcb1d0b6 - Fixed rare TypeError which could occur when stringifying certain
kinds of internal column loader options within internal logging.
fixes #3539
2015-09-23 16:40:16 -04:00
Mike Bayer 3dfcb10bef - The `legacy_schema_aliasing` flag, introduced in version 1.0.5
as part of 🎫`3424` to allow disabling of the MSSQL dialect's
attempts to create aliases for schema-qualified tables, now defaults
to False; the old behavior is now disabled unless explicitly turned on.
fixes #3434
2015-09-19 18:06:23 -04:00
Mike Bayer 80aeba3d5e - Added a new type-level modifier :meth:.TypeEngine.evaluates_none
which indicates to the ORM that a positive set of None should be
persisted as the value NULL, instead of omitting the column from
the INSERT statement.  This feature is used both as part of the
implementation for 🎫`3514` as well as a standalone feature
available on any type.  fixes #3250
- add new documentation section illustrating the "how to force null"
 use case of #3250
- alter our change from #3514 so that the class-level flag is now
called "should_evaluate_none"; so that "evaluates_none" is now
a generative method.
2015-09-19 16:27:51 -04:00
Mike Bayer 371f1a82c5 - The use of a :class:.postgresql.ARRAY object that refers
to a :class:`.types.Enum` or :class:`.postgresql.ENUM` subtype
will now emit the expected "CREATE TYPE" and "DROP TYPE" DDL when
the type is used within a "CREATE TABLE" or "DROP TABLE".
fixes #2729
2015-09-19 11:58:50 -04:00
Mike Bayer 24a7241b5e - The :func:.type_coerce construct is now a fully fledged Core
expression element which is late-evaluated at compile time.  Previously,
the function was only a conversion function which would handle different
expression inputs by returning either a :class:`.Label` of a column-oriented
expression or a copy of a given :class:`.BindParameter` object,
which in particular prevented the operation from being logically
maintained when an ORM-level expression transformation would convert
a column to a bound parameter (e.g. for lazy loading).
fixes #3531
2015-09-16 18:46:53 -04:00
Mike Bayer 7eb34baf99 - fix incorrect example in inheritance docs 2015-09-15 11:17:13 -04:00
Mike Bayer fe41e39b9b - add new entry for sharing of Engine across process boundaries 2015-09-14 11:02:43 -04:00
Mike Bayer ad28e228e3 - call it deque, since you can really pop from either side 2015-09-10 10:28:42 -04:00
Mike Bayer 03797b7847 - add a new FAQ recipe for "walk all objects", replacing the need
to use mapper.cascade_iterator() for this purpose as it was not really
designed for that use case.  Add docs to cascade_iterator() pointing
to the recipe.  fixes #3498
2015-09-10 10:00:46 -04:00
Mike Bayer f5b13797a6 Merged in bsmithgall/sqlalchemy/event-doc-link-fix (pull request #60)
fix typo in session events docs
2015-09-08 18:10:51 -04:00
mike bayer 74781d8532 Merge pull request #197 from davidjb/master
Minor grammar fix for capitalisation in session docs
2015-09-08 18:09:06 -04:00
Mike Bayer 0997e843f2 - Internal calls to "bookkeeping" functions within
:meth:`.Session.bulk_save_objects` and related bulk methods have
been scaled back to the extent that this functionality is not
currently used, e.g. checks for column default values to be
fetched after an INSERT or UPDATE statement.
fixes #3526
2015-09-08 14:12:32 -04:00
Mike Bayer 68a6701c6d - Fixed bug in :meth:.Session.bulk_save_objects where a mapped
column that had some kind of "fetch on update" value and was not
locally present in the given object would cause an AttributeError
within the operation.
fixes #3525
2015-09-08 13:00:26 -04:00
bsmithgall 2fb3bb31ef fix typo in session events docs 2015-09-07 21:37:19 -04:00
Mike Bayer 176ac6ab09 - update moved link, fixes #3351 2015-09-03 16:42:43 -04:00
Mike Bayer 606135dd98 Merge branch 'ticket_2677' 2015-09-02 17:55:26 -04:00
Mike Bayer 108c60f460 - The :class:.SessionEvents suite now includes events to allow
unambiguous tracking of all object lifecycle state transitions
in terms of the :class:`.Session` itself, e.g. pending,
transient,  persistent, detached.   The state of the object
within each event is also defined.
fixes #2677
- Added a new session lifecycle state :term:`deleted`.  This new state
represents an object that has been deleted from the :term:`persistent`
state and will move to the :term:`detached` state once the transaction
is committed.  This resolves the long-standing issue that objects
which were deleted existed in a gray area between persistent and
detached.   The :attr:`.InstanceState.persistent` accessor will
**no longer** report on a deleted object as persistent; the
:attr:`.InstanceState.deleted` accessor will instead be True for
these objects, until they become detached.
- The :paramref:`.Session.weak_identity_map` parameter is deprecated.
See the new recipe at :ref:`session_referencing_behavior` for
an event-based approach to maintaining strong identity map behavior.
references #3517
2015-09-02 17:55:15 -04:00
Mike Bayer 8be93c23ee - add new documentation that applies to all modern SQLA versions,
detailing ORM event recipes across the board.
2015-09-02 11:58:59 -04:00
Mike Bayer c39ff9978d - Fixed regression in 1.0-released default-processor for multi-VALUES
insert statement, 🎫`3288`, where the column type for the
default-holding column would not be propagated to the compiled
statement in the case where the default was being used,
leading to bind-level type handlers not being invoked.
fixes #3520
2015-08-31 11:30:03 -04:00