Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom blob subtypes #147

Merged
merged 3 commits into from
Oct 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion rsfbclient-diesel/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ license = "MIT"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
diesel = { version = "2.0.0", default-features = false, features = ["chrono", "i-implement-a-third-party-backend-and-opt-into-breaking-changes"]}
diesel = { version = "=2.0.0", default-features = false, features = ["chrono", "i-implement-a-third-party-backend-and-opt-into-breaking-changes"]}
rsfbclient = { version = "0.23.0", path = "../", default-features = false }
byteorder = "1.4.3"
bytes = "1.0.1"
Expand Down
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/wire.rs
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@ pub fn parse_sql_response(
}
}

ibase::SQL_BLOB if var.sqlsubtype == 0 || var.sqlsubtype == 1 => {
ibase::SQL_BLOB if var.sqlsubtype <= 1 => {
let id = resp.get_u64()?;

let null = read_null(resp, col_index)?;
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 @@
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 Expand Up @@ -129,7 +129,7 @@
// Remove nullable type indicator
let sqltype = var.sqltype as u32 & (!1);

match sqltype as u32 {

Check warning on line 132 in rsfbclient-rust/src/xsqlda.rs

View workflow job for this annotation

GitHub Actions / clippy

casting to the same type is unnecessary (`u32` -> `u32`)

warning: casting to the same type is unnecessary (`u32` -> `u32`) --> rsfbclient-rust/src/xsqlda.rs:132:15 | 132 | match sqltype as u32 { | ^^^^^^^^^^^^^^ help: try: `sqltype` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_cast
ibase::SQL_VARYING => {
blr.put_u8(consts::blr::VARYING);
blr.put_i16_le(var.data_length);
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 @@
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 All @@ -212,7 +224,7 @@
(),
)?
.unwrap();
assert_eq!(NaiveDate::from_ymd(2010, 10, 10), a);

Check warning on line 227 in src/tests/row.rs

View workflow job for this annotation

GitHub Actions / testing (ubuntu-20.04, v3, linking)

use of deprecated associated function `chrono::NaiveDate::from_ymd`: use `from_ymd_opt()` instead

Check warning on line 227 in src/tests/row.rs

View workflow job for this annotation

GitHub Actions / testing (ubuntu-20.04, v3, dynamic_loading)

use of deprecated associated function `chrono::NaiveDate::from_ymd`: use `from_ymd_opt()` instead

Check warning on line 227 in src/tests/row.rs

View workflow job for this annotation

GitHub Actions / testing (ubuntu-20.04, v2, linking)

use of deprecated associated function `chrono::NaiveDate::from_ymd`: use `from_ymd_opt()` instead

Check warning on line 227 in src/tests/row.rs

View workflow job for this annotation

GitHub Actions / testing (ubuntu-20.04, v2, dynamic_loading)

use of deprecated associated function `chrono::NaiveDate::from_ymd`: use `from_ymd_opt()` instead

Check warning on line 227 in src/tests/row.rs

View workflow job for this annotation

GitHub Actions / testing (ubuntu-20.04, v4, linking)

use of deprecated associated function `chrono::NaiveDate::from_ymd`: use `from_ymd_opt()` instead

Check warning on line 227 in src/tests/row.rs

View workflow job for this annotation

GitHub Actions / testing (ubuntu-20.04, v4, dynamic_loading)

use of deprecated associated function `chrono::NaiveDate::from_ymd`: use `from_ymd_opt()` instead

Check warning on line 227 in src/tests/row.rs

View workflow job for this annotation

GitHub Actions / testing (windows-latest, v4, linking)

use of deprecated associated function `chrono::NaiveDate::from_ymd`: use `from_ymd_opt()` instead

Check warning on line 227 in src/tests/row.rs

View workflow job for this annotation

GitHub Actions / testing (windows-latest, v4, dynamic_loading)

use of deprecated associated function `chrono::NaiveDate::from_ymd`: use `from_ymd_opt()` instead

Check warning on line 227 in src/tests/row.rs

View workflow job for this annotation

GitHub Actions / testing (macos-latest, v3, dynamic_loading)

use of deprecated associated function `chrono::NaiveDate::from_ymd`: use `from_ymd_opt()` instead

Check warning on line 227 in src/tests/row.rs

View workflow job for this annotation

GitHub Actions / testing (ubuntu-20.04, v3, linking)

use of deprecated associated function `chrono::NaiveDate::from_ymd`: use `from_ymd_opt()` instead

Check warning on line 227 in src/tests/row.rs

View workflow job for this annotation

GitHub Actions / testing (ubuntu-20.04, v3, dynamic_loading)

use of deprecated associated function `chrono::NaiveDate::from_ymd`: use `from_ymd_opt()` instead

Check warning on line 227 in src/tests/row.rs

View workflow job for this annotation

GitHub Actions / testing (ubuntu-20.04, v2, linking)

use of deprecated associated function `chrono::NaiveDate::from_ymd`: use `from_ymd_opt()` instead

Check warning on line 227 in src/tests/row.rs

View workflow job for this annotation

GitHub Actions / testing (ubuntu-20.04, v2, dynamic_loading)

use of deprecated associated function `chrono::NaiveDate::from_ymd`: use `from_ymd_opt()` instead

Check warning on line 227 in src/tests/row.rs

View workflow job for this annotation

GitHub Actions / testing (ubuntu-20.04, v4, linking)

use of deprecated associated function `chrono::NaiveDate::from_ymd`: use `from_ymd_opt()` instead

Check warning on line 227 in src/tests/row.rs

View workflow job for this annotation

GitHub Actions / testing (ubuntu-20.04, v4, dynamic_loading)

use of deprecated associated function `chrono::NaiveDate::from_ymd`: use `from_ymd_opt()` instead

Check warning on line 227 in src/tests/row.rs

View workflow job for this annotation

GitHub Actions / testing (windows-latest, v4, linking)

use of deprecated associated function `chrono::NaiveDate::from_ymd`: use `from_ymd_opt()` instead

Check warning on line 227 in src/tests/row.rs

View workflow job for this annotation

GitHub Actions / testing (windows-latest, v4, dynamic_loading)

use of deprecated associated function `chrono::NaiveDate::from_ymd`: use `from_ymd_opt()` instead
assert_eq!(NaiveDate::from_ymd(2010, 10, 10).and_hms(10, 10, 10), b);
assert_eq!(NaiveTime::from_hms(10, 10, 10), c);

Expand Down
Loading