pygame / pygameweb

🎮🕸️ pygame.org website. Python, PostgreSQL, Flask, sqlalchemy, JS.
https://www.pygame.org/
BSD 2-Clause "Simplified" License
120 stars 30 forks source link

Can't add tags to projects #99

Open gacheiro opened 4 years ago

gacheiro commented 4 years ago

When I try to add one or more tags to a project, I get:

sqlalchemy.exc.IntegrityError: (psycopg2.errors.NotNullViolation) null value in column "id" violates not-null constraint
DETAIL:  Failing row contains (2, puzzle, null).

[SQL: INSERT INTO tags (project_id, value) VALUES (%(project_id)s, %(value)s) RETURNING tags.id]
[parameters: {'project_id': 2, 'value': 'puzzle'}]
(Background on this error at: http://sqlalche.me/e/13/gkpj)

This seems to be raised by the following code, in pygameweb.project.views line 326:

...
tag = Tags(project=project, value=value)
current_session.add(tag)
...
current_session.commit()

Postgres should autogenerate the id, but it doesn't. The above code passes in tests, so it might be a problem with the migrations.

Edit: Steps to reproduce

illume commented 4 years ago

Seems to be when projects are added without an image, but with tags. There's a PR in progress here: https://github.com/pygame/pygameweb/pull/100

gacheiro commented 4 years ago

@illume, seems to me that this is not the case, as the test added in #100 doesn't fail. Unless I forgot something?

I made some test locally and I still get the same error with and without providing an image. Just added steps to reproduce section, so hopefully someone can try to reproduce it?