Skip to content

Commit

Permalink
Custom blob subtypes
Browse files Browse the repository at this point in the history
Support for custom blob subtypes added.

Blob subtypes supported now:
- 1: TEXT
- 0: binary
- <= -1: custom

Issue #146
  • Loading branch information
fernandobatels committed Oct 11, 2023
1 parent f7b007e commit 4c728cc
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
7 changes: 4 additions & 3 deletions rsfbclient-native/src/row.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,17 @@ impl ColumnBuffer {
Boolean(Box::new(0))
}

// BLOB sql_type text are considered a normal text on read
ibase::SQL_BLOB if (sqlsubtype == 0 || sqlsubtype == 1) => {
ibase::SQL_BLOB if (sqlsubtype <= 1) => {
let blob_id = Box::new(ibase::GDS_QUAD_t {
gds_quad_high: 0,
gds_quad_low: 0,
});

var.sqltype = ibase::SQL_BLOB as i16 + 1;

if sqlsubtype == 0 {
// subtype 0: binary
// subtype <= -1: custom
if sqlsubtype <= 0 {
BlobBinary(blob_id)
} else {
BlobText(blob_id)
Expand Down
2 changes: 1 addition & 1 deletion rsfbclient-rust/src/xsqlda.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ impl XSqlVar {
self.sqltype = ibase::SQL_TIMESTAMP as i16 + 1;
}

ibase::SQL_BLOB if (sqlsubtype == 0 || sqlsubtype == 1) => {
ibase::SQL_BLOB if (sqlsubtype <= 1) => {
self.sqltype = ibase::SQL_BLOB as i16 + 1;
}

Expand Down
12 changes: 12 additions & 0 deletions src/tests/row.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,18 @@ mk_tests_default! {
Ok(())
}

#[test]
fn blob_custom_subtype() -> Result<(), FbError> {
let mut conn = cbuilder().connect()?;

let (a,): (Option<Vec<u8>>,) = conn.query_first("select cast(null as blob SUB_TYPE -1) from rdb$database;", ())?
.unwrap();

assert_eq!(None, a);

Ok(())
}

#[test]
fn dates() -> Result<(), FbError> {
let mut conn = cbuilder().connect()?;
Expand Down

0 comments on commit 4c728cc

Please sign in to comment.