Comments (5)
Do you mind sharing a minimum reproducible snippet?
from sqlalchemy-mixins.
It works in #108 with both alternatives: with declarative_base and with class Base(DeclarativeBase)
from sqlalchemy-mixins.
v2.0.4
should now be live
from sqlalchemy-mixins.
Sure!
This fails with
SQLAlchemy==2.0.19 and sqlalchemy-mixins==2.0.3
from sqlalchemy.orm import declarative_base
from sqlalchemy import Column, Integer
from sqlalchemy_mixins import AllFeaturesMixin
Base = declarative_base()
class MyOtherBaseClass(Base, AllFeaturesMixin):
__abstract__ = True
class MyBaseClass(MyOtherBaseClass):
__abstract__ = True
class Test(MyBaseClass):
__tablename__ = 'test'
id = Column(Integer(), primary_key=True)
Traceback (most recent call last):
File "scratch_25.py", line 12, in <module>
class Test(MyBaseClass):
File "/venv38/lib/python3.8/site-packages/sqlalchemy/orm/decl_api.py", line 195, in __init__
_as_declarative(reg, cls, dict_)
File "/venv38/lib/python3.8/site-packages/sqlalchemy/orm/decl_base.py", line 247, in _as_declarative
return _MapperConfig.setup_mapping(registry, cls, dict_, None, {})
File "/venv38/lib/python3.8/site-packages/sqlalchemy/orm/decl_base.py", line 328, in setup_mapping
return _ClassScanMapperConfig(
File "/venv38/lib/python3.8/site-packages/sqlalchemy/orm/decl_base.py", line 520, in __init__
super().__init__(registry, cls_, mapper_kw)
File "/venv38/lib/python3.8/site-packages/sqlalchemy/orm/decl_base.py", line 344, in __init__
instrumentation.register_class(
File "/venv38/lib/python3.8/site-packages/sqlalchemy/orm/instrumentation.py", line 684, in register_class
manager._update_state(
File "/venv38/lib/python3.8/site-packages/sqlalchemy/orm/instrumentation.py", line 209, in _update_state
registry._add_manager(self)
File "/venv38/lib/python3.8/site-packages/sqlalchemy/orm/decl_api.py", line 1380, in _add_manager
raise exc.ArgumentError(
sqlalchemy.exc.ArgumentError: Class '<class '__main__.Test'>' already has a primary mapper defined.
If I edit the script to use:
from sqlalchemy.orm import DeclarativeBase
class Base(DeclarativeBase):
pass
instead of declarative_base() it seems to work
from sqlalchemy-mixins.
@federicoemartinez Do you mind testing against #108 ?
from sqlalchemy-mixins.
Related Issues (20)
- Add Support Async HOT 7
- How to select specific fields? HOT 1
- TypeError: metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases HOT 6
- [Question] Support for 2.0 style querying HOT 1
- Explicit imports
- save from Activerecord can commit external transactions HOT 3
- [Question] Latest version is not available yet ? HOT 3
- Why does the TimestampsMixin not enable timezones? HOT 2
- FastAPI Sqlalchemy - *** AttributeError: 'generator' object has no attribute 'query' HOT 1
- SqlAlchemy 1.4 deprecation warning HOT 1
- Relationship exclude to serializate HOT 2
- Datetime or Time Format
- Pass relationship values to update method HOT 1
- Smart query - ability to add custom data types
- How to cover the original model by TimestampsMixin? HOT 3
- Imperative mode HOT 2
- Adapt to sqlalchemy 2.0? HOT 4
- Project status? HOT 1
- Setup confusion, using declarative_base() HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sqlalchemy-mixins.