Skip to content

Commit 220c194

Browse files
author
Jim Flood
committed
Wrap BLOB function parameters in SQLite3::Blob if encoding is not available.
1 parent deecab9 commit 220c194

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

ext/sqlite3/database.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,14 @@ static VALUE sqlite3val2rb(sqlite3_value * val)
288288
which is what we want, as blobs are binary
289289
*/
290290
int len = sqlite3_value_bytes(val);
291+
#ifdef HAVE_RUBY_ENCODING_H
291292
return rb_tainted_str_new((const char *)sqlite3_value_blob(val), len);
293+
#else
294+
/* When encoding is not available, make it class SQLite3::Blob. */
295+
VALUE strargv[1];
296+
strargv[0] = rb_tainted_str_new((const char *)sqlite3_value_blob(val), len);
297+
return rb_class_new_instance(1, strargv, cSqlite3Blob);
298+
#endif
292299
break;
293300
}
294301
case SQLITE_NULL:

0 commit comments

Comments
 (0)