Opened 7 years ago
Closed 7 years ago
#29951 closed Bug (invalid)
Object not created in the correct table with db_table=<schema>.<table> on PostgreSQL
| Reported by: | Jonathan Chao | Owned by: | nobody |
|---|---|---|---|
| Component: | Testing framework | Version: | 2.1 |
| Severity: | Normal | Keywords: | test |
| Cc: | Triage Stage: | Unreviewed | |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
I have a model that looks like
class PeopleBio(models.Model):
person_id = models.TextField()
bio = models.TextField()
class Meta:
managed = True # it's actually based on setting IS_TESTING, which is set to True in this case
db_table = '"ppl"."ppl_bio"'
When running test, I insert the object
PeopleBio.objects.create(person_id="person1", bio='test')
when using cursor.fetchall() on ppl.ppl_bio, it returns nothing. I used pdb to double check, and the test table indeed doesn't have anything in it. The Model's db_table is indeed ppl.ppl_bio, and when doing PeopleBio.objects.all(), it does return something.
All leads me to believe that the Model does not point to the right Postgres table when running test.
Change History (1)
comment:1 by , 7 years ago
| Resolution: | → invalid |
|---|---|
| Status: | new → closed |
| Summary: | Django Test Model objects creation does not get created in the right table (Postgres) → Object not created in the correct table with db_table=<schema>.<table> on PostgreSQL |
Note:
See TracTickets
for help on using tickets.
Django doesn't officially support schemas. See #6148 for that. As far as I know, the
<schema>.<table>syntax only works on Oracle.