This adjusts the _DMLOnlyColumnArgument type to be a more
focused _OnlyColumnArgument type where we also add a more tightly
focused coercion, while still allowing ORM attributes to be used
as arguments.
Co-authored-by: Mike Bayer <mike_mp@zzzcomputing.com>
Closes: #13012
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/13012
Pull-request-sha: 5ebb402c68
Change-Id: I8bbccaf556ec5ecb2f5cfdd2030bcfa4eb5ce125
Fixed typing issue where :meth:`.Select.with_for_update` would not support
lists of ORM entities in the :paramref:`.Select.with_for_update.of`
parameter. Pull request courtesy Shamil.
Fixes: #12730Closes: #12988
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/12988
Pull-request-sha: 41a38bfe38
Change-Id: I61d60a4f4d2b16037da8d5f30e33f5d74fa47374
Fixed typing issue where :class:`.coalesce` would not return the correct
return type when a nullable form of that argument were passed, even though
this function is meant to select the non-null entry among possibly null
arguments. Pull request courtesy Yannick PÉROUX.
Closes: #12963
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/12963
Pull-request-sha: 05d0d9784d
Change-Id: Ife83a384ea57faf446c1fdb542df14627348f40f
Added support for the SQL ``CREATE TABLE ... AS SELECT`` construct via the
new :class:`_sql.CreateTableAs` DDL construct and the
:meth:`_sql.SelectBase.into` method. The new construct allows creating a
table directly from the results of a SELECT statement, with support for
options such as ``TEMPORARY`` and ``IF NOT EXISTS`` where supported by the
target database. Pull request courtesy Greg Jarzab.
Fixes: #4950Closes: #12860
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/12860
Pull-request-sha: 7de8a109b8
Change-Id: Id9c8e4a3c520ffc61de1e48e331b6220e3d52fc9
Added support for the pow operator (``**``), with a default SQL
implementation of the ``POW()`` function. On Oracle Database, PostgreSQL
and MSSQL it renders as ``POWER()``. As part of this change, the operator
routes through a new first class ``func`` member :class:`_functions.pow`,
which renders on Oracle Database, PostgreSQL and MSSQL as ``POWER()``.
Fixes: #8579Closes: #8580
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/8580
Pull-request-sha: 041b2ef474
Change-Id: I371bd44ed3e58f2d55ef705aeec7d04710c97f23
try again to remove the overloads to the generic functionn
generator (like coalesce, array_agg, etc).
As of mypy 1.15 it still does now work, but a simpler version
is added in this change
Change-Id: I8b97ae00298ec6f6bf8580090e5defff71e1ceb0
The return type of `array_agg()` is declared as a `Sequence[T]` where `T` is bound to the type of input argument.
This is implemented by making `array_agg()` inheriting from `ReturnTypeFromArgs` which provides appropriate overloads of `__init__()` to support this.
This usage of ReturnTypeFromArgs is a bit different from previous ones as the return type of the function is not exactly the same as that of its arguments, but a "collection" (a generic, namely a Sequence here) of the argument types. Accordingly, we adjust the code of `tools/generate_sql_functions.py` to retrieve the "collection" type from 'fn_class' annotation and generate expected return type.
Also add a couple of hand-written typing tests for PostgreSQL.
Related to #6810Closes: #12461
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/12461
Pull-request-sha: ba27cbb863
Change-Id: I3fd538cc7092a0492c26970f0b825bf70ddb66cd
Support generic types for compound selects (:func:`_sql.union`,
:func:`_sql.union_all`, :meth:`_sql.Select.union`,
:meth:`_sql.Select.union_all`, etc) returning the type of the first select.
Fixes: #11922Closes: #12320
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/12320
Pull-request-sha: f914a19f72
Change-Id: I4fffa5d3fe93dd3a293b078360e326fea4207c5d
* Added valid types to server_onupdate and mapped_column kwargs mypy tests
* Joined mapped_column test files
* Set _ServerOnUpdateArgument to _ServerDefaultArgument
Fixes: #11546
### Description
Fixes#11328 by adding an overload to ColumnCollection when a non-None default is provided.
### Checklist
This pull request is:
- [ ] A documentation / typographical / small typing 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.
Closes: #11329
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/11329
Pull-request-sha: 32db849e0d
Change-Id: I8bef91c423fb7048ec8d4a7c99f70f0b1588c37a
Add a missing `@overload` to the `__add__` operator.
### Description
The `__add__` function is missing an overload that handles the rest of the cases, similar to the one that `__sub__` has a few lines later in the same file.
This fix is taken from https://github.com/microsoft/pyright/issues/7743
### Checklist
This pull request is:
- [x] A documentation / typographical / small typing 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: #11307
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/11307
Pull-request-sha: 961d87403a
Change-Id: I27784f79e8d4f8b7f09b17060186916c78cba0a3
The :class:`.Row` object now no longer makes use of an intermediary
``Tuple`` in order to represent its individual element types; instead,
the individual element types are present directly, via new :pep:`646`
integration, now available in more recent versions of Mypy. Mypy
1.7 or greater is now required for statements, results and rows
to be correctly typed. Pull request courtesy Yurii Karabas.
Fixes: #10635Closes: #10634
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/10634
Pull-request-sha: 430785c8a0
Change-Id: Ibd0ae31a98b4ea69dcb89f970e640920b2be6c48
### Description
The documentation and the type annotations for `TableValueType()` clearly
state that both strings and column expression arguments are accepted
but the annotation omits `str`, which is the most common use case.
### Checklist
This pull request is:
- [x] A documentation / typographical / small typing 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.
Closes: #10886
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/10886
Pull-request-sha: 624a97f051
Change-Id: I2a1d2eb9b70815c33a27dd238ff2a9f11e5f5a64
* Fixed the argument types passed to functions so that literal expressions
like strings and ints are again interpreted correctly (🎫`10818`)
this includes a reformatting of the changelog message from #10801
to read as a general "fixed regressions" list.
Fixes: #10818
Change-Id: I65ad86e096241863e833608d45f0bdb6069f5896
Further enhancements to pep-484 typing to allow SQL functions from
:attr:`_sql.func` derived elements to work more effectively with ORM-mapped
attributes.
Fixes: #10801
Change-Id: Ib8222d888a2d8c3fbeab0d1bf5edb535916d4721
This includes all methods / properties on the returned FunctionFilter
object.
This contributes towards #6810
This pull request is:
- [x] A documentation / typographical / small typing 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.
Closes: #10643
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/10643
Pull-request-sha: 6137b7b995
Change-Id: I2af1af7617d0cd3fd30b262d36ff982464bac011
Completed pep-484 typing for the ``sqlalchemy.sql.functions`` module.
:func:`_sql.select` constructs made against ``func`` elements should now
have filled-in return types.
References: #6810
Change-Id: I5121583c9c5b6f7151f811348c7a281c446cf0b8
in 6f710b393a we committed tests using lowercase ``list`` with
indexed access. use only newer Python versions for this test.
Change-Id: Icba0ef1c6b0b8e66e2d2a6c5b7e9fe86ed81deec
Fixed typing issue where the argument list passed to :class:`.Values` was
too-restrictively tied to ``List`` rather than ``Sequence``. Pull request
courtesy Iuri de Silvio.
Fixes: #10451Closes: #10452
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/10452
Pull-request-sha: 7800f0d631
Change-Id: If631455d049b2308ec42602b72a60a5ede35fa32
Repaired the core "SQL element" class ``SQLCoreOperations`` to support the
``__hash__()`` method from a typing perspective, as objects like
:class:`.Column` and ORM :class:`.InstrumentedAttribute` are hashable and
are used as dictionary keys in the public API for the :class:`_dml.Update`
and :class:`_dml.Insert` constructs. Previously, type checkers were not
aware the root SQL element was hashable.
Fixes: #10353
Change-Id: I3c8eeb7ceb29a3087596e17d09aa6a7f45a8cf99
Fixed regression introduced in 2.0.20 via 🎫`9600` fix which
attempted to add more formal typing to
:paramref:`_schema.MetaData.naming_convention`. This change prevented basic
naming convention dictionaries from passing typing and has been adjusted so
that a plain dictionary of strings for keys as well as dictionaries that
use constraint types as keys or a mix of both, are again accepted.
As part of this change, lesser used forms of the naming convention
dictionary are also typed, including that it currently allows for
``Constraint`` type objects as keys as well.
Fixes: #9284Fixes: #10264
Change-Id: Ic6561dd65058e4de3a7a393295b9863fc065db13
Typing improvements:
* :class:`.CursorResult` is returned for some forms of
:meth:`_orm.Session.execute` where DML without RETURNING is used
* fixed type for :paramref:`_orm.Query.with_for_update.of` parameter within
:meth:`_orm.Query.with_for_update`
* improvements to ``_DMLColumnArgument`` type used by some DML methods to
pass column expressions
* Add overload to :func:`_sql.literal` so that it is inferred that the
return type is ``BindParameter[NullType]`` where
:paramref:`_sql.literal.type_` param is None
* Add overloads to :meth:`_sql.ColumnElement.op` so that the inferred
type when :paramref:`_sql.ColumnElement.op.return_type` is not provided
is ``Callable[[Any], BinaryExpression[Any]]``
* Add missing overload to :meth:`_sql.ColumnElement.__add__`
Pull request courtesy Mehdi Gmira.
Fixes: #9185Closes: #10108
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/10108
Pull-request-sha: 6017526c9c
Change-Id: I77a2a199b7a8b137b405001bef8813cf2d327bca
- correctly inspect orm classes and instances
- add missing generics in run_sync on async connection and session
- minor fixes to relationship order params and shift overload
Change-Id: I9aebd3e1312bca855c8451ec0cc02a891983063f
Improved typing when using standalone operator functions from
``sqlalchemy.sql.operators`` such as ``sqlalchemy.sql.operators.eq``.
Fixes: #10054
Change-Id: I7e39cb3ccddb354a3f04f749ef65b18088e136e1
Extract a fixture to run mypy on files
Move the plain files to test/typing
Move test files from stubs repository
Transform the fixture module in a package
Change-Id: I23acaecb84e7c4b9010259d44395dc1df83a9385