summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/ext
Commit message (Collapse)AuthorAgeFilesLines
* Remove code deprecated before version 1.1Federico Caselli2020-04-093-35/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Remove deprecated method ``get_primary_keys` in the :class:`.Dialect` and :class:`.Inspector` classes. - Remove deprecated event ``dbapi_error`` and the method ``ConnectionEvents.dbapi_error`. - Remove support for deprecated engine URLs of the form ``postgres://``. - Remove deprecated dialect ``mysql+gaerdbms``. - Remove deprecated parameter ``quoting`` from :class:`.mysql.ENUM` and :class:`.mysql.SET` in the ``mysql`` dialect. - Remove deprecated function ``comparable_property``. and function ``comparable_using`` in the declarative extension. - Remove deprecated function ``compile_mappers``. - Remove deprecated method ``collection.linker``. - Remove deprecated method ``Session.prune`` and parameter ``Session.weak_identity_map``. This change also removes the class ``StrongInstanceDict``. - Remove deprecated parameter ``mapper.order_by``. - Remove deprecated parameter ``Session._enable_transaction_accounting`. - Remove deprecated parameter ``Session.is_modified.passive``. - Remove deprecated class ``Binary``. Please use :class:`.LargeBinary`. - Remove deprecated methods ``Compiled.compile``, ``ClauseElement.__and__`` and ``ClauseElement.__or__`` and attribute ``Over.func``. - Remove deprecated ``FromClause.count`` method. - Remove deprecated parameter ``Table.useexisting``. - Remove deprecated parameters ``text.bindparams`` and ``text.typemap``. - Remove boolean support for the ``passive`` parameter in ``get_history``. - Remove deprecated ``adapt_operator`` in ``UserDefinedType.Comparator``. Fixes: #4643 Change-Id: Idcd390c77bf7b0e9957907716993bdaa3f1a1763
* Use dot-separated name resolution for relationship targetMike Bayer2020-04-071-13/+43
| | | | | | | | | | | | | | | The string argument accepted as the first positional argument by the :func:`.relationship` function when using the Declarative API is no longer interpreted using the Python ``eval()`` function; instead, the name is dot separated and the names are looked up directly in the name resolution dictionary without treating the value as a Python expression. However, passing a string argument to the other :func:`.relationship` parameters that necessarily must accept Python expressions will still use ``eval()``; the documentation has been clarified to ensure that there is no ambiguity that this is in use. Fixes: #5238 Change-Id: Id802f403190adfab0ca034afe2214ba10fd9cfbb
* Add a third labeling mode for SELECT statementsMike Bayer2020-03-291-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Enhanced the disambiguating labels feature of the :func:`~.sql.expression.select` construct such that when a select statement is used in a subquery, repeated column names from different tables are now automatically labeled with a unique label name, without the need to use the full "apply_labels()" feature that conbines tablename plus column name. The disambigated labels are available as plain string keys in the .c collection of the subquery, and most importantly the feature allows an ORM :func:`.orm.aliased` construct against the combination of an entity and an arbitrary subquery to work correctly, targeting the correct columns despite same-named columns in the source tables, without the need for an "apply labels" warning. The existing labeling style is now called LABEL_STYLE_TABLENAME_PLUS_COL. This labeling style will remain used throughout the ORM as has been the case for over a decade, however, the new disambiguation scheme could theoretically replace this scheme entirely. The new scheme would dramatically alter how SQL looks when rendered from the ORM to be more succinct but arguably harder to read. The tablename_columnname scheme used by Join.c is unaffected here, as that's still hardcoded to that scheme. Fixes: #5221 Change-Id: Ib47d9e0f35046b3afc77bef6e65709b93d0c3026
* Simplified module pre-loading strategy and made it linter friendlyFederico Caselli2020-03-074-7/+7
| | | | | | | | | | | | | | | | | Introduced a modules registry to register modules that should be lazily loaded in the package init. This ensures that they are in the system module cache, avoiding potential thread safety issues as when importing them directly in the function that uses them. The module registry is used to obtain these modules directly, ensuring that the all the lazily loaded modules are resolved at the proper time This replaces dependency_for decorator and the dependencies decorator logic, removing the need to pass the resolved modules as arguments of the decodated functions and removes possible errors caused by linters. Fixes: #4689 Fixes: #4656 Change-Id: I2e291eba4297867fc0ddb5d875b9f7af34751d01
* Ensure all nested exception throws have a causeMike Bayer2020-03-025-31/+55
| | | | | | | | | | | | | | | Applied an explicit "cause" to most if not all internally raised exceptions that are raised from within an internal exception catch, to avoid misleading stacktraces that suggest an error within the handling of an exception. While it would be preferable to suppress the internally caught exception in the way that the ``__suppress_context__`` attribute would, there does not as yet seem to be a way to do this without suppressing an enclosing user constructed context, so for now it exposes the internally caught exception as the cause so that full information about the context of the error is maintained. Fixes: #4849 Change-Id: I55a86b29023675d9e5e49bc7edc5a2dc0bcd4751
* Remove print statement in favor of print() function in docs and examplesAlbert Tugushev2020-02-262-16/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | <!-- Provide a general summary of your proposed changes in the Title field above --> ### Description <!-- Describe your changes in detail --> Remove print statements ### Checklist <!-- go over following points. check them with an `x` if they do apply, (they turn into clickable checkboxes once the PR is submitted, so no need to do everything at once) --> This pull request is: - [X] A documentation / typographical error fix - Good to go, no issue or tests are needed - [ ] A short code fix - please include the issue number, and create an issue if none exists, which must include a complete example of the issue. one line code fixes without an issue and demonstration will not be accepted. - Please include: `Fixes: #<issue number>` in the commit message - please include tests. one line code fixes without tests will not be accepted. - [ ] A new feature implementation - please include the issue number, and create an issue if none exists, which must include a complete example of how the feature would look. - Please include: `Fixes: #<issue number>` in the commit message - please include tests. **Have a nice day!** Closes: #5166 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5166 Pull-request-sha: 04a7394f71298322188f0861b4dfe93e5485839d Change-Id: Ib90a59fac929661a18748c6e44966fb87e3978c6
* Result initial introductionMike Bayer2020-02-211-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This builds on cc718cccc0bf8a01abdf4068c7ea4f3 which moved RowProxy to Row, allowing Row to be more like a named tuple. - KeyedTuple in ORM is replaced with Row - ResultSetMetaData broken out into "simple" and "cursor" versions for ORM and Core, as well as LegacyCursor version. - Row now has _mapping attribute that supplies full mapping behavior. Row and SimpleRow both have named tuple behavior otherwise. LegacyRow has some mapping features on the tuple which emit deprecation warnings (e.g. keys(), values(), etc). the biggest change for mapping->tuple is the behavior of __contains__ which moves from testing of "key in row" to "value in row". - ResultProxy breaks into ResultProxy and FutureResult (interim), the latter has the newer APIs. Made available to dialects using execution options. - internal reflection methods and most tests move off of implicit Row mapping behavior and move to row._mapping, result.mappings() method using future result - a new strategy system for cursor handling replaces the various subclasses of RowProxy - some execution context adjustments. We will leave EC in but refined things like get_result_proxy() and out parameter handling. Dialects for 1.4 will need to adjust from get_result_proxy() to get_result_cursor_strategy(), if they are using this method - out parameter handling now accommodated by get_out_parameter_values() EC method. Oracle changes for this. external dialect for DB2 for example will also need to adjust for this. - deprecate case_insensitive flag for engine / result, this feature is not used mapping-methods on Row are deprecated, and replaced with Row._mapping.<meth>, including: row.keys() -> use row._mapping.keys() row.items() -> use row._mapping.items() row.values() -> use row._mapping.values() key in row -> use key in row._mapping int in row -> use int < len(row) Fixes: #4710 Fixes: #4878 Change-Id: Ieb9085e9bcff564359095b754da9ae0af55679f0
* Add keywords to MutableList.sort()Mike Bayer2020-01-231-2/+2
| | | | | | | | Added keyword arguments to the :meth:`.MutableList.sort` function so that a key function as well as the "reverse" keyword argument can be provided. Fixes: #5114 Change-Id: Iefb29e1ccadfad6ecba558ce575029307001b88e
* Merge "Use context managers for threading.Lock()"mike bayer2020-01-032-8/+2
|\
| * Use context managers for threading.Lock()Heckad2020-01-032-8/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | (zzzeek:) For some reason I thought that threading.Lock() still did not support context managers, at least in Python 2, however this does not seem to be the case. Co-authored-by: Mike Bayer <mike_mp@zzzcomputing.com> Closes: #5069 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5069 Pull-request-sha: efeac06dda5afdbe33abcf9b27c8b5b5725c8444 Change-Id: Ic64fcd99cd587bc70b4ecc5b45d8205b5c76eff2
* | happy new yearMike Bayer2020-01-0115-15/+15
|/ | | | Change-Id: I08440dc25e40ea1ccea1778f6ee9e28a00808235
* Add anonymizing context to cache keys, comparison; convert traversalMike Bayer2019-11-042-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Created new visitor system called "internal traversal" that applies a data driven approach to the concept of a class that defines its own traversal steps, in contrast to the existing style of traversal now known as "external traversal" where the visitor class defines the traversal, i.e. the SQLCompiler. The internal traversal system now implements get_children(), _copy_internals(), compare() and _cache_key() for most Core elements. Core elements with special needs like Select still implement some of these methods directly however most of these methods are no longer explicitly implemented. The data-driven system is also applied to ORM elements that take part in SQL expressions so that these objects, like mappers, aliasedclass, query options, etc. can all participate in the cache key process. Still not considered is that this approach to defining traversibility will be used to create some kind of generic introspection system that works across Core / ORM. It's also not clear if real statement caching using the _cache_key() method is feasible, if it is shown that running _cache_key() is nearly as expensive as compiling in any case. Because it is data driven, it is more straightforward to optimize using inlined code, as is the case now, as well as potentially using C code to speed it up. In addition, the caching sytem now accommodates for anonymous name labels, which is essential so that constructs which have anonymous labels can be cacheable, that is, their position within a statement in relation to other anonymous names causes them to generate an integer counter relative to that construct which will be the same every time. Gathering of bound parameters from any cache key generation is also now required as there is no use case for a cache key that does not extract bound parameter values. Applies-to: #4639 Change-Id: I0660584def8627cad566719ee98d3be045db4b8d
* Don't cache a query that has before_compile modificationsMike Bayer2019-10-261-1/+11
| | | | | | | | | | | | | | | | | The :class:`.BakedQuery` will not cache a query that was modified by a :meth:`.QueryEvents.before_compile` event, so that compilation hooks that may be applying ad-hoc modifications to queries will take effect on each run. In particular this is helpful for events that modify queries used in lazy loading as well as eager loading such as "select in" loading. In order to re-enable caching for a query modified by this event, a new flag ``bake_ok`` is added; see :ref:`baked_with_before_compile` for details. A longer term plan to provide a new form of SQL caching should solve this kind of issue more comprehensively. Fixes: #4947 Change-Id: I5823c4fa00e7b6d46a2e8461b02d8b16605a6ed0
* Add result map targeting for custom compiled, text objectsMike Bayer2019-10-071-1/+20
| | | | | | | | | | | | | | | | In order for text(), custom compiled objects, etc. to be usable by Query(), they are all targeted by object key in the result map. As we no longer want Query to implicitly label these, as well as that text() has no label feature, support adding entries to the result map that have no name, key, or type, only the object itself, and then ensure that the compiler sets up for positional targeting when this condition is detected. Allows for more flexible ORM query usage with custom expressions and text() while having less special logic in query itself. Fixes: #4887 Change-Id: Ie073da127d292d43cb132a2b31bc90af88bfe2fd
* Move identity_lookup to sessionMike Bayer2019-09-271-34/+41
| | | | | | | | This performance critical method is on Query needlessly, just to appease the horizontal sharding API. Have the performance impact of invoking Query only incur if horizontal sharding is actually used. Change-Id: I03db2befe2f5614380258927a62ed389a6ba0fae
* Remove unnecessary util.callable usageSteven Loria2019-09-092-5/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixes: #4850 <!-- Provide a general summary of your proposed changes in the Title field above --> ### Description <!-- Describe your changes in detail --> Removes usage of `util.callable`. ### Checklist <!-- go over following points. check them with an `x` if they do apply, (they turn into clickable checkboxes once the PR is submitted, so no need to do everything at once) --> This pull request is: - [ ] A documentation / typographical error fix - Good to go, no issue or tests are needed - [x] A short code fix - please include the issue number, and create an issue if none exists, which must include a complete example of the issue. one line code fixes without an issue and demonstration will not be accepted. - Please include: `Fixes: #<issue number>` in the commit message - please include tests. one line code fixes without tests will not be accepted. - [ ] A new feature implementation - please include the issue number, and create an issue if none exists, which must include a complete example of how the feature would look. - Please include: `Fixes: #<issue number>` in the commit message - please include tests. **Have a nice day!** Closes: #4851 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/4851 Pull-request-sha: a0ccdff2cb74f5e944d8baccc269c382b591c8e2 Change-Id: I79918f44becbc5dbefdc7ff65128695c1cabed1d
* Remove threadlocal strategy docs, remaining contextual_connectMike Bayer2019-08-051-1/+1
| | | | | | | | | | | | in dfb20f07d8, we merged the removal of the threadlocal strategy from the 1.4 branch. We forgot to take the docs out :). Also, there seems to be an uncovered _contextual_connect call in horizontal shard. Cover that and repair. Fixes: #4632 Closes: #4795 Change-Id: Id05cbbebe34a8f547c9c84369a929a2926c7d093
* Squashed commit of the following:Mike Bayer2019-07-051-1/+1
| | | | | | | | | | | | | | | | commit d4f3bedc74568b7ec543988ee2d43e64c5ace28f Author: Carson Ip <carsonip@users.noreply.github.com> Date: Fri Jul 5 11:20:12 2019 +0800 Fix typo in docstring commit a3e4b05744f51ec5d12a2fee1ad6093de904273e Author: Carson Ip <carsonip@users.noreply.github.com> Date: Fri Jul 5 11:14:57 2019 +0800 Fix typo in docstring Change-Id: Ifa2ebff5629bf970e5fac28bba64d501376cfae9
* Consult is_attrbute flag to determine descriptor; enable for assoc proxyMike Bayer2019-06-141-1/+1
| | | | | | | | | | | | Fixed bug where the :attr:`.Mapper.all_orm_descriptors` accessor would return an entry for the :class:`.Mapper` itself under the declarative ``__mapper___`` key, when this is not a descriptor. The ``.is_attribute`` flag that's present on all :class:`.InspectionAttr` objects is now consulted, which has also been modified to be ``True`` for an association proxy, as it was erroneously set to False for this object. Fixes: #4729 Change-Id: Ia02388cc25d004e32d337140b62a587f3e5a0b7b
* Add QueryableAttribute._impl_uses_objects accessor for AssociationProxyMike Bayer2019-05-191-6/+2
| | | | | | | | | | | | | | Fixed regression where new association proxy system was still not proxying hybrid attributes when they made use of the ``@hybrid_property.expression`` decorator to return an alternate SQL expression, or when the hybrid returned an arbitrary :class:`.PropComparator`, at the expression level. This involved futher generalization of the heuristics used to detect the type of object being proxied at the level of :class:`.QueryableAttribute`, to better detect if the descriptor ultimately serves mapped classes or column expressions. Fixes: #4690 Change-Id: I5b5300661291c94a23de53bcf92d747701720aa1
* Implement new ClauseElement role and coercion systemMike Bayer2019-05-182-2/+3
| | | | | | | | | | | | | | | | | | | | A major refactoring of all the functions handle all detection of Core argument types as well as perform coercions into a new class hierarchy based on "roles", each of which identify a syntactical location within a SQL statement. In contrast to the ClauseElement hierarchy that identifies "what" each object is syntactically, the SQLRole hierarchy identifies the "where does it go" of each object syntactically. From this we define a consistent type checking and coercion system that establishes well defined behviors. This is a breakout of the patch that is reorganizing select() constructs to no longer be in the FromClause hierarchy. Also includes a rename of as_scalar() into scalar_subquery(); deprecates automatic coercion to scalar_subquery(). Partially-fixes: #4617 Change-Id: I26f1e78898693c6b99ef7ea2f4e7dfd0e8e1a1bd
* Mutex the declarative scan/map process against configure_mappers()Mike Bayer2019-05-161-6/+12
| | | | | | | | | | | | | Applied the mapper "configure mutex" against the declarative class mapping process, to guard against the race which can occur if mappers are used while dynamic module import schemes are still in the process of configuring mappers for related classes. This does not guard against all possible race conditions, such as if the concurrent import has not yet encountered the dependent classes as of yet, however it guards against as much as possible within the SQLAlchemy declarative process. Fixes: #4686 Change-Id: I0349036b8078bd42265ab40862cfbfe5bf9d5b44
* Resolve RST306 issuesMike Bayer2019-05-131-2/+2
| | | | | | | | The latest flake8 seems to look for these and they are in fact correctable with a backslash. Also need to add r to the strings to avoid W605. Change-Id: I8045309aa2ad29978ba7e99c45f75bc1457dff3d
* remote_attr and local_attr refer to class bound attributes, notMike Bayer2019-04-251-2/+2
| | | | | | MapperProperty Change-Id: If5fee69474f295e8c4bef891f5360f6b54080bbf
* - formatting typoMike Bayer2019-04-251-1/+1
| | | | Change-Id: Ia34c2f9a6c3db83bbe0f0a06f82aa04c603cb521
* Add __reduce_ex__ to MutableList; add compat for older picklesMike Bayer2019-04-091-6/+8
| | | | | | | | | | | | | | | | | | Fixed bug where using ``copy.copy()`` or ``copy.deepcopy()`` on :class:`.MutableList` would cause the items within the list to be duplicated, due to an inconsistency in how Python pickle and copy both make use of ``__getstate__()`` and ``__setstate__()`` regarding lists. In order to resolve, a ``__reduce_ex__`` method had to be added to :class:`.MutableList`. In order to maintain backwards compatibility with existing pickles based on ``__getstate__()``, the ``__setstate__()`` method remains as well; the test suite asserts that pickles made against the old version of the class can still be deserialized by the pickle module. Also modified sqlalchemy.testing.util.picklers to return picklers all the way through pickle.HIGHEST_PROTOCOL. Fixes: #4603 Change-Id: I7f78b9cfb89d59a706248536c553dc5e1d987b88
* Refine ambiguous access for unknown attribute typesMike Bayer2019-03-261-2/+21
| | | | | | | | | | | | | | | | Restored instance-level support for plain Python descriptors, e.g. ``@property`` objects, in conjunction with association proxies, in that if the proxied object is not within ORM scope at all, it gets classified as "ambiguous" but is proxed directly. For class level access, a basic class level``__get__()`` now returns the :class:`.AmbiguousAssociationProxyInstance` directly, rather than raising its exception, which is the closest approximation to the previous behavior that returned the :class:`.AssociationProxy` itself that's possible. Also improved the stringification of these objects to be more descriptive of current state. Fixes: #4574 Change-Id: I787a22806b5530c146ae6ee66b588e5b191ae689
* Add documentation section for cascade_scalar_deletesMike Bayer2019-03-071-0/+4
| | | | | Change-Id: I56825652e0608862472bc594fc6c2b12ed5cc16f References: #4534
* Add missing attribute in hybrid.py docsDaniel Demmel2019-03-041-1/+1
|
* Add bulk_replace to AssociationSet, AssociationDictMike Bayer2019-02-041-2/+38
| | | | | | | | | | | Implemented a more comprehensive assignment operation (e.g. "bulk replace") when using association proxy with sets or dictionaries. Fixes the problem of redundant proxy objects being created to replace the old ones, which leads to excessive events and SQL and in the case of unique constraints will cause the flush to fail. Fixes: #2642 Change-Id: I57ab27dd9feba057e539267722cce92254fca777
* Add informative failure modes to _DeferredMapperConfigMike Bayer2019-01-303-0/+92
| | | | | | | | | | | Added some helper exceptions that invoke when a mapping based on :class:`.AbstractConcreteBase`, :class:`.DeferredReflection`, or :class:`.AutoMap` is used before the mapping is ready to be used, which contain descriptive information on the class, rather than falling through into other failure modes that are less informative. Fixes: #4470 Change-Id: I9bc51697f63cedaa7809a0adb17b2398c209e289
* Fix many spell glitchesLele Gaifax2019-01-257-11/+11
| | | | | | | | | | | | This affects mostly docstrings, except in orm/events.py::dispose_collection() where one parameter gets renamed: given that the method is empty, it seemed reasonable to me to fix that too. Closes: #4440 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/4440 Pull-request-sha: 779ed75acb6142e1f1daac467b5b14134529bb4b Change-Id: Ic0553fe97853054b09c2453af76d96363de6eb0e
* Implement relationship to AliasedClass; deprecate non primary mappersMike Bayer2019-01-251-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | Implemented a new feature whereby the :class:`.AliasedClass` construct can now be used as the target of a :func:`.relationship`. This allows the concept of "non primary mappers" to no longer be necessary, as the :class:`.AliasedClass` is much easier to configure and automatically inherits all the relationships of the mapped class, as well as preserves the ability for loader options to work normally. - introduce new name for mapped_table, "persist_selectable". this is the selectable that selects against the local mapper and its superclasses, but does not include columns local only to subclasses. - relationship gains "entity" which is the mapper or aliasedinsp. - clarfiy name "entity" vs. "query_entity" in loader strategies. Fixes: #4423 Fixes: #4422 Fixes: #4421 Fixes: #3348 Change-Id: Ic3609b43dc4ed115006da9ad9189e574dc0c72d9
* Add deprecation warnings to all deprecated APIsMike Bayer2019-01-231-1/+1
| | | | | | | | | | | | | | | A large change throughout the library has ensured that all objects, parameters, and behaviors which have been noted as deprecated or legacy now emit ``DeprecationWarning`` warnings when invoked. As the Python 3 interpreter now defaults to displaying deprecation warnings, as well as that modern test suites based on tools like tox and pytest tend to display deprecation warnings, this change should make it easier to note what API features are obsolete. See the notes added to the changelog and migration notes for further details. Fixes: #4393 Change-Id: If0ea11a1fc24f9a8029352eeadfc49a7a54c0a1b
* Remove version directives for 0.6, 0.7, 0.8Mike Bayer2019-01-153-44/+0
| | | | | | | | | - fix a few "seealso"s - ComparableProprerty's "superseded in 0.7" becomes deprecated in 0.7 Backport to currently maintained doc versions 1.2, 1.1 Change-Id: Ib1fcb2df8673dbe5c4ffc47f3896a60d1dfcb4b2
* Relax "ambiguous" association proxy restrictions, support ProxyMike Bayer2019-01-141-17/+25
| | | | | | | | | | | | Fixed issue in association proxy due to :ticket:`3423` which caused the use of custom :class:`.PropComparator` objects with hybrid attribites, such as the one demonstrated in the ``dictlike-polymorphic`` example to not function within an association proxy. The strictness that was added in :ticket:`3423` has been relaxed, and additional logic to accomodate for an association proxy that links to a custom hybrid have been added. Fixes: #4446 Change-Id: I8addc80f51094769915ac2dce1a301bd72ee7433
* happy new yearMike Bayer2019-01-1115-15/+15
| | | | Change-Id: I6a71f4924d046cf306961c58dffccf21e9c03911
* Post black reformattingMike Bayer2019-01-0615-206/+232
| | | | | | | | | | | | | Applied on top of a pure run of black -l 79 in I7eda77fed3d8e73df84b3651fd6cfcfe858d4dc9, this set of changes resolves all remaining flake8 conditions for those codes we have enabled in setup.cfg. Included are resolutions for all remaining flake8 issues including shadowed builtins, long lines, import order, unused imports, duplicate imports, and docstring issues. Change-Id: I4f72d3ba1380dd601610ff80b8fb06a2aff8b0fe
* Run black -l 79 against all source filesMike Bayer2019-01-0616-659/+1021
| | | | | | | | | | | | | | This is a straight reformat run using black as is, with no edits applied at all. The black run will format code consistently, however in some cases that are prevalent in SQLAlchemy code it produces too-long lines. The too-long lines will be resolved in the following commit that will resolve all remaining flake8 issues including shadowed builtins, long lines, import order, unused imports, duplicate imports, and docstring issues. Change-Id: I7eda77fed3d8e73df84b3651fd6cfcfe858d4dc9
* Fix the "greatest" example.Konstantin Tretyakov2018-12-171-12/+8
| | | | | | | | | | | | The current example code does not pass `**kw` down to the `compiler.process` calls, thus the example does not work when invoked with, `literal_binds=True`. Besides, the calls to `process` each argument twice are wasteful, and reusing the built-in `case` expression instead of hard-coding the SQL statements is slightly nicer overall, isn't it? Closes: #4402 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/4402 Pull-request-sha: 24ee93f63e21fccae6cbc1cc1c154dd56f1e1963 Change-Id: I02424d9eb2b35abd5cdec5c2cd5d464a56e7fae6
* Take instance into account when determining AssociationProxyInstanceMike Bayer2018-12-071-17/+136
| | | | | | | | | | Fixed a regression in 1.3.0b1 caused by :ticket:`3423` where association proxy objects that access an attribute that's only present on a polymorphic subclass would raise an ``AttributeError`` even though the actual instance being accessed was an instance of that subclass. Fixes: #4401 Change-Id: Ie62c48aa9142adff45cbf9a297184987c72f30f3
* "left" -> "accidentally placed at"Mike Bayer2018-12-021-2/+2
| | | | | | | | | | | since "left" is kind of ambiguous, use more explicit terminology here. Also update the test to use a positive assertion that the warning is emitted; quote the attribute name. Change-Id: Ic2284c200a26b32b2da063cfaf6d59547309d587 References: https://github.com/zzzeek/sqlalchemy/pull/488
* Warn for lower-case column attribute on declarativeMike Bayer2018-11-261-0/+14
| | | | | | | | | A warning is emitted in the case that a :func:`.column` object is applied to a declarative class, as it seems likely this intended to be a :class:`.Column` object. Fixes: #4374 Change-Id: I2e617ef65547162e3ba6587c168548ad0cf6203d
* Add missing index method to _AssociationList.Chris Macklin2018-10-311-0/+3
| | | | | | | | Added missing ``.index()`` method to list-based association collections in the association proxy extension. Change-Id: Ice81dc4bcccd520638c5bc9a0f8bb2027946c846 Pull-request: https://github.com/zzzeek/sqlalchemy/pull/485
* Move pk on single-inh subclass check below conflict resolution checkTom Manderson2018-10-301-5/+5
| | | | | | | | | | | | The column conflict resolution technique discussed at :ref:`declarative_column_conflicts` is now functional for a :class:`.Column` that is also a primary key column. Previously, a check for primary key columns declared on a single-inheritance subclass would occur before the column copy were allowed to pass. Fixes: #4352 Change-Id: Id4c025da53c28e58db6b549fe398f25f8a90d355 Pull-request: https://github.com/zzzeek/sqlalchemy/pull/483
* Merge remote-tracking branch 'origin/pr/478'Mike Bayer2018-10-301-1/+29
|\ | | | | | | Change-Id: I0f27b6426dbfd665edf2a119b1cfaadb54511dd0
| * Add warning to hybrid property expression and fixup crosslinksJames Owen2018-10-041-1/+29
| |
* | Create object- and column-oriented versions of AssociationProxyInstanceMike Bayer2018-10-261-19/+81
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The :class:`.AssociationProxy` now has standard column comparison operations such as :meth:`.ColumnOperators.like` and :meth:`.ColumnOperators.startswith` available when the target attribute is a plain column - the EXISTS expression that joins to the target table is rendered as usual, but the column expression is then use within the WHERE criteria of the EXISTS. Note that this alters the behavior of the ``.contains()`` method on the association proxy to make use of :meth:`.ColumnOperators.contains` when used on a column-based attribute. Fixes: #4351 Change-Id: I310941f4e8f778c200f8144a26a89e5364cd4dfb
* | Check more specifically for hybrid attr and not mapped propertyMike Bayer2018-10-191-1/+2
| | | | | | | | | | | | | | | | | | | | Fixed regression caused by :ticket:`4326` in version 1.2.12 where using :class:`.declared_attr` with a mixin in conjunction with :func:`.orm.synonym` would fail to map the synonym properly to an inherited subclass. Fixes: #4350 Change-Id: Ib2a9b6a125a2ac7c7ff80201746b7f10e5596226
* | selectinload omit joinJayson Reis2018-10-101-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The "selectin" loader strategy now omits the JOIN in the case of a simple one-to-many load, where it instead relies upon the foreign key columns of the related table in order to match up to primary keys in the parent table. This optimization can be disabled by setting the :paramref:`.relationship.omit_join` flag to False. Many thanks to Jayson Reis for the efforts on this. As part of this change, horizontal shard no longer relies upon the _mapper_zero() method to get the query-bound mapper, instead using the more generalized _bind_mapper() (which will use mapper_zero if no explicit FROM is present). A short check for the particular recursive condition is added to BundleEntity and it no longer assigns itself as the "namespace" to its ColumnEntity objects which creates a reference cycle. Co-authored-by: Mike Bayer <mike_mp@zzzcomputing.com> Fixes: #4340 Change-Id: I649587e1c07b684ecd63f7d10054cd165891baf4 Pull-request: https://bitbucket.org/zzzeek/sqlalchemy/pull-requests/7