On Sunday, January 27, 2013 9:04:20 AM UTC-8, rlf wrote:
> Hello.
>
> I'm trying to save new rows in a table with a virtual column.
> Although I never try to set the column value (obviously), it is failing
> when I create/save:
>
> "Sequel::DatabaseError: OCIError: ORA-54013: INSERT operation disallowed
> on virtual columns".
>
> At first look it would appear as though the SQL might be trying to insert
> a null into the pseudo-column.
>
> I'm rather new to Sequel, and I imagine there's a way around it, but I
> couldn't find an answer on my own.
>
I'm not familiar with Oracle virtual columns, but I'm guessing you can work
around the issue by adding the following to the model:
def before_save
@virtual_column_name = values.delete(:virtual_column_name)
super
end
def virtual_column_name
values.fetch(:virtual_column_name, @virtual_column_name)
end
Basically, you need to make sure that the :virtual_column_name entry is not
part of the values hash, that should make the saving code no longer attempt
to use it in INSERT/UPDATE statements. The other code is just so calling
the virtual_column_name method on the object still works correctly after
saving.
Sequel is a Tremendous piece of work, btw.
>
Thanks!
Jeremy
--
You received this message because you are subscribed to the Google Groups
"sequel-talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
Visit this group at http://groups.google.com/group/sequel-talk?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.