mirror of
https://github.com/jeffknupp/sandman2.git
synced 2026-04-25 00:25:49 +03:00
[GH-ISSUE #71] Automapper gives errors on database unless prepare() is configured differently #48
Labels
No labels
bug
duplicate
enhancement
help wanted
invalid
pull-request
question
refactoring
research
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/sandman2-jeffknupp#48
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @samuller on GitHub (Jun 20, 2018).
Original GitHub issue: https://github.com/jeffknupp/sandman2/issues/71
When running
sandman2ctl, I got the following errors:Which I could fix, but then I also got (and fixed) this:
While SQLAlchemy's automapper is probably capable of mapping any type of schema, it seems that some weird edge cases can cause issues when only using AutomapModel's default naming conventions.
For our Postgresql database it seems there were issues when:
To get it working in our case I had to change
app._reflect_all()to use the following:This does have some side effects such as a "Tbl" prefix for foreign key columns in the admin interface, but at least it works.
Hopefully there's a cleaner way to handle this use case automatically, but even an option with some configuration through the CLI would be helpful.
@jeffknupp commented on GitHub (Jun 22, 2018):
Yep, the problem is obvious but the
tbl_solution will break other things as the user can refer to the tables (really, the classes) discovered byAutomapModel.prepareto do things like exclude tables from the API or make them read-only, so even adding it as a command-line flag could create problems (or at the very least a lot of confusion). I'll try to create a test database that has models/tables with the properties you listed and see if I can figure out anything else (I've used the code you pasted from SO in the past for similar issues).