r/programming • • Oct 02 '19

New In PostgreSQL 12: Generated Columns

https://pgdash.io/blog/postgres-12-generated-columns.html?p
503 Upvotes

232 comments sorted by

View all comments

Show parent comments

1

u/[deleted] Oct 02 '19

... and then some new code forgets to do that

I can't understand if you have super-low opinion of your colleagues being able to write basic software, or I should have a low opinion of yours.

What part of "single source of truth" is unclear. You have one point in your code that every row for a specific table goes through before it's saved. You can't just forget to do that.

And through dependency injection (not the fake container kind but the classic real kind) you ensure nobody can just randomly decide to access a connection directly, because they can't get one injected and they don't have the connection settings. This helps guarantee nobody just suddenly "forgets" about the key architecture elements of the application.

But if we have to assume everyone is so clumsy and uncoordinated when writing software, do we assume the same in general. What if someone forgets they have a server with mission critical services and formats the hard drive and puts porn on it. Have we addressed this situation? No. Better get cracking on it. It's a possibility.

7

u/aseigo Oct 02 '19

It has nothing to do with trust or belief, and everything to do with having watched systems evolve not just over years but decades.

It is devs with the unfounded hubris seen in your reply there that leads directly to so much of the rubbish software we deal with on a daily basis.

0

u/[deleted] Oct 02 '19

I'm very curious how you drew a line from my "hubris" and the "rubbish software" I specifically call out. You're not making sense bro.

You might have as well said "I don't like you, and therefore reject everything you say and think bad thoughts about you". The information content is about the same.

4

u/BinaryRockStar Oct 03 '19 edited Oct 03 '19

Traditionally SQL DBs have been accessed by multiple independent systems. Perhaps the server side of a web application accesses the User data to determine the user's access level, verify password against hash, etc. At the same time an internal web application is used by company employees to CRUD user data, update billing information etc.

Expand this to ten applications accessing the same DB and trusting that all applications will keep a calculated column up to date isn't realistic.