That did the trick, thank you!!

On Thursday, October 28, 2021 at 6:57:45 PM UTC-5 [email protected] 
wrote:

> You want the skip_saving_columns plugin. It should handle this for you 
> automatically.
>
>
> https://sequel.jeremyevans.net/rdoc-plugins/classes/Sequel/Plugins/SkipSavingColumns.html
>
> Adam
>
> Sent from my iPhone
>
> On Oct 28, 2021, at 7:18 PM, Andrew Burleson <[email protected]> wrote:
>
> 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: '[email protected]'
> 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 [email protected].
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/sequel-talk/d9396bdc-f96b-4826-82c1-0c8cf5b95732n%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/sequel-talk/d9396bdc-f96b-4826-82c1-0c8cf5b95732n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
>

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/f3604adb-c2ae-4262-ac13-032b02ce4a9bn%40googlegroups.com.

Reply via email to