续集宝石更新Clob字段问题

时间:2016-07-12 10:14:23

标签: ruby sequel

我使用Oracle数据库存储有关课程的信息 我有public class CountingFileRequestBody extends RequestBody { private static final String TAG = "CountingFileRequestBody"; private final ProgressListener listener; private final String key; private final MultipartBody multipartBody; protected CountingSink mCountingSink; public CountingFileRequestBody(MultipartBody multipartBody, String key, ProgressListener listener) { this.multipartBody = multipartBody; this.listener = listener; this.key = key; } @Override public long contentLength() throws IOException { return multipartBody.contentLength(); } @Override public MediaType contentType() { return multipartBody.contentType(); } @Override public void writeTo(BufferedSink sink) throws IOException { mCountingSink = new CountingSink(sink); BufferedSink bufferedSink = Okio.buffer(mCountingSink); multipartBody.writeTo(bufferedSink); bufferedSink.flush(); } public interface ProgressListener { void transferred(String key, int num); } protected final class CountingSink extends ForwardingSink { private long bytesWritten = 0; public CountingSink(Sink delegate) { super(delegate); } @Override public void write(Buffer source, long byteCount) throws IOException { bytesWritten += byteCount; listener.transferred(key, (int) (100F * bytesWritten / contentLength())); super.write(source, byteCount); delegate().flush(); // I have added this line to manually flush the sink } } } 模型

Course

每门课程的描述长度超过4000 所以我被迫将class Course < Sequel::Model set_dataset Sequel.lit(TABLE_NAME_HERE) set_primary_key :offer_rk end 列的类型设置为description

在我的代码中,我有类似

的内容
Clob

不幸的是它会引发错误

course.update description: large_text_here

似乎Sequel将描述保存为普通OCIError: ORA-01704: string literal too long 而不是String值。

如何正确保存Clob字段中的大型文字?

我应该以某种方式修补此方法吗?

Clob

谢谢。

1 个答案:

答案 0 :(得分:1)

尝试使用prepared_statements插件:Course.plugin :prepared_statements