We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
primary_key
Playing around with Ormar, I found that model inheritance wasn't working as expected.
class BaseMeta(ormar.ModelMeta): database = database metadata = metadata class BaseModel(ormar.Model): class Meta: abstract = True id: uuid.UUID = ormar.UUID( primary_key=True, default=uuid.uuid4, uuid_format="string" ) created_at: datetime.datetime = ormar.DateTime(default=datetime.datetime.utcnow()) updated_at: datetime.datetime = ormar.DateTime(default=datetime.datetime.utcnow()) class Member(BaseModel): class Meta(BaseMeta): tablename = "members" first_name: str = ormar.String(max_length=50) last_name: str = ormar.String(max_length=50)
If i run await Member.objects.create(first_name="foo", last_name="bar") i got the following error:
await Member.objects.create(first_name="foo", last_name="bar")
asyncpg.exceptions.NotNullViolationError: null value in column "id" of relation "members" violates not-null constraint DETAIL: Failing row contains (null, 2021-06-24 18:15:38.164825, 2021-06-24 18:15:38.164956, foo, bar).
How do I get this example working?
ormar 0.10.12 databases 0.4.3 psycopg2 2.9.1
The text was updated successfully, but these errors were encountered:
I don't know if that helps, but Alembic is properly generating the tables from the inherited model example.
def upgrade(): # ### commands auto generated by Alembic - please adjust! ### op.create_table('members', sa.Column('id', sa.CHAR(36), nullable=False), sa.Column('created_at', sa.DateTime(), nullable=True), sa.Column('updated_at', sa.DateTime(), nullable=True), sa.Column('first_name', sa.String(length=50), nullable=False), sa.Column('last_name', sa.String(length=50), nullable=False), sa.PrimaryKeyConstraint('id') ) # ### end Alembic commands ###
Sorry, something went wrong.
Fixed in 0.10.13 (via #254), please update and check again. Thanks for reporting!
It works now as expected, thanks a lot!
No branches or pull requests
Playing around with Ormar, I found that model inheritance wasn't working as expected.
If i run
await Member.objects.create(first_name="foo", last_name="bar")
i got the following error:How do I get this example working?
ormar 0.10.12
databases 0.4.3
psycopg2 2.9.1
The text was updated successfully, but these errors were encountered: