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

Remove seq-macro #1699

Merged

Conversation

workingjubilee
Copy link
Member

This adds some local boilerplate but removes an external proc-macro from our build.

Copy link
Contributor

@eeeebbbbrrrr eeeebbbbrrrr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👀

Fair.

@workingjubilee workingjubilee merged commit db14f0e into pgcentralfoundation:develop May 10, 2024
12 checks passed
@workingjubilee workingjubilee deleted the remove-seq-macro branch May 10, 2024 18:23
Comment on lines +160 to +196
unsafe impl<'iter, $($C,)*> SqlTranslatable for TableIterator<'iter, ($($C,)*)>
where
$($C: SqlTranslatable + 'iter,)*
{
fn argument_sql() -> Result<SqlMapping, ArgumentError> {
Err(ArgumentError::Table)
}
fn return_sql() -> Result<Returns, ReturnsError> {
let vec = vec![
$(
match $C::return_sql() {
Ok(Returns::One(sql)) => sql,
Ok(Returns::SetOf(_)) => return Err(ReturnsError::TableContainingSetOf),
Ok(Returns::Table(_)) => return Err(ReturnsError::NestedTable),
err => return err,
},
)*
{
fn argument_sql() -> Result<SqlMapping, ArgumentError> {
Err(ArgumentError::Table)
}
fn return_sql() -> Result<Returns, ReturnsError> {
let mut vec = Vec::new();
#(
vec.push(match Input~N::return_sql() {
Ok(Returns::One(sql)) => sql,
Ok(Returns::SetOf(_)) => return Err(ReturnsError::TableContainingSetOf),
Ok(Returns::Table(_)) => return Err(ReturnsError::NestedTable),
Err(err) => return Err(err),
});
)*
Ok(Returns::Table(vec))
];
Ok(Returns::Table(vec))
}
}

impl<$($C: IntoDatum),*> IntoHeapTuple for ($($C,)*) {
unsafe fn into_heap_tuple(self, tupdesc: pg_sys::TupleDesc) -> *mut pg_sys::HeapTupleData {
// shadowing the type names with these identifiers
#[allow(nonstandard_style)]
let ($($C,)*) = self;
let datums = [$($C.into_datum(),)*];
let mut nulls = datums.map(|option| option.is_none());
let mut datums = datums.map(|option| option.unwrap_or(pg_sys::Datum::from(0)));


unsafe {
// SAFETY: Caller has asserted that `tupdesc` is valid, and we just went
// through a little bit of effort to setup properly sized arrays for
// `datums` and `nulls`
pg_sys::heap_form_tuple(tupdesc, datums.as_mut_ptr(), nulls.as_mut_ptr())
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

honestly half the reason here for this code is that both of these should be the same thing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants