From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: onlinejudge95@gmail.com
Subject: BUG #16407: Column mismatch
Date: Fri, 01 May 2020 14:38:34 +0000
Message-ID: <16407-0650de12983d6b3b@postgresql.org> (raw)
The following bug has been logged on the website:
Bug reference: 16407
Logged by: onlinejudge95
Email address: onlinejudge95@gmail.com
PostgreSQL version: 12.2
Operating system: Docker
Description:
I have a flask app that connects to a Postgres DB and stores the user info
there.
For local development purposes, I am using docker to bring up 2 containers
one my app and the other of Postgres.
In my models, I am defining my primary key as a column named id
class User(db.Model):
__tablename__ = "users"
_id = db.Column(UUID(as_uuid=True), primary_key=True, unique=True,
nullable=False,)
username = db.Column(db.String(128), nullable=False)
email = db.Column(db.String(128), nullable=False)
def __init__(self, username, email):
self._id = uuid.uuid4().hex
self.username = username
self.email = email
Everything works fine in my local system when I use this Dockerfile
FROM postgres:12.2
LABEL maintainer="onlinejudge95"
COPY configs/db.sql /docker-entrypoint-initdb.d/
But while deploying to Heroku and using the Postgre image there, I receive
the following errors on any operation that queries my DB.
sqlalchemy.exc.ProgrammingError: (psycopg2.errors.UndefinedColumn) column
users.id does not exist
So I decided to change my models to use _id instead of id, this change seems
to work fine.
Is this a known discrepancy?
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-bugs@postgresql.org
Cc: noreply@postgresql.org, pgsql-bugs@lists.postgresql.org, onlinejudge95@gmail.com
Subject: Re: BUG #16407: Column mismatch
In-Reply-To: <16407-0650de12983d6b3b@postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox