Title: alembic incompatibility with sqlalchemy < 1.3.11 due to computed columns · Issue #269 · googleapis/python-spanner-sqlalchemy · GitHub
Open Graph Title: alembic incompatibility with sqlalchemy < 1.3.11 due to computed columns · Issue #269 · googleapis/python-spanner-sqlalchemy
X Title: alembic incompatibility with sqlalchemy < 1.3.11 due to computed columns · Issue #269 · googleapis/python-spanner-sqlalchemy
Description: Environment details Programming language: python OS: macos Language runtime version: 3.7.14 Package version: sqlalchemy-spanner 1.3.2, sqlalchemy 1.2.12, alembic 0.9.3 Steps to reproduce install any sqlalchemy version under 1.3.11 run an...
Open Graph Description: Environment details Programming language: python OS: macos Language runtime version: 3.7.14 Package version: sqlalchemy-spanner 1.3.2, sqlalchemy 1.2.12, alembic 0.9.3 Steps to reproduce install an...
X Description: Environment details Programming language: python OS: macos Language runtime version: 3.7.14 Package version: sqlalchemy-spanner 1.3.2, sqlalchemy 1.2.12, alembic 0.9.3 Steps to reproduce install an...
Opengraph URL: https://github.com/googleapis/python-spanner-sqlalchemy/issues/269
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"alembic incompatibility with sqlalchemy \u003c 1.3.11 due to computed columns","articleBody":"#### Environment details\r\n\r\n - Programming language: python\r\n - OS: macos\r\n - Language runtime version: 3.7.14 \r\n - Package version: sqlalchemy-spanner 1.3.2, sqlalchemy 1.2.12, alembic 0.9.3\r\n\r\n#### Steps to reproduce\r\n\r\n 1. install any sqlalchemy version under 1.3.11\r\n 2. run any alembic migration \r\n \r\nEasy way to try this using the existing tests--in the [migration_test function](https://github.com/googleapis/python-spanner-sqlalchemy/blob/main/noxfile.py#L225) in noxfile.py, add \r\n\r\n```session.run(\"pip\", \"install\", \"sqlalchemy\u003e=1.1.13,\u003c=1.3.10\", \"--force-reinstall\")```\r\n\r\n at the beginning after the imports to force install the sqlalchemy versions with the incompatibilities. Then run the tests using `nox -s migration_test`. In `alembic upgrade head`, and the following error should occur:\r\n\r\n```\r\n\u003cremoved\u003e\r\n File \"google/cloud/sqlalchemy_spanner/sqlalchemy_spanner.py\", line 352, in get_column_specification\r\n if column.computed is not None:\r\n File \"nox/migration_test/lib/python3.8/site-packages/sqlalchemy/sql/elements.py\", line 690, in __getattr__\r\n key)\r\nAttributeError: Neither 'Column' object nor 'Comparator' object has an attribute 'computed'\r\n```\r\n\r\nThis is because the sqlalchemy_spanner alembic code [here](https://github.com/googleapis/python-spanner-sqlalchemy/blob/main/google/cloud/sqlalchemy_spanner/sqlalchemy_spanner.py#L352-L353) refers to the `computed` attribute of `Column`, which was introduced in sqlalchemy 1.3.11 ([release notes](https://github.com/sqlalchemy/sqlalchemy/releases/tag/rel_1_3_11), [code ref](https://github.com/sqlalchemy/sqlalchemy/compare/rel_1_3_10...rel_1_3_11#diff-04bfd5c1f4dc2b278cac4df823a4dca6fbb03a1c16d8dc7bb88714cf3858bce3R1347)). So, for sqlalchemy versions \u003c 1.3.11, this will throw the `AttributeError` above since `Column`s don't have the computed attribute. \r\n\r\nA simple but maybe hacky fix would be to just check if the attribute exists before accessing it:\r\n\r\nNew version\r\n```\r\nif hasattr(column, \"computed\") and column.computed is not None:\r\n colspec += \" \" + self.process(column.computed)\r\n```\r\n\r\nOld version\r\n```\r\nif column.computed is not None:\r\n colspec += \" \" + self.process(column.computed)\r\n```\r\n\r\nbut definitely open to suggestions for how to fix this! ","author":{"url":"https://github.com/elainearbaugh","@type":"Person","name":"elainearbaugh"},"datePublished":"2022-10-13T21:55:02.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/269/python-spanner-sqlalchemy/issues/269"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:e19900fc-3a38-33c1-5aa1-41f8c71b2717 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 95F0:2C03D:74F5118:A432606:6A4FDF78 |
| html-safe-nonce | 3a1d79fafffb7ffd916a1d133969e410cec53a5231bdd5d265edd8d1e5e26d00 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5NUYwOjJDMDNEOjc0RjUxMTg6QTQzMjYwNjo2QTRGREY3OCIsInZpc2l0b3JfaWQiOiIzNzQ1ODIwMTIzNzExMTM1NjA4IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 33c1d7a164c9595a31e78a52562d8779695a423ce59ccf441bbd6e3b33151c1f |
| hovercard-subject-tag | issue:1408469901 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/googleapis/python-spanner-sqlalchemy/269/issue_layout |
| twitter:image | https://opengraph.githubassets.com/7531cde24b648abac67321bbada08d8eb4db1bd362585022081d7b8ab30d13cb/googleapis/python-spanner-sqlalchemy/issues/269 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/7531cde24b648abac67321bbada08d8eb4db1bd362585022081d7b8ab30d13cb/googleapis/python-spanner-sqlalchemy/issues/269 |
| og:image:alt | Environment details Programming language: python OS: macos Language runtime version: 3.7.14 Package version: sqlalchemy-spanner 1.3.2, sqlalchemy 1.2.12, alembic 0.9.3 Steps to reproduce install an... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | elainearbaugh |
| hostname | github.com |
| expected-hostname | github.com |
| None | 19b98c3d9767bb8a56238a89ff8401d1cbdf3bc5c353799aacf49fe6c76b4b7c |
| turbo-cache-control | no-preview |
| go-import | github.com/googleapis/python-spanner-sqlalchemy git https://github.com/googleapis/python-spanner-sqlalchemy.git |
| octolytics-dimension-user_id | 16785467 |
| octolytics-dimension-user_login | googleapis |
| octolytics-dimension-repository_id | 335511641 |
| octolytics-dimension-repository_nwo | googleapis/python-spanner-sqlalchemy |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 335511641 |
| octolytics-dimension-repository_network_root_nwo | googleapis/python-spanner-sqlalchemy |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 142593e66413bbae27fd485859993597d5a3b104 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width