-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
implement array_fill #4203
implement array_fill #4203
Conversation
not sure what arguments should i pass in auto_type.rs function call |
6b7a83a
to
67df9a6
Compare
|
||
/// Return type of [`array_fill_with_lower_bound(value,array,array)`](super::functions::array_fill_with_lower_bound()) | ||
#[allow(non_camel_case_types)] | ||
#[cfg(feature = "postgres_backend")] | ||
pub type array_fill_with_lower_bound<E> = | ||
super::functions::array_fill_with_lower_bound<SqlTypeOf<E>, E, Array<Integer>, Array<Integer>>; | ||
pub type array_fill_with_lower_bound<E, A1, A2> = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure why i have to write generics here for arguments that have concrete types, but this works. An explanation would be appreciated!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
define_sql_function!
generates a function signature as follows for the array_fill
function:
fn array_fill<E: SingleValue, value: T1, dim: T2>(value: T1, dim: T2) -> _
where T1: AsExpression<E>,
T2: AsExpression<Array<Integer>>
The additional AsExpression
bounds enable diesel to accept a typed SQL expression (like for example a column) or a rust side value (for example 5
) as argument in this position.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good for me beside the minor stylistic request. (I will just apply the suggestions, no need to change anything here).
|
||
/// Return type of [`array_fill_with_lower_bound(value,array,array)`](super::functions::array_fill_with_lower_bound()) | ||
#[allow(non_camel_case_types)] | ||
#[cfg(feature = "postgres_backend")] | ||
pub type array_fill_with_lower_bound<E> = | ||
super::functions::array_fill_with_lower_bound<SqlTypeOf<E>, E, Array<Integer>, Array<Integer>>; | ||
pub type array_fill_with_lower_bound<E, A1, A2> = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
define_sql_function!
generates a function signature as follows for the array_fill
function:
fn array_fill<E: SingleValue, value: T1, dim: T2>(value: T1, dim: T2) -> _
where T1: AsExpression<E>,
T2: AsExpression<Array<Integer>>
The additional AsExpression
bounds enable diesel to accept a typed SQL expression (like for example a column) or a rust side value (for example 5
) as argument in this position.
dbec4d3
to
6e423d3
Compare
implemented array_fill under #4153