Building an Inventory Database with PostgreSQL backfilling problem

I am on step 3 in this project, and I am supposed to fill in the missing descriptions in a table,
empty descriptions are however not recognized as NULL objects because they are ‘space’ characters.
Now, when I use this code to fill them in:
UPDATE parts SET description = 'None available' WHERE description IS NULL OR description = ' ';
it actually deletes the rows were the description is space character (???)
Anyone had a similar problem?
When I only use WHERE descirption IS NULL it is not recognized and the table is not updated, that is my table after WHERE description = ’ ’ :


As you can see id=3 and id=9 get deleted from a table.

Can you please provide a link to the lesson?

https://www.codecademy.com/paths/full-stack-engineer-career-path/tracks/fscp-22-advanced-postgresql/modules/wdcp-22-database-intact/projects/constraints-project

Did you backfill those empty descriptions first (it’s in the hint for question 3)?

ie:

UPDATE parts
SET description = 'None Available'
WHERE description ____ ____;

I am doing it in the photo that is provided, when I dont use or equals ’ ’ it does not fill them, because they are not null, they are recognized as ascii_value 32, when I use equals ’ ’ it deletes rows. Even if i try to SET description WHERE id = 3; it gets deleted as well.

I thought the affected rows were being deleted too until I realised that they were actually just shuffled down to the bottom of the table and therefore out of the top 10 entries that we LIMIT the view to.

2 Likes

Thank you! What an amazing eye you have!

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.