summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/ext/compiler.py
Commit message (Collapse)AuthorAgeFilesLines
* Improve rendering of core statements w/ ORM elementsMike Bayer2020-05-311-5/+4
| | | | | | | | | | | | | | | | | | | | This patch contains a variety of ORM and expression layer tweaks to support ORM constructs in select() statements, without the 1.3.x requiremnt in Query that a full _compile_context() + new select() is needed in order to get a working statement object. Includes such tweaks as the ability to implement aliased class of an aliased class, as we are looking to fully support ACs against subqueries, as well as the ability to access anonymously-labeled ColumnProperty expressions within subqueries by naming the ".key" of the label after the property key. Some tuning to query.join() as well as ORMJoin internals to allow things to work more smoothly. Change-Id: Id810f485c5f7ed971529489b84694e02a3356d6d
* Run search and replace of symbolic module namesMike Bayer2020-04-141-5/+6
| | | | | | | | Replaces a wide array of Sphinx-relative doc references with an abbreviated absolute form now supported by zzzeeksphinx. Change-Id: I94bffcc3f37885ffdde6238767224296339698a2
* Ensure all nested exception throws have a causeMike Bayer2020-03-021-8/+15
| | | | | | | | | | | | | | | 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-261-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | <!-- 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
* happy new yearMike Bayer2020-01-011-1/+1
| | | | Change-Id: I08440dc25e40ea1ccea1778f6ee9e28a00808235
* Add anonymizing context to cache keys, comparison; convert traversalMike Bayer2019-11-041-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* 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
* happy new yearMike Bayer2019-01-111-1/+1
| | | | Change-Id: I6a71f4924d046cf306961c58dffccf21e9c03911
* Run black -l 79 against all source filesMike Bayer2019-01-061-11/+19
| | | | | | | | | | | | | | 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
* happy new yearMike Bayer2018-01-121-1/+1
| | | | Change-Id: I3ef36bfd0cb0ba62b3123c8cf92370a43156cf8f
* Support python3.6Mike Bayer2017-01-131-3/+3
| | | | | | | | | | | Corrects some warnings and adds tox config. Adds DeprecationWarning to the error category. Large sweep for string literals w/ backslashes as this is common in docstrings Co-authored-by: Andrii Soldatenko Fixes: #3886 Change-Id: Ia7c838dfbbe70b262622ed0803d581edc736e085 Pull-request: https://github.com/zzzeek/sqlalchemy/pull/337
* update for 2017 copyrightMike Bayer2017-01-041-1/+1
| | | | Change-Id: I4e8c2aa8fe817bb2af8707410fa0201f938781de
* spelling: Postgresql -> PostgreSQLVille Skyttä2016-10-081-1/+1
|
* Ensure @compiles calls down to the original compilation schemeMike Bayer2016-06-291-2/+15
| | | | | | | | | | | | | | | Made a slight behavioral change in the ``sqlalchemy.ext.compiler`` extension, whereby the existing compilation schemes for an established construct would be removed if that construct was itself didn't already have its own dedicated ``__visit_name__``. This was a rare occurrence in 1.0, however in 1.1 :class:`.postgresql.ARRAY` subclasses :class:`.sqltypes.ARRAY` and has this behavior. As a result, setting up a compilation handler for another dialect such as SQLite would render the main :class:`.postgresql.ARRAY` object no longer compilable. Fixes: #3732 Change-Id: If2c1ada4eeb09157885888e41f529173902f2b49
* - happy new yearMike Bayer2016-01-291-1/+1
|
* - add a note that the literal_binds flag should be usedMike Bayer2016-01-201-1/+11
| | | | when cross-compiling from DDL to SQL, fixes #3615
* - copyright 2015Mike Bayer2015-03-101-1/+1
|
* PEP8 style fixesBrian Jarrett2014-07-131-5/+7
|
* - break up the <authors> copyright comment as part of a passMike Bayer2014-07-091-1/+2
| | | | to get all flake8 passing
* Documentation fix-up: "its" vs. "it's"pr/91Matthias Urlichs2014-05-111-1/+1
| | | | | | | | | Removed ungrammatical apostrophes from documentation, replacing "it's" with "its" where appropriate (but in a few cases with "it is" when that read better). While doing that, I also fixed a couple of minor typos etc. as I noticed them.
* - happy new yearMike Bayer2014-01-051-1/+1
|
* Fix cross referencesVraj Mohan2013-11-121-1/+1
|
* - Added new method to the :func:`.insert` constructMike Bayer2013-07-051-0/+6
| | | | | | | | | | :meth:`.Insert.from_select`. Given a list of columns and a selectable, renders ``INSERT INTO (table) (columns) SELECT ..``. While this feature is highlighted as part of 0.9 it is also backported to 0.8.3. [ticket:722] - The :func:`.update`, :func:`.insert`, and :func:`.delete` constructs will now interpret ORM entities as FROM clauses to be operated upon, in the same way that select() already does. Also in 0.8.3.
* happy new year (see #2645)Diana Clarke2013-01-011-1/+1
|
* fixing broken links (see #2625)Diana Clarke2012-12-061-5/+6
|
* just a pep8 pass of lib/sqlalchemy/extDiana Clarke2012-11-191-47/+63
|
* - [feature] Added a hook to the system of renderingMike Bayer2012-09-091-0/+15
| | | | | | | CREATE TABLE that provides access to the render for each Column individually, by constructing a @compiles function against the new schema.CreateColumn construct. [ticket:2463]
* - move ext to relative importsMike Bayer2012-07-171-25/+25
|
* happy new yearMike Bayer2012-01-041-1/+1
|
* - [bug] the @compiles decorator raises anMike Bayer2011-12-061-1/+7
| | | | | | informative error message when no "default" compilation handler is present, rather than KeyError.
* document autocommit when using the compiler extension, update the ↵Mike Bayer2011-08-181-0/+49
| | | | "understanding autocommit" section
* - add some function examples, [ticket:2107]Mike Bayer2011-04-021-1/+117
| | | | | | - have "packagenames" be present on FunctionElement by default so that compiler.visit_function() can be called - add a test for that
* - whitespace removal bonanzaMike Bayer2011-01-021-17/+17
|
* - clean up copyright, update for 2011, stamp every file withMike Bayer2011-01-021-0/+6
| | | | | a consistent tag - AUTHORS file
* almost through.Mike Bayer2010-09-041-0/+2
|
* - The 'default' compiler is automatically copied overMike Bayer2010-07-021-1/+6
| | | | | | | | when overriding the compilation of a built in clause construct, so no KeyError is raised if the user-defined compiler is specific to certain backends and compilation for a different backend is invoked. [ticket:1838]
* add example for changing TypeEngine compilationMike Bayer2010-04-071-1/+18
|
* add FunctionElement exampleMike Bayer2010-04-021-2/+17
|
* - the compiler extension now allows @compiles decoratorsMike Bayer2010-03-301-1/+1
| | | | | | on base classes that extend to child classes, @compiles decorators on child classes that aren't broken by a @compiles decorator on the base class.
* - Made sqlalchemy.sql.expressions.Executable part of publicMike Bayer2010-02-121-1/+8
| | | | | | | | | | | API, used for any expression construct that can be sent to execute(). FunctionElement now inherits Executable so that it gains execution_options(), which are also propagated to the select() that's generated within execute(). Executable in turn subclasses _Generative which marks any ClauseElement that supports the @_generative decorator - these may also become "public" for the benefit of the compiler extension at some point.
* add a note about type for ColumnElementMike Bayer2010-02-071-0/+8
|
* some compile docsMike Bayer2009-12-301-2/+40
|
* - subclassed Function off of new FunctionElement generic baseMike Bayer2009-11-101-11/+42
| | | | | | - removed "key" accessor of Function, Grouping - this doesn't seem to be used for anything - various formatting - documented the four "Element" classes in the compiler extension as per [ticket:1590]
* merge 0.6 series to trunk.Mike Bayer2009-08-061-4/+4
|
* - Back-ported the "compiler" extension from SQLA 0.6. Thisrel_0_5_4Mike Bayer2009-05-171-0/+110
is a standardized interface which allows the creation of custom ClauseElement subclasses and compilers. In particular it's handy as an alternative to text() when you'd like to build a construct that has database-specific compilations. See the extension docs for details.