-
-
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_dims #4190
Merged
Merged
implement array_dims #4190
Changes from 5 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
9c25091
implement array_dims
27bc1d6
fixed doc test
d580610
Revert "fixed doc test"
bf30144
fixed doc test
f7a7f62
doctest fix
1e3b9d7
fixed doc test and added new doc tests for None
02c080c
doctest fix
d02ecb4
implement array_dims
10ab6bd
fixed doc test
3e17a01
Revert "fixed doc test"
7ed50b5
fixed doc test
144a765
doctest fix
d301cf9
fixed doc test and added new doc tests for None
04c6dac
doctest fix
03b996e
implement array_dims
eeb3f9b
fixed doc test
c23160b
Revert "fixed doc test"
a0de4ea
fixed doc test
930759e
doctest fix
b828950
fixed doc test and added new doc tests for None
f091f57
doctest fix
08c7ec1
resolved conflicts
949ba5e
Merge branch 'feat/add/array_dims' of github.com:valkrypton/diesel in…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -748,3 +748,34 @@ define_sql_function! { | |
/// ``` | ||
fn array_append<Arr: ArrayOrNullableArray<Inner=T> + SingleValue, T: SingleValue>(a: Arr, e: T) -> Array<T>; | ||
} | ||
|
||
#[cfg(feature = "postgres_backend")] | ||
define_sql_function! { | ||
/// Returns a text representation of the array's dimensions | ||
/// | ||
/// # Example | ||
/// | ||
/// ```rust | ||
/// # include!("../../doctest_setup.rs"); | ||
/// # | ||
/// # fn main(){ | ||
/// # run_test().unwrap(); | ||
/// # } | ||
/// # fn run_test()->QueryResult<()>{ | ||
/// # use diesel::dsl::array_dims; | ||
/// # use diesel::sql_types::{Nullable,Array,Integer}; | ||
/// # let connection = &mut establish_connection(); | ||
/// | ||
/// let dims = diesel::select(array_dims::<Array<_>,_,_>(vec![1,2])) | ||
/// .get_result::<String>(connection).unwrap(); | ||
/// assert!(String::from("[1:2]").eq(&dims)); | ||
/// | ||
/// let dims = diesel::select(array_dims::<Array<_>,_,_>(vec![vec![1,2,3],vec![4,5,6]])) | ||
/// .get_result::<String>(connection).unwrap(); | ||
/// assert!(String::from("[1:2][1:3]").eq(&dims)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The crazy error here say that diesel didn't know how to transform |
||
/// | ||
/// # Ok(()) | ||
/// # } | ||
/// | ||
fn array_dims<Arr:ArrayOrNullableArray<Inner=T> + SingleValue,T:SingleValue>(arr:Arr) -> Text; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
The error says that rust don't know with implementation use, this
i32
could beInt4
,Int8
or something else, to fix you need to specify the type here. Thearray_append
doesn't need this because it Array inner type is the same of the second argument, and the second argument is specifiedThere 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.
Thanks for the help!