Search code examples
rubysequel

Sequel gem update Clob field issue


I use Oracle database to store information about courses.
I have Course model

class Course < Sequel::Model
  set_dataset Sequel.lit(TABLE_NAME_HERE)
  set_primary_key :offer_rk
end

Each course has a description which can have more than 4000 length.
So I have been forced to set type of description column to Clob.

In my code I have something like

course.update description: large_text_here

Unfortunately it raises an error

OCIError: ORA-01704: string literal too long

Seems like Sequel saves description as ordinary String not as Clob value.

What should I do to save large text in Clob field correctly?

Should I patch this method somehow?

module Sequel
  module JDBC
    module Oracle
      module DatabaseMethods
        def schema_column_type(db_type)
        end
      end
    end
  end
end

Thank you.


Solution

  • Try using the prepared_statements plugin: Course.plugin :prepared_statements