jabber1111
jabber1111

Reputation: 65

psql update timestamp to nil

I'm trying to update timestamp to nil, as my codebase tests for user.last_seen.nil? so I want to be able to reset my test users last_seen table value to nil. I've tried the following, where 'users' is my table. This correctly updates the last_seen field to current time.

UPDATE users SET last_seen = current_timestamp WHERE '[email protected]' = email;

If I try:

    UPDATE users SET last_seen = nil WHERE '[email protected]' = email;

however I get the error: ERROR: column "nil" does not exist

I've tried this 10 different ways and can't get it to update.

Any thoughts? Thanks

Upvotes: 0

Views: 34

Answers (1)

coreyward
coreyward

Reputation: 80090

Postgres, like most RDBMS's, uses null, not nil. If you update your query like so it'll work:

UPDATE users SET last_seen = null WHERE '[email protected]' = email;

Upvotes: 3

Related Questions