Title: Using custom db_class alters global state and subsequent uses fail for db_class=None · Issue #2 · apache/casbin-python-sqlalchemy-adapter · GitHub
Open Graph Title: Using custom db_class alters global state and subsequent uses fail for db_class=None · Issue #2 · apache/casbin-python-sqlalchemy-adapter
X Title: Using custom db_class alters global state and subsequent uses fail for db_class=None · Issue #2 · apache/casbin-python-sqlalchemy-adapter
Description: See comments in the code below: import casbin_sqlalchemy_adapter import sqlalchemy from sqlalchemy import Column, Integer, String ENGINE = sqlalchemy.create_engine("foo") CUSTOM_SCHEMA = "custom_schema" class Base(sqlalchemy.orm.Declarat...
Open Graph Description: See comments in the code below: import casbin_sqlalchemy_adapter import sqlalchemy from sqlalchemy import Column, Integer, String ENGINE = sqlalchemy.create_engine("foo") CUSTOM_SCHEMA = "custom_sc...
X Description: See comments in the code below: import casbin_sqlalchemy_adapter import sqlalchemy from sqlalchemy import Column, Integer, String ENGINE = sqlalchemy.create_engine("foo") CUSTOM_SCHEMA = ...
Opengraph URL: https://github.com/apache/casbin-python-sqlalchemy-adapter/issues/2
X: @github
Domain: github.com
IPv4 address: 140.82.114.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Using custom db_class alters global state and subsequent uses fail for db_class=None","articleBody":"See comments in the code below:\n\n```py\nimport casbin_sqlalchemy_adapter\nimport sqlalchemy\nfrom sqlalchemy import Column, Integer, String\n\nENGINE = sqlalchemy.create_engine(\"foo\")\n\nCUSTOM_SCHEMA = \"custom_schema\"\n\n\nclass Base(sqlalchemy.orm.DeclarativeBase):\n pass\n\n\nclass CustomCasbinRule(Base):\n \"\"\"Class we use instead of casbin_sqlalchemy_adapter.CasbinRule, so we can set the right metadata.\"\"\"\n\n __tablename__ = \"casbin_rule_abc\"\n\n metadata = sqlalchemy.MetaData(schema=CUSTOM_SCHEMA)\n\n id = Column(Integer, primary_key=True)\n ptype = Column(String(255))\n v0 = Column(String(255))\n v1 = Column(String(255))\n v2 = Column(String(255))\n v3 = Column(String(255))\n v4 = Column(String(255))\n v5 = Column(String(255))\n\n def __str__(self):\n arr = [str(self.ptype)]\n for v in (self.v0, self.v1, self.v2, self.v3, self.v4, self.v5):\n if v is None:\n break\n arr.append(str(v))\n return \", \".join(arr)\n\n def __repr__(self):\n return f'\u003cCustomCasbinRule {self.id}: \"{self}\">'\n\n\ncasbin_sqlalchemy_adapter.Adapter(ENGINE, db_class=CustomCasbinRule)\n\n# At this point the `casbin_sqlalchemy_adapter.Base.metadata` is altered, and following code will create\n# the table in \"custom_schema\" as well, which is unexpected and can cause issues.\n\ncasbin_sqlalchemy_adapter.Adapter(ENGINE)\n```\n\n@mick-graft","author":{"url":"https://github.com/hsluoyz","@type":"Person","name":"hsluoyz"},"datePublished":"2025-08-09T08:48:40Z","url":"https://github.com/apache/casbin-python-sqlalchemy-adapter/issues/2"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| 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:c886c67e-af14-1e89-c811-0268cbef150a |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B61A:C4ED3:1CEBD8:269C74:6B04B3D3 |
| html-safe-nonce | 1e2541a625a8b87a2b43d94b42fbf2748a63b1e71b9f730ec2479ee84b8060ff |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCNjFBOkM0RUQzOjFDRUJEODoyNjlDNzQ6NkIwNEIzRDMiLCJ2aXNpdG9yX2lkIjoiMTYzMTQ2MjE1NDAyMjcyODY1OSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | a622323947c092950449df5c5548d29d570060eeb2f7eaf21545a1481c64d505 |
| hovercard-subject-tag | issue:3306117378 |
| 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/apache/casbin-python-sqlalchemy-adapter/2/issue_layout |
| twitter:image | https://opengraph.githubassets.com/dcfa3ceb85ae29339774b7f948d60d8726748bcd2bb2fd11d34ac1f2c0818574/apache/casbin-python-sqlalchemy-adapter/issues/2 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/dcfa3ceb85ae29339774b7f948d60d8726748bcd2bb2fd11d34ac1f2c0818574/apache/casbin-python-sqlalchemy-adapter/issues/2 |
| og:image:alt | See comments in the code below: import casbin_sqlalchemy_adapter import sqlalchemy from sqlalchemy import Column, Integer, String ENGINE = sqlalchemy.create_engine("foo") CUSTOM_SCHEMA = "custom_sc... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | hsluoyz |
| hostname | github.com |
| expected-hostname | github.com |
| None | 378bd702ac792b3550e484ad39d9a898fcd25bb52ba6962b0c9cc457c1ea71c7 |
| turbo-cache-control | no-preview |
| go-import | github.com/apache/casbin-python-sqlalchemy-adapter git https://github.com/apache/casbin-python-sqlalchemy-adapter.git |
| octolytics-dimension-user_id | 47359 |
| octolytics-dimension-user_login | apache |
| octolytics-dimension-repository_id | 878922594 |
| octolytics-dimension-repository_nwo | apache/casbin-python-sqlalchemy-adapter |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 878922594 |
| octolytics-dimension-repository_network_root_nwo | apache/casbin-python-sqlalchemy-adapter |
| 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 | b032e77f1ea437ede6c115446a0a467709b468e7 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width