I'm sure this is user error, but I'm having a surprising issue using 
generated columns.

In short I can't save a record after creating it, because Sequel is trying 
to write back the generated column, which is not allowed. The exception 
looks like this:

.../sequel-5.48.0/lib/sequel/adapters/postgres.rb:156:in `exec': 
PG::SyntaxError: ERROR:  column "full_name" can only be updated to DEFAULT 
(Sequel::DatabaseError)
DETAIL:  Column "full_name" is a generated column.

As you can guess from the error I have a user column with a first_name and 
last_name column, and a generated column full_name. 

That was created via this line in the table creation:

column      :full_name,   String,     generated_always_as: 
Sequel[:first_name] + ' ' + Sequel[:last_name], generated_type: :stored

This works perfectly, except that after records are created they can't be 
saved... The code below is enough to trigger the error.

user = User.first! email: 'f...@bar.com'
user.save

I'm guessing there's some configuration I need to do on the model to tell 
it not to write the full_name column, but I haven't been able to figure it 
out yet. Any help is appreciated :)

Thank you!
- Andrew

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sequel-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/d9396bdc-f96b-4826-82c1-0c8cf5b95732n%40googlegroups.com.

Reply via email to