Skip to content

Commit 7c76284

Browse files
diegoimbertMaxxen
authored andcommitted
get_alias and set_alias
1 parent 38ddd42 commit 7c76284

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

crates/duckdb/src/core/logical_type.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,28 @@ impl LogicalTypeHandle {
289289
};
290290
unsafe { Self::new(c_logical_type) }
291291
}
292+
293+
/// Alias of the logical type.
294+
pub fn get_alias(&self) -> Option<String> {
295+
unsafe {
296+
let alias_ptr = duckdb_logical_type_get_alias(self.ptr);
297+
if alias_ptr.is_null() {
298+
None
299+
} else {
300+
let c_str = CString::from_raw(alias_ptr);
301+
let alias = c_str.to_str().unwrap();
302+
Some(alias.to_string())
303+
}
304+
}
305+
}
306+
307+
/// Set the alias of the logical type.
308+
pub fn set_alias(&self, alias: &str) -> () {
309+
unsafe {
310+
let alias = CString::new(alias).unwrap();
311+
duckdb_logical_type_set_alias(self.ptr, alias.as_ptr());
312+
}
313+
}
292314
}
293315

294316
#[cfg(test)]

0 commit comments

Comments
 (0)