Skip to content

Commit

Permalink
boyscouts
Browse files Browse the repository at this point in the history
  • Loading branch information
pacman82 committed Mar 5, 2022
1 parent 56ad96b commit 5307ac0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
10 changes: 7 additions & 3 deletions odbc-api/src/buffers/column_with_indicator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,21 +244,25 @@ impl<'a, T> NullableSliceMut<'a, T> {
///
/// // Memcopy the values into the buffer, and set indicators according to mask
/// // values.
/// fn copy_values_and_make_mask(new_values: &[i32], mask: &[bool], odbc_slice: &mut NullableSliceMut<i32>) {
/// fn copy_values_and_make_mask(
/// new_values: &[i32],
/// mask: &[bool],
/// odbc_slice: &mut NullableSliceMut<i32>)
/// {
/// let (values, indicators) = odbc_slice.raw_values();
/// values.copy_from_slice(new_values);
/// // Create array of bools indicating null values.
/// indicators.iter_mut().zip(mask.iter()).for_each(|(indicator, &mask)| {
/// *indicator = if mask {
/// 1
/// 0
/// } else {
/// NULL_DATA
/// }
/// });
/// }
/// ```
pub fn raw_values(&mut self) -> (&mut [T], &mut [isize]) {
(&mut self.values, &mut self.indicators)
(self.values, self.indicators)
}
}

Expand Down
10 changes: 5 additions & 5 deletions odbc-api/tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -772,12 +772,12 @@ fn columnar_insert_timestamp(profile: &Profile) {

/// Insert values into a i32 column using a columnar buffer's raw values
#[test_case(MSSQL; "Microsoft SQL Server")]
// #[test_case(MARIADB; "Maria DB")] No DATEIME2 type
// #[test_case(SQLITE_3; "SQLite 3")] default precision of 3 instead 7
#[test_case(MARIADB; "Maria DB")]
#[test_case(SQLITE_3; "SQLite 3")]
fn columnar_insert_int_raw(profile: &Profile) {
let table_name = "Int";
let table_name = "ColumnarInsertIntRaw";
// Setup
let conn = profile.setup_empty_table(table_name, &["INT"]).unwrap();
let conn = profile.setup_empty_table(table_name, &["INTEGER"]).unwrap();

// Fill buffer with values
let desc = BufferDescription {
Expand All @@ -797,7 +797,7 @@ fn columnar_insert_int_raw(profile: &Profile) {
indicators
.iter_mut()
.zip(mask.iter())
.for_each(|(indicator, &mask)| *indicator = if mask { 1 } else { NULL_DATA })
.for_each(|(indicator, &mask)| *indicator = if mask { 0 } else { NULL_DATA })
} else {
panic!("Expected i32 column writer");
};
Expand Down

0 comments on commit 5307ac0

Please sign in to comment.