summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/sql/events.py
Commit message (Collapse)AuthorAgeFilesLines
* happy new year 2023Mike Bayer2023-01-031-1/+1
| | | | Change-Id: I625af65b3fb1815b1af17dc2ef47dd697fdc3fb1
* Merge "support create/drop events for all CREATE/DROP" into mainmike bayer2022-08-221-21/+118
|\
| * support create/drop events for all CREATE/DROPMike Bayer2022-08-201-21/+118
| | | | | | | | | | | | | | | | | | | | | | | | | | Implemented the DDL event hooks :meth:`.DDLEvents.before_create`, :meth:`.DDLEvents.after_create`, :meth:`.DDLEvents.before_drop`, :meth:`.DDLEvents.after_drop` for all :class:`.SchemaItem` objects that include a distinct CREATE or DROP step, when that step is invoked as a distinct SQL statement, including for :class:`.ForeignKeyConstraint`, :class:`.Sequence`, :class:`.Index`, and PostgreSQL's :class:`_postgresql.ENUM`. Fixes: #8394 Change-Id: Iee6274984e794f50103451a04d089641d6ac443a
* | remove erroneous note about future metadataMike Bayer2022-08-171-3/+0
|/ | | | | | this change was already applied Change-Id: I24cfdc1912b77f98ae6d0f3865cabd223553fc79
* pep484: schema APIMike Bayer2022-04-151-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | implement strict typing for schema.py this module has lots of public API, lots of old decisions and very hard to follow construction sequences in many cases, and is also where we get a lot of new feature requests, so strict typing should help keep things clean. among improvements here, fixed the pool .info getters and also figured out how to get ColumnCollection and related to be covariant so that we may set them up as returning Column or ColumnClause without any conflicts. DDL was affected, noting that superclasses of DDLElement (_DDLCompiles, added recently) can now be passed into "ddl_if" callables; reorganized ddl into ExecutableDDLElement as a new name for DDLElement and _DDLCompiles renamed to BaseDDLElement. setting up strict also located an API use case that is completely broken, which is connection.execute(some_default) returns a scalar value. This case has been deprecated and new paths have been set up so that connection.scalar() may be used. This likely wasn't possible in previous versions because scalar() would assume a CursorResult. The scalar() change also impacts Session as we have explicit support (since someone had reported it as a regression) for session.execute(Sequence()) to work. They will get the same deprecation message (which omits the word "Connection", just uses ".execute()" and ".scalar()") and they can then use Session.scalar() as well. Getting this to type correctly while still supporting ORM use cases required some refactoring, and I also set up a keyword only delimeter for Session.execute() and related as execution_options / bind_arguments should always be keyword only, applied these changes to AsyncSession as well. Additionally simpify Table __init__ now that we are Python 3 only, we can have positional plus explicit kwargs finally. Simplify Column.__init__ as well again taking advantage of kw only arguments. Fill in most/all __init__ methods in sqltypes.py as the constructor for types is most of the API. should likely do this for dialect-specific types as well. Apply _InfoType for all info attributes as should have been done originally and update descriptor decorators. Change-Id: I3f9f8ff3f1c8858471ff4545ac83d68c88107527
* pep484 - SQL internalsMike Bayer2022-03-241-9/+37
| | | | | | | non-strict checking for mostly internal or semi-internal code Change-Id: Ib91b47f1a8ccc15e666b94bad1ce78c4ab15b0ec
* pep-484 for sqlalchemy.event; use future annotationsMike Bayer2022-02-151-0/+2
| | | | | | | | | | __future__.annotations mode allows us to use non-string annotations for argument and return types in most cases, but more importantly it removes a large amount of runtime overhead that would be spent in evaluating the annotations. Change-Id: I2f5b6126fe0019713fc50001be3627b664019ede References: #6810
* happy new year 2022Mike Bayer2022-01-061-1/+1
| | | | Change-Id: I49abf2607e0eb0623650efdf0091b1fb3db737ea
* Fixes: #5151jonathan vanasco2021-09-271-1/+6
| | | | | | document `listen=True` on `before_create` Change-Id: I0804ee073044d879eb0decafeb1b358741d69f02
* Replace all http:// links to https://Federico Caselli2021-07-041-1/+1
| | | | | | Also replace http://pypi.python.org/pypi with https://pypi.org/project Change-Id: I84b5005c39969a82140706472989f2a30b0c7685
* Accommodate column-based naming conventions for pk constraintMike Bayer2021-02-041-0/+6
| | | | | | | | | | | | | | Repaired / implemented support for primary key constraint naming conventions that use column names/keys/etc as part of the convention. In particular, this includes that the :class:`.PrimaryKeyConstraint` object that's automatically associated with a :class:`.schema.Table` will update its name as new primary key :class:`_schema.Column` objects are added to the table and then to the constraint. Internal failure modes related to this constraint construction process including no columns present, no name present or blank name present are now accommodated. Fixes: #5919 Change-Id: Ic2800b50f4a4cd5978bec48cefea0a2e198e0123
* happy new yearMike Bayer2021-01-041-1/+1
| | | | Change-Id: Ic5bb19ca8be3cb47c95a0d3315d84cb484bac47c
* Implement `TypeEngine.as_generic`Gord Thompson2020-12-081-0/+3
| | | | | | | | | | | | | | | | | | Added :meth:`_types.TypeEngine.as_generic` to map dialect-specific types, such as :class:`sqlalchemy.dialects.mysql.INTEGER`, with the "best match" generic SQLAlchemy type, in this case :class:`_types.Integer`. Pull request courtesy Andrew Hannigan. Abstract away how we check for "overridden methods" so it is more clear what the intent is and that the methodology can be independently tested. Fixes: #5659 Closes: #5714 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5714 Pull-request-sha: 91afb9a0ba3bfa81a1ded80c025989213cf6e4eb Change-Id: Ic54d6690ecc10dc69e6e72856d5620036cea472a
* Allow MetaData as the target for column_reflect eventMike Bayer2020-11-181-11/+35
| | | | | | | | | The :meth:`_event.DDLEvents.column_reflect` event may now be applied to a :class:`_schema.MetaData` object where it will take effect for the :class:`_schema.Table` objects local to that collection. Fixes: #5712 Change-Id: I6044baa72d096ebd1fd99128270119747d1461b9
* improve column_reflect docsMike Bayer2020-11-181-40/+44
| | | | | Change-Id: I41d947e3cccb68c2d1ca811b5b2ae4b3f66409fb References: #5711
* Rename Table.tometadata to to_metadataGord Thompson2020-06-291-9/+9
| | | | | | | | | | | | | | | | Renamed the :meth:`_schema.Table.tometadata` method to :meth:`_schema.Table.to_metadata`. The previous name remains with a deprecation warning. Updated the "decorate" utility function to support decoration of functions that include non-builtins as default values. Moves test for deprecated "databases" package into test/dialect/test_deprecations.py Fixes: #5413 Fixes: #5426 Change-Id: I6ed899871c935f9e46360127c17ccb7cf97cea6e
* Run search and replace of symbolic module namesMike Bayer2020-04-141-31/+34
| | | | | | | | Replaces a wide array of Sphinx-relative doc references with an abbreviated absolute form now supported by zzzeeksphinx. Change-Id: I94bffcc3f37885ffdde6238767224296339698a2
* Deprecate plain string in execute and introduce `exec_driver_sql`Federico Caselli2020-03-211-2/+3
| | | | | | | | | | | | | | | Execution of literal sql string is deprecated in the :meth:`.Connection.execute` and a warning is raised when used stating that it will be coerced to :func:`.text` in a future release. To execute a raw sql string the new connection method :meth:`.Connection.exec_driver_sql` was added, that will retain the previous behavior, passing the string to the DBAPI driver unchanged. Usage of scalar or tuple positional parameters in :meth:`.Connection.execute` is also deprecated. Fixes: #4848 Fixes: #5178 Change-Id: I2830181054327996d594f7f0d59c157d477c3aa9
* Reorganize core event modules to avoid import cyclesMike Bayer2020-01-211-0/+285
sqlalchemy.sql.naming was causing a full import of engine due to the DDLEvents dependency. Break out pool, DDL and engine events into new modules specific to those packages; resolve some other import cycles in Core also. Change-Id: Ife8d217e58a26ab3605dd80ee70837968f957eaf