diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2022-01-02 17:35:43 -0500 | 
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2022-01-12 10:29:30 -0500 | 
| commit | 43f6ae639ca0186f4802255861acdc20f19e702f (patch) | |
| tree | 311d908ba5b72b0fcb751d682f56ccd73710d41b /lib/sqlalchemy/dialects/mysql/dml.py | |
| parent | a869dc8fe3cd579ed9bab665d215a6c3e3d8a4ca (diff) | |
| download | sqlalchemy-43f6ae639ca0186f4802255861acdc20f19e702f.tar.gz | |
initial reorganize for static typing
start applying foundational annotations to key
elements.
two main elements addressed here:
1. removal of public_factory() and replacement with
   explicit functions.  this just works much better with
   typing.
2. typing support for column expressions and operators.
   The biggest part of this involves stubbing out all the
   ColumnOperators methods under ColumnElement in a
   TYPE_CHECKING section.  Took me a while to see this
   method vs. much more complicated things I thought
   I needed.
Also for this version implementing #7519, ColumnElement
types against the Python type and not TypeEngine.  it is
hoped this leads to easier transferrence between ORM/Core
as well as eventual support for result set typing.
Not clear yet how well this approach will work and what
new issues it may introduce.
given the current approach we now get full, rich typing for
scenarios like this:
from sqlalchemy import column, Integer, String, Boolean
c1 = column('a', String)
c2 = column('a', Integer)
expr1 = c2.in_([1, 2, 3])
expr2 = c2 / 5
expr3 = -c2
expr4_a = ~(c2 == 5)
expr4_b = ~column('q', Boolean)
expr5 = c1 + 'x'
expr6 = c2 + 10
Fixes: #7519
Fixes: #6810
Change-Id: I078d9f57955549f6f7868314287175f6c61c44cb
Diffstat (limited to 'lib/sqlalchemy/dialects/mysql/dml.py')
| -rw-r--r-- | lib/sqlalchemy/dialects/mysql/dml.py | 25 | 
1 files changed, 19 insertions, 6 deletions
diff --git a/lib/sqlalchemy/dialects/mysql/dml.py b/lib/sqlalchemy/dialects/mysql/dml.py index a21d49e0b..eb4a9f798 100644 --- a/lib/sqlalchemy/dialects/mysql/dml.py +++ b/lib/sqlalchemy/dialects/mysql/dml.py @@ -14,12 +14,30 @@ from ...sql.base import ColumnCollection  from ...sql.dml import Insert as StandardInsert  from ...sql.elements import ClauseElement  from ...sql.expression import alias -from ...util.langhelpers import public_factory  __all__ = ("Insert", "insert") +def insert(table): +    """Construct a MySQL/MariaDB-specific variant :class:`_mysql.Insert` +    construct. + +    .. container:: inherited_member + +        The :func:`sqlalchemy.dialects.mysql.insert` function creates +        a :class:`sqlalchemy.dialects.mysql.Insert`.  This class is based +        on the dialect-agnostic :class:`_sql.Insert` construct which may +        be constructed using the :func:`_sql.insert` function in +        SQLAlchemy Core. + +    The :class:`_mysql.Insert` construct includes additional methods +    :meth:`_mysql.Insert.on_duplicate_key_update`. + +    """ +    return Insert(table) + +  SelfInsert = typing.TypeVar("SelfInsert", bound="Insert") @@ -145,11 +163,6 @@ class Insert(StandardInsert):          return self -insert = public_factory( -    Insert, ".dialects.mysql.insert", ".dialects.mysql.Insert" -) - -  class OnDuplicateClause(ClauseElement):      __visit_name__ = "on_duplicate_key_update"  | 
