Skip to content
This repository has been archived by the owner on May 5, 2024. It is now read-only.

Commit

Permalink
fix: correct LogicalTypeId enum name
Browse files Browse the repository at this point in the history
  • Loading branch information
Mause committed Nov 9, 2022
1 parent 8505aae commit 9dbebbb
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/constants.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::duckly::*;

#[derive(Debug, Eq, PartialEq, num_derive::FromPrimitive)]
pub enum DuckDBType {
pub enum LogicalTypeId {
Boolean = DUCKDB_TYPE_DUCKDB_TYPE_BOOLEAN as isize,
Tinyint = DUCKDB_TYPE_DUCKDB_TYPE_TINYINT as isize,
Smallint = DUCKDB_TYPE_DUCKDB_TYPE_SMALLINT as isize,
Expand Down
2 changes: 1 addition & 1 deletion src/data_chunk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ mod test {
#[test]
fn test_data_chunk_construction() {
let dc = DataChunk::new(vec![LogicalType::new(
crate::constants::DuckDBType::Integer,
crate::constants::LogicalTypeId::Integer,
)]);

assert_eq!(dc.get_column_count(), 1);
Expand Down
14 changes: 7 additions & 7 deletions src/logical_type.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::constants::DuckDBType;
use crate::constants::LogicalTypeId;
use crate::duckly::{
duckdb_create_list_type, duckdb_create_logical_type, duckdb_create_map_type,
duckdb_destroy_logical_type, duckdb_get_type_id, duckdb_logical_type,
Expand All @@ -11,7 +11,7 @@ pub struct LogicalType {
}

impl LogicalType {
pub fn new(typ: DuckDBType) -> Self {
pub fn new(typ: LogicalTypeId) -> Self {
unsafe {
Self {
typ: duckdb_create_logical_type(typ as u32),
Expand Down Expand Up @@ -50,7 +50,7 @@ impl LogicalType {
///
/// # Arguments
/// * `returns`: The type id
pub fn type_id(&self) -> DuckDBType {
pub fn type_id(&self) -> LogicalTypeId {
let id = unsafe { duckdb_get_type_id(self.typ) };

FromPrimitive::from_u32(id).unwrap()
Expand Down Expand Up @@ -80,16 +80,16 @@ impl Drop for LogicalType {

#[cfg(test)]
mod test {
use crate::constants::DuckDBType;
use crate::constants::LogicalTypeId;
use crate::LogicalType;
#[test]
fn test_logi() {
let key = LogicalType::new(DuckDBType::Varchar);
let key = LogicalType::new(LogicalTypeId::Varchar);

let value = LogicalType::new(DuckDBType::Utinyint);
let value = LogicalType::new(LogicalTypeId::Utinyint);

let map = LogicalType::new_map_type(&key, &value);

assert_eq!(map.type_id(), DuckDBType::Map);
assert_eq!(map.type_id(), LogicalTypeId::Map);
}
}
6 changes: 3 additions & 3 deletions src/test_integration.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::constants::DuckDBType;
use crate::constants::LogicalTypeId;
use crate::database::Database;
use crate::duckly::{
duckdb_bind_info, duckdb_data_chunk, duckdb_function_info, duckdb_init_info, duckdb_query,
Expand Down Expand Up @@ -53,7 +53,7 @@ unsafe extern "C" fn init(info: duckdb_init_info) {
unsafe extern "C" fn bind(info: duckdb_bind_info) {
let info = BindInfo::from(info);

info.add_result_column("column0", LogicalType::new(DuckDBType::Varchar));
info.add_result_column("column0", LogicalType::new(LogicalTypeId::Varchar));

let param = info.get_parameter(0).get_varchar();

Expand All @@ -67,7 +67,7 @@ fn test_database_creation() -> Result<(), Box<dyn Error>> {

let table_function = TableFunction::default();
table_function
.add_parameter(&LogicalType::new(DuckDBType::Json))
.add_parameter(&LogicalType::new(LogicalTypeId::Json))
.set_name("read_json")
.supports_pushdown(false)
.set_function(Some(func))
Expand Down

0 comments on commit 9dbebbb

Please sign in to comment.