summaryrefslogtreecommitdiff
path: root/alembic/operations
diff options
context:
space:
mode:
authorJames Addison <james@reciperadar.com>2023-04-10 15:40:38 -0400
committerFederico Caselli <cfederico87@gmail.com>2023-04-12 22:36:39 +0200
commitd3f869bb3159d18669fb6f00cbe514307118eea7 (patch)
tree32b83d276b3eaf779dcea37aa1c59e0b0da5e596 /alembic/operations
parent33a9947686a7c8bb3becd6169ec7abe84cf2c7e6 (diff)
downloadalembic-d3f869bb3159d18669fb6f00cbe514307118eea7.tar.gz
tooling: write_pyi.py: filter usage of raw-strings (rstrings)
### Description While reading the diff between [`rel_1_10_2...rel_1_10_3`](https://github.com/sqlalchemy/alembic/compare/rel_1_10_2...rel_1_10_3), the introduction of r-strings drew my attention, and that resulted in some [discussion on the relevant commit](https://github.com/sqlalchemy/alembic/commit/bc0c305b7c2cc0401e250fcd6a725aacecdd6e33). This changeset filters the production of r-strings during stub-generation to cases where docstrings contain escape (backslash, `\`) characters. I'll admit that I didn't realize until today that these stubs are primarily for typechecking. Since that's the case, I have doubts about whether the change is worthwhile (consistency and simplicity -- using r-strings for all docstrings in the stubs -- even if it's redundant, seems fine to me). ### Checklist This pull request is: - [x] A documentation / typographical error fix - [x] A short code fix - Relates to discussion at https://github.com/sqlalchemy/alembic/commit/bc0c305b7c2cc0401e250fcd6a725aacecdd6e33 Closes: #1218 Pull-request: https://github.com/sqlalchemy/alembic/pull/1218 Pull-request-sha: 352ab8829525435f78838687e12156a3fa3a3d86 Closes: #1219 Pull-request: https://github.com/sqlalchemy/alembic/pull/1219 Change-Id: I2808a592681dabc093d538f589e673fcc5e05822
Diffstat (limited to 'alembic/operations')
-rw-r--r--alembic/operations/ops.py18
1 files changed, 9 insertions, 9 deletions
diff --git a/alembic/operations/ops.py b/alembic/operations/ops.py
index a40704f..789fb58 100644
--- a/alembic/operations/ops.py
+++ b/alembic/operations/ops.py
@@ -2339,14 +2339,12 @@ class ExecuteSQLOp(MigrateOperation):
from sqlalchemy import String
from alembic import op
- account = table('account',
- column('name', String)
- )
+ account = table("account", column("name", String))
op.execute(
- account.update().\\
- where(account.c.name==op.inline_literal('account 1')).\\
- values({'name':op.inline_literal('account 2')})
- )
+ account.update()
+ .where(account.c.name == op.inline_literal("account 1"))
+ .values({"name": op.inline_literal("account 2")})
+ )
Above, we made use of the SQLAlchemy
:func:`sqlalchemy.sql.expression.table` and
@@ -2370,11 +2368,13 @@ class ExecuteSQLOp(MigrateOperation):
also be used normally, use the "bind" available from the context::
from alembic import op
+
connection = op.get_bind()
connection.execute(
- account.update().where(account.c.name=='account 1').
- values({"name": "account 2"})
+ account.update()
+ .where(account.c.name == "account 1")
+ .values({"name": "account 2"})
)
Additionally, when passing the statement as a plain string, it is first