Comments (4)
Thanks for your reply and feedback! I unfortunately am also pretty busy at the moment so I won't be able to look at this either for the time being.
For anyone who might be trying to a create many-to-many association table and need to save it with achemy dumps, I came up with a workaround for that specific case. I created a mapped class that would create a table with the same shape that I needed. That way alchemy dumps will pick it up since it will be enumerated as a subclass of db.Model.
For example:
user_to_project_table = db.Table(
'user_to_project',
Base.metadata,
db.Column('user_id', db.ForeignKey('user.id'), primary_key=True),
db.Column('project_id', db.ForeignKey('project.id'), primary_key=True)
)
Becomes something like:
class UserToProjectTable(db.Model):
__tablename__ = 'user_to_project'
user_id = db.Column('user_id', db.ForeignKey('user.id'), primary_key=True)
project_id = db.Column('project_id', db.ForeignKey('project.id'), primary_key=True)
Then in your classes where you declare the relationship, the relationship's 'secondary' property can be assigned the string 'user_to_project' instead of user_to_project_table.
from alchemydumps.
This seems to be because the base declarative class's subclasses are the only things enumerated when creating dumps, which will result in missing other data.
That's completely true, @baumatron. You've found a huge bug.
Unfortunately, I cannot take a look on these issues this soon because things are kind of hectic here the following weeks.
However, feel free to send e PR if you want to give it a try.
Usually I follow a TDD (test-driven development) approach:
- Add the missing models at
tests/app.py
(e.g. many-to-many relationships this time) - Write tests for the new models at
tests/test_commands.py
- Fix the package ; )
- Add the novelties to the
README.md
from alchemydumps.
Many thanks again @baumatron!
I edited your last comment just to add Python color to the code bits, ok?
from alchemydumps.
Perfect, thanks for making that more readable.
from alchemydumps.
Related Issues (20)
- Could not create. python manage.py dumps create HOT 14
- Dumps might fail if tables are empty
- Problems using vsftpd as ftp-server HOT 6
- Use of deprecated library import HOT 7
- sqlalchemy.exc.InvalidRequestError: SQL expression, column, or mapped entity expected - got '<class 'flask_sqlalchemy.Model'>'
- I am willing to take over this package ..... HOT 6
- Licensing Request HOT 1
- Export to different extensions HOT 1
- .ext. Deprecated HOT 1
- Export to S3
- Fix CI
- alchemydumps not registered as flask subcommand HOT 5
- Can you call the backup within Flask directly ? HOT 4
- Can you add support for Flask 2.x? HOT 3
- Re-add Coveralls
- python3 support
- Multiple models with abstract (not working) HOT 4
- Allow usage with app factory pattern HOT 3
- problem with windows path HOT 4
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 alchemydumps.