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

implement array_dims #4190

Merged
merged 23 commits into from
Aug 23, 2024
Merged

Conversation

valkrypton
Copy link
Contributor

@valkrypton valkrypton commented Aug 22, 2024

Added support for array_dims postgres function under #4153
This is my first PR ever so I would love some poitners!

@valkrypton
Copy link
Contributor Author

I can't fix the doc test i've written. Help would be appreciated

@weiznich weiznich requested a review from a team August 22, 2024 18:43
Copy link
Contributor

@guissalustiano guissalustiano left a comment

Choose a reason for hiding this comment

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

Thanks for open the PR!

I let some comment about the errors. Could you also add a test with a None input to check it behavior? Thanks!

Comment on lines 773 to 775
/// 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));
Copy link
Contributor

@guissalustiano guissalustiano Aug 22, 2024

Choose a reason for hiding this comment

The 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 Vec<Vec<_>> to Array<_> because Diesel does not support multidimensional arrays yet. So you can remove this test for now.

/// # use diesel::sql_types::{Nullable,Array,Integer};
/// # let connection = &mut establish_connection();
///
/// let dims = diesel::select(array_dims::<Array<_>,_,_>(vec![1,2]))
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
/// let dims = diesel::select(array_dims::<Array<_>,_,_>(vec![1,2]))
/// let dims = diesel::select(array_dims::<Array<Integer>,_,_>(vec![1,2]))

The error says that rust don't know with implementation use, this i32 could be Int4, Int8 or something else, to fix you need to specify the type here. The array_append doesn't need this because it Array inner type is the same of the second argument, and the second argument is specified

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the help!

@weiznich
Copy link
Member

Thanks for working on this. The PR looks now good 👍

@weiznich weiznich added this pull request to the merge queue Aug 23, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to a conflict with the base branch Aug 23, 2024
auto-merge was automatically disabled August 23, 2024 11:10

Head branch was pushed to by a user without write access

@valkrypton
Copy link
Contributor Author

@weiznich I also resolved the conflicts and merged the branches, is that a problem?

@weiznich
Copy link
Member

@valkrypton I's fine, I just tend to resolve conflicts on accepted merge conflicts on my own to not burden contributors with the merge order.

@valkrypton
Copy link
Contributor Author

@weiznich I would love to contribute more to the repo, how do you recommend I start learning about Diesel internals?

@weiznich weiznich added this pull request to the merge queue Aug 23, 2024
@weiznich
Copy link
Member

@valkrypton Well the best way to learn about internals is to contribute and ask questions as soon as you hit a problem. It is also usful to join the reviewers teams (see #1186) and read code written by others. That is often an excellent place to learn more about how others approach certain problems and you often get explanations there on how certain things are implemented.

Merged via the queue into diesel-rs:master with commit 6db1ada Aug 23, 2024
48 checks passed
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.

3 participants