From 6ed493cdb285c0d1e29dd7a711e2b6b00f6ba045 Mon Sep 17 00:00:00 2001 From: Markus Klein Date: Sat, 16 Dec 2023 17:58:48 +0100 Subject: [PATCH] use quirks provided by odbc_api --- Cargo.toml | 2 +- Changelog.md | 4 ++++ src/lib.rs | 2 -- src/quirks.rs | 34 ---------------------------------- src/reader.rs | 14 +++++--------- src/reader/odbc_reader.rs | 4 ++-- src/reader/to_record_batch.rs | 4 ++-- tests/integration.rs | 4 ++-- 8 files changed, 16 insertions(+), 52 deletions(-) delete mode 100644 src/quirks.rs diff --git a/Cargo.toml b/Cargo.toml index c7a07ce..96a1327 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -39,7 +39,7 @@ thiserror = "1.0.49" # features implying the use of UTF-16 for queries, connection strings and error messages. This # should work on any system [target.'cfg(target_os = "windows")'.dependencies] -odbc-api = ">= 4, < 5" +odbc-api = ">= 4.1, < 5" # On linux we assume use of a UTF-8 locale. So we set the narrow features implying that for queries, # connection strings and error messages the driver and driver manager supply utf8-strings. This diff --git a/Changelog.md b/Changelog.md index 0b1201b..7d10b51 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,9 @@ # Changelog +## 4.0.1 + +* Update odbc-api `>= 4, < 5` -> `>= 4.1, < 5` + ## 4.0.0 * Update odbc-api `>= 2.2, < 4` -> `>= 4, < 5` diff --git a/src/lib.rs b/src/lib.rs index 829d8a4..2457309 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -45,7 +45,6 @@ mod date_time; mod decimal; mod error; mod odbc_writer; -mod quirks; mod reader; mod schema; @@ -57,7 +56,6 @@ pub use odbc_api; pub use self::{ error::Error, odbc_writer::{insert_into_table, insert_statement_from_schema, OdbcWriter, WriterError}, - quirks::Quirks, reader::{ BufferAllocationOptions, ColumnFailure, ConcurrentOdbcReader, OdbcReader, OdbcReaderBuilder, }, diff --git a/src/quirks.rs b/src/quirks.rs deleted file mode 100644 index 21fc6ff..0000000 --- a/src/quirks.rs +++ /dev/null @@ -1,34 +0,0 @@ -/// A (non exhaustive) description of the non ODBC API conformant behavior of ODBC drivers. -/// Workarounds which are intended to help application developers seperate between the descision of -/// how to deal with non conformity from the knowledge which driver behaves weird in exactly which -/// way. -/// -/// For example it wants to avoid an if statement specifying "if the database is DB2 please use -/// terminating zeroes instead of indiactors to determine string lengths" and seperate this into -/// "IBM DB2 returns memory garbage for indicators" and another part of the application decides, -/// this is how I deal with memory garbage indicicators. -#[non_exhaustive] -#[derive(Clone, PartialEq, Eq)] -pub struct Quirks { - /// IBM DB2 has been observered that the length indicators returned from memory are garbage for - /// strings. It seems to be preferable to rely on the terminating zero exclusively to determine - /// string length. This behavior seems to so far only manifest with variadic string fields. - /// See: and also - /// - pub indicators_returned_from_bulk_fetch_are_memory_garbage: bool, -} - -impl Quirks { - /// A new instance describing an ODBC driver without quirks - pub fn new() -> Self { - Quirks { - indicators_returned_from_bulk_fetch_are_memory_garbage: false, - } - } -} - -impl Default for Quirks { - fn default() -> Self { - Self::new() - } -} diff --git a/src/reader.rs b/src/reader.rs index a462bee..6904447 100644 --- a/src/reader.rs +++ b/src/reader.rs @@ -12,7 +12,7 @@ use arrow::{ use log::debug; use odbc_api::{ buffers::{AnySlice, BufferDesc, Item}, - Bit, DataType as OdbcDataType, ResultSetMetadata, + Bit, DataType as OdbcDataType, ResultSetMetadata, Quirks, }; use thiserror::Error; @@ -25,19 +25,15 @@ mod odbc_reader; mod text; mod to_record_batch; -use self::{decimal::Decimal, map_odbc_to_arrow::MapOdbcToArrow}; - -use crate::{ - date_time::{ - days_since_epoch, ms_since_epoch, ns_since_epoch, seconds_since_epoch, us_since_epoch, - }, - Quirks, +use crate::date_time::{ + days_since_epoch, ms_since_epoch, ns_since_epoch, seconds_since_epoch, us_since_epoch, }; pub use self::{ binary::{Binary, FixedSizedBinary}, concurrent_odbc_reader::ConcurrentOdbcReader, - map_odbc_to_arrow::MappingError, + decimal::Decimal, + map_odbc_to_arrow::{MapOdbcToArrow, MappingError}, odbc_reader::{OdbcReader, OdbcReaderBuilder}, text::choose_text_strategy, }; diff --git a/src/reader/odbc_reader.rs b/src/reader/odbc_reader.rs index 41c026f..54ddea0 100644 --- a/src/reader/odbc_reader.rs +++ b/src/reader/odbc_reader.rs @@ -5,9 +5,9 @@ use arrow::{ error::ArrowError, record_batch::{RecordBatch, RecordBatchReader}, }; -use odbc_api::{buffers::ColumnarAnyBuffer, BlockCursor, Cursor}; +use odbc_api::{buffers::ColumnarAnyBuffer, BlockCursor, Cursor, Quirks}; -use crate::{BufferAllocationOptions, ConcurrentOdbcReader, Error, Quirks}; +use crate::{BufferAllocationOptions, ConcurrentOdbcReader, Error}; use super::{odbc_batch_stream::OdbcBatchStream, to_record_batch::ToRecordBatch}; diff --git a/src/reader/to_record_batch.rs b/src/reader/to_record_batch.rs index 3558d96..a9a0dc0 100644 --- a/src/reader/to_record_batch.rs +++ b/src/reader/to_record_batch.rs @@ -5,9 +5,9 @@ use arrow::{ record_batch::RecordBatch, }; use log::info; -use odbc_api::{buffers::ColumnarAnyBuffer, ResultSetMetadata}; +use odbc_api::{buffers::ColumnarAnyBuffer, ResultSetMetadata, Quirks}; -use crate::{arrow_schema_from, BufferAllocationOptions, ColumnFailure, Error, Quirks}; +use crate::{arrow_schema_from, BufferAllocationOptions, ColumnFailure, Error}; use super::{choose_column_strategy, MappingError, ReadStrategy}; diff --git a/tests/integration.rs b/tests/integration.rs index eb4f0d3..3abb831 100644 --- a/tests/integration.rs +++ b/tests/integration.rs @@ -30,10 +30,10 @@ use arrow_odbc::{ odbc_api::{ buffers::TextRowSet, sys::{AttrConnectionPooling, AttrCpMatch}, - Connection, ConnectionOptions, Cursor, CursorImpl, Environment, IntoParameter, + Connection, ConnectionOptions, Cursor, CursorImpl, Environment, IntoParameter, Quirks, StatementConnection, }, - ColumnFailure, Error, OdbcReaderBuilder, OdbcWriter, Quirks, WriterError, + ColumnFailure, Error, OdbcReaderBuilder, OdbcWriter, WriterError, }; use stdext::function_name;