summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/util/langhelpers.py
Commit message (Collapse)AuthorAgeFilesLines
...
* Post black reformattingMike Bayer2019-01-061-9/+14
| | | | | | | | | | | | | 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-061-170/+253
| | | | | | | | | | | | | | 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
* Prep for flake8 refactoringMike Bayer2019-01-031-1/+3
| | | | | | | | a few code changes ahead of time to handle some __all__ issues better. also include new flake8 rules, since the existing flake8 doesn't pass in any case. Change-Id: I1efdf75124ae7bcac719c22e505bb5b13db06c04
* Handle PostgreSQL enums in remote schemasMike Bayer2018-12-211-0/+45
| | | | | | | | | | | | | | | | | | Fixed issue where a :class:`.postgresql.ENUM` or a custom domain present in a remote schema would not be recognized within column reflection if the name of the enum/domain or the name of the schema required quoting. A new parsing scheme now fully parses out quoted or non-quoted tokens including support for SQL-escaped quotes. Fixed issue where multiple :class:`.postgresql.ENUM` objects referred to by the same :class:`.MetaData` object would fail to be created if multiple objects had the same name under different schema names. The internal memoization the Postgresql dialect uses to track if it has created a particular :class:`.postgresql.ENUM` in the database during a DDL creation sequence now takes schema name into account. Fixes: #4416 Change-Id: I8cf03069e10b12f409e9b6796e24fc5850979955
* Modernize cx_Oracle parametersMike Bayer2018-11-151-1/+3
| | | | | | | | | | Updated the parameters that can be sent to the cx_Oracle DBAPI to both allow for all current parameters as well as for future parameters not added yet. In addition, removed unused parameters that were deprecated in version 1.2, and additionally we are now defaulting "threaded" to False. Fixes: #4369 Change-Id: I599668960e7b2d5bd1f5e6850e10b5b3ec215ed3
* Fix dependency_for final argumentJoe Urciuoli2018-10-011-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | Fixed issue where part of the utility language helper internals was passing the wrong kind of argument to the Python ``__import__`` builtin as the list of modules to be imported. The issue produced no symptoms within the core library but could cause issues with external applications that redefine the ``__import__`` builtin or otherwise instrument it. Pull request courtesy Joe Urciuoli. Per the submitter: "The fourth argument provided to `__import__` (which `import_` feeds in to) is supposed to be a a list of strings, but this code is passing a single string. This was causing the sqlalchemy `import_` function to break the string (for example 'interfaces') into an array of single characters ['i', 'n', ...], which causes the actual `__import__` to not find the module `sqlalchemy.orm.i` (since it's trying to import `sqlalchemy.orm.i` and `sqlalchemy.orm.n` .. etc)" No issue could be reproduced locally as it seems you can put anything non- empty/None into that last argument, even a list like ``['X']``, and all the sub-modules seem to appear. Omit it, and then the sub-modules aren't present. Perhaps it just runs the module or not if this attribute is present. Change-Id: Ia15c74620f24d24f0df4882f9b36a04e2c3725b8 Pull-request: https://github.com/zzzeek/sqlalchemy/pull/473
* Vendor python3 formatargspecMike Bayer2018-06-281-11/+11
| | | | | | | | | Replaced the usage of inspect.formatargspec() with a vendored version copied from the Python standard library, as inspect.formatargspec() is deprecated and as of Python 3.7.0 is emitting a warning. Change-Id: I751652fac7f605a3a10b547ba8c5f34fef1de945 Fixes: #4291
* happy new yearMike Bayer2018-01-121-1/+1
| | | | Change-Id: I3ef36bfd0cb0ba62b3123c8cf92370a43156cf8f
* PG dialect test fixesMike Bayer2017-10-021-0/+3
| | | | | | | | Make sure we clear the plugin registry before testing that the "postgres" name raises. Also move non-backend tests out of MiscTest into a new suite. Change-Id: Icd1bb4745aa07f52d585fcf959f76fcd8bdc7f24
* Add safe_reraise() + warnings only to Connection._autorollbackMike Bayer2017-03-271-1/+7
| | | | | | | | | | | | Added an exception handler that will warn for the "cause" exception on Py2K when the "autorollback" feature of :class:`.Connection` itself raises an exception. In Py3K, the two exceptions are naturally reported by the interpreter as one occurring during the handling of the other. This is continuing with the series of changes for rollback failure handling that were last visited as part of :ticket:`2696` in 1.0.12. Change-Id: I600ba455a14ebaea27c6189889181f97c632f179 Fixes: #3946
* New features from python 2.7Катаев Денис2017-03-171-1/+1
| | | | | | | After bump minimum supported version to 2.7 (1da9d3752160430c91534a8868ceb8c5ad1451d4), we can use new syntax. Change-Id: Ib064c75a00562e641d132f9c57e5e69744200e05 Pull-request: https://github.com/zzzeek/sqlalchemy/pull/347
* Allow SchemaType and Variant to work togetherMike Bayer2017-03-071-3/+7
| | | | | | | | | | | | | | Added support for the :class:`.Variant` and the :class:`.SchemaType` objects to be compatible with each other. That is, a variant can be created against a type like :class:`.Enum`, and the instructions to create constraints and/or database-specific type objects will propagate correctly as per the variant's dialect mapping. Also added testing for some potential double-event scenarios on TypeDecorator but it seems usually this doesn't occur. Change-Id: I4a7e7c26b4133cd14e870f5bc34a1b2f0f19a14a Fixes: #2892
* Support python3.6Mike Bayer2017-01-131-2/+2
| | | | | | | | | | | 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
* Check for __module__ not present in util.wrap_callable()Mike Bayer2016-10-141-1/+2
| | | | | | | | | The newly added wrap_callable() function assumes __module__ is present when this is not the case for objects such as functools.partial. Change-Id: Ia226260e9a65419e26d5c1f7187512f7fd4bb7c1 Fixes: #3823
* - happy new yearMike Bayer2016-01-291-1/+1
|
* - revert the change first made in a6fe4dc, as we are now generalizingMike Bayer2016-01-281-0/+7
| | | | | | | | | | | | | | | | | | | | | | | the warning here to all safe_reraise() cases in Python 2. - Revisiting :ticket:`2696`, first released in 1.0.10, which attempts to work around Python 2's lack of exception context reporting by emitting a warning for an exception that was interrupted by a second exception when attempting to roll back the already-failed transaction; this issue continues to occur for MySQL backends in conjunction with a savepoint that gets unexpectedly lost, which then causes a "no such savepoint" error when the rollback is attempted, obscuring what the original condition was. The approach has been generalized to the Core "safe reraise" function which takes place across the ORM and Core in any place that a transaction is being rolled back in response to an error which occurred trying to commit, including the context managers provided by :class:`.Session` and :class:`.Connection`, and taking place for operations such as a failure on "RELEASE SAVEPOINT". Previously, the fix was only in place for a specific path within the ORM flush/commit process; it now takes place for all transational context managers as well. fixes #2696
* Merge remote-tracking branch 'origin/pr/210'Mike Bayer2015-11-301-4/+4
|\
| * Update usages of getargspec to compat version.pr/210Jacob MacDonald2015-10-291-4/+4
| | | | | | | | | | The places inspect.getargspec was being used were causing problems for newer Python versions.
* | - convert wrap_callable() to a general purpose update_wrapper-likeMike Bayer2015-10-291-11/+7
| | | | | | | | | | | | function; the caller still passes in the "wrapper" - move tests for wrap_callable() to be generic util tests - changelog for pullreq github:204
* | - wrap ColumnDefault empty arg callables like functools.wraps, setting ↵pr/204Martin J. Hsu2015-10-151-0/+26
|/ | | | __name__, __doc__, and __module__
* - merge of ticket_3499 indexed access branchMike Bayer2015-08-171-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - The "hashable" flag on special datatypes such as :class:`.postgresql.ARRAY`, :class:`.postgresql.JSON` and :class:`.postgresql.HSTORE` is now set to False, which allows these types to be fetchable in ORM queries that include entities within the row. fixes #3499 - The Postgresql :class:`.postgresql.ARRAY` type now supports multidimensional indexed access, e.g. expressions such as ``somecol[5][6]`` without any need for explicit casts or type coercions, provided that the :paramref:`.postgresql.ARRAY.dimensions` parameter is set to the desired number of dimensions. fixes #3487 - The return type for the :class:`.postgresql.JSON` and :class:`.postgresql.JSONB` when using indexed access has been fixed to work like Postgresql itself, and returns an expression that itself is of type :class:`.postgresql.JSON` or :class:`.postgresql.JSONB`. Previously, the accessor would return :class:`.NullType` which disallowed subsequent JSON-like operators to be used. part of fixes #3503 - The :class:`.postgresql.JSON`, :class:`.postgresql.JSONB` and :class:`.postgresql.HSTORE` datatypes now allow full control over the return type from an indexed textual access operation, either ``column[someindex].astext`` for a JSON type or ``column[someindex]`` for an HSTORE type, via the :paramref:`.postgresql.JSON.astext_type` and :paramref:`.postgresql.HSTORE.text_type` parameters. also part of fixes #3503 - The :attr:`.postgresql.JSON.Comparator.astext` modifier no longer calls upon :meth:`.ColumnElement.cast` implicitly, as PG's JSON/JSONB types allow cross-casting between each other as well. Code that makes use of :meth:`.ColumnElement.cast` on JSON indexed access, e.g. ``col[someindex].cast(Integer)``, will need to be changed to call :attr:`.postgresql.JSON.Comparator.astext` explicitly. This is part of the refactor in references #3503 for consistency in operator use.
* - Fixed an issue where a particular base class within utilsMike Bayer2015-07-201-0/+2
| | | | | | | | | didn't implement ``__slots__``, and therefore meant all subclasses of that class didn't either, negating the rationale for ``__slots__`` to be in use. Didn't cause any issue except on IronPython which apparently does not implement ``__slots__`` behavior compatibly with cPython. Fixes #3494
* - Fixed an internal "memoization" routine for method types suchMike Bayer2015-06-081-21/+9
| | | | | that a Python descriptor is no longer used; repairs inspectability of these methods including support for Sphinx documentation.
* - The warning emitted by the unicode type for a non-unicode typeMike Bayer2015-03-311-3/+6
| | | | | | | | | | | | has been liberalized to warn for values that aren't even string values, such as integers; previously, the updated warning system of 1.0 made use of string formatting operations which would raise an internal TypeError. While these cases should ideally raise totally, some backends like SQLite and MySQL do accept them and are potentially in use by legacy code, not to mention that they will always pass through if unicode conversion is turned off for the target backend. fixes #3346
* - copyright 2015Mike Bayer2015-03-101-1/+1
|
* - Custom dialects that implement :class:`.GenericTypeCompiler` canMike Bayer2015-01-161-0/+27
| | | | | | | | | | | | | | 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
* - add MemoizedSlots, a generalized solution to using __getattr__Mike Bayer2015-01-051-0/+43
| | | | | for memoization on a class that uses slots. - apply many more __slots__. mem use for nova now at 46% savings
* - use a different bitwise approach here that doesn't require iteratingMike Bayer2015-01-031-0/+9
| | | | through all possible set values
* - The :class:`.mysql.SET` type has been overhauled to no longerMike Bayer2015-01-031-2/+2
| | | | | | | | | | | | | | 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
* Maul the evaulate & friends typoPriit Laes2014-12-191-1/+1
|
* - The ``__module__`` attribute is now set for all those SQL andMike Bayer2014-10-141-1/+3
| | | | | | | ORM functions that are derived as "public factory" symbols, which should assist with documentation tools being able to report on the target module. fixes #3218
* Merge remote-tracking branch 'origin/pr/140' into pr140Mike Bayer2014-10-111-3/+3
|\
| * cleanup exception handling - use new exception hierarchy (since python 2.5)pr/140ndparker2014-10-021-9/+3
| |
| * improve exception vs. exit handlingndparker2014-09-231-0/+6
| |
* | - refactor of declarative, break up into indiviudal methodsMike Bayer2014-09-251-1/+14
|/ | | | | | | | | | | | | | | | | | | | | | | that are now affixed to _MapperConfig - declarative now creates column copies ahead of time so that they are ready to go for a declared_attr - overhaul of declared_attr; memoization, cascading modifier - A relationship set up with :class:`.declared_attr` on a :class:`.AbstractConcreteBase` base class will now be configured on the abstract base mapping automatically, in addition to being set up on descendant concrete classes as usual. fixes #2670 - The :class:`.declared_attr` construct has newly improved behaviors and features in conjunction with declarative. The decorated function will now have access to the final column copies present on the local mixin when invoked, and will also be invoked exactly once for each mapped class, the returned result being memoized. A new modifier :attr:`.declared_attr.cascading` is added as well. fixes #3150 - the original plan for #3150 has been scaled back; by copying mixin columns up front and memoizing, we don't actually need the "map properties later" thing. - full docs + migration notes
* - The :func:`~.expression.column` and :func:`~.expression.table`Mike Bayer2014-09-011-4/+4
| | | | | | | | | | | | | | | | | | | | | constructs are now importable from the "from sqlalchemy" namespace, just like every other Core construct. - The implicit conversion of strings to :func:`.text` constructs when passed to most builder methods of :func:`.select` as well as :class:`.Query` now emits a warning with just the plain string sent. The textual conversion still proceeds normally, however. The only method that accepts a string without a warning are the "label reference" methods like order_by(), group_by(); these functions will now at compile time attempt to resolve a single string argument to a column or label expression present in the selectable; if none is located, the expression still renders, but you get the warning again. The rationale here is that the implicit conversion from string to text is more unexpected than not these days, and it is better that the user send more direction to the Core / ORM when passing a raw string as to what direction should be taken. Core/ORM tutorials have been updated to go more in depth as to how text is handled. fixes #2992
* - A new style of warning can be emitted which will "filter" up toMike Bayer2014-08-311-10/+41
| | | | | | | | | N occurrences of a parameterized string. This allows parameterized warnings that can refer to their arguments to be delivered a fixed number of times until allowing Python warning filters to squelch them, and prevents memory from growing unbounded within Python's warning registries. fixes #3178
* - major refactoring/inlining to loader.instances(), though not reallyMike Bayer2014-08-281-0/+8
| | | | | | | | | | | any speed improvements :(. code is in a much better place to be run into C, however - The ``proc()`` callable passed to the ``create_row_processor()`` method of custom :class:`.Bundle` classes now accepts only a single "row" argument. - Deprecated event hooks removed: ``populate_instance``, ``create_instance``, ``translate_row``, ``append_result`` - the getter() idea is somewhat restored; see ref #3175
* - The ``info`` parameter has been added to the constructor forMike Bayer2014-08-131-1/+3
| | | | | | | | | | | :class:`.SynonymProperty` and :class:`.ComparableProperty`. - The ``info`` parameter has been added as a constructor argument to all schema constructs including :class:`.MetaData`, :class:`.Index`, :class:`.ForeignKey`, :class:`.ForeignKeyConstraint`, :class:`.UniqueConstraint`, :class:`.PrimaryKeyConstraint`, :class:`.CheckConstraint`. fixes #2963
* - apply pep8 formatting to sqlalchemy/sql, sqlalchemy/util, sqlalchemy/dialects,Brian Jarrett2014-07-201-44/+61
| | | | sqlalchemy/orm, sqlalchemy/event, sqlalchemy/testing
* - break up the <authors> copyright comment as part of a passMike Bayer2014-07-091-1/+2
| | | | to get all flake8 passing
* Fix many typos throughout the codebasepr/85Alex Gaynor2014-04-261-1/+1
| | | | Found using: https://github.com/intgr/topy
* - Added a new keyword argument ``once=True`` to :func:`.event.listen`Mike Bayer2014-03-111-1/+1
| | | | | and :func:`.event.listens_for`. This is a convenience feature which will wrap the given listener such that it is only invoked once.
* - Support has been added for pytest to run tests. This runnerMike Bayer2014-03-031-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | is currently being supported in addition to nose, and will likely be preferred to nose going forward. The nose plugin system used by SQLAlchemy has been split out so that it works under pytest as well. There are no plans to drop support for nose at the moment and we hope that the test suite itself can continue to remain as agnostic of testing platform as possible. See the file README.unittests.rst for updated information on running tests with pytest. The test plugin system has also been enhanced to support running tests against mutiple database URLs at once, by specifying the ``--db`` and/or ``--dburi`` flags multiple times. This does not run the entire test suite for each database, but instead allows test cases that are specific to certain backends make use of that backend as the test is run. When using pytest as the test runner, the system will also run specific test suites multiple times, once for each database, particularly those tests within the "dialect suite". The plan is that the enhanced system will also be used by Alembic, and allow Alembic to run migration operation tests against multiple backends in one run, including third-party backends not included within Alembic itself. Third party dialects and extensions are also encouraged to standardize on SQLAlchemy's test suite as a basis; see the file README.dialects.rst for background on building out from SQLAlchemy's test platform.
* - get util.get_callable_argspec() to be completely bulletproof for 2.6-3.4,Mike Bayer2014-03-021-11/+33
| | | | | methods, classes, builtins, functools.partial(), everything known so far - use get_callable_argspec() within ColumnDefault._maybe_wrap_callable, re: #2979
* - Fixed some test/feature failures occurring in Python 3.4,Mike Bayer2014-03-021-7/+7
| | | | | | in particular the logic used to wrap "column default" callables wouldn't work properly for Python built-ins. fixes #2979
* - implement kwarg validation and type system for dialect-specificMike Bayer2014-01-181-1/+1
| | | | | arguments; [ticket:2866] - add dialect specific kwarg functionality to ForeignKeyConstraint, ForeignKey
* - happy new yearMike Bayer2014-01-051-1/+1
|
* - Fixed regression where using a ``functools.partial()`` with the eventMike Bayer2014-01-041-1/+3
| | | | | | | | | | | system would cause a recursion overflow due to usage of inspect.getargspec() on it in order to detect a legacy calling signature for certain events, and apparently there's no way to do this with a partial object. Instead we skip the legacy check and assume the modern style; the check itself now only occurs for the SessionEvents.after_bulk_update and SessionEvents.after_bulk_delete events. Those two events will require the new signature style if assigned to a "partial" event listener. [ticket:2905]