Skip to content

Ordering team by name ascending except for 'Owners' #48

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

Merged
merged 4 commits into from
Nov 6, 2016
Merged

Ordering team by name ascending except for 'Owners' #48

merged 4 commits into from
Nov 6, 2016

Conversation

thibaultmeyer
Copy link
Contributor

Relative to the issue #3841, this pull request force team names to be ascending ordered. Owners is now always on top of the list.

Tested on MySQL 5, PostgreSQL 9 ans SQlite 3

image

Copy link
Member

@DblK DblK left a comment

Choose a reason for hiding this comment

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

Everything is good except padding because of GoFMT that should have removed necessary padding spaces

@@ -495,7 +495,7 @@ func (org *User) GetUserRepositories(userID int64, page, pageSize int) ([]*Repos
repos := make([]*Repository, 0, pageSize)
// FIXME: use XORM chain operations instead of raw SQL.
if err = x.Sql(fmt.Sprintf(`SELECT repository.* FROM repository
INNER JOIN team_repo
INNER JOIN team_repo
Copy link
Member

Choose a reason for hiding this comment

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

Need to test it but I think the space should stay.

Copy link
Contributor Author

@thibaultmeyer thibaultmeyer Nov 3, 2016

Choose a reason for hiding this comment

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

no problem, the query still working cause SQL threat \n like space. You can see other files where space has been trimmed and the query still working

@@ -507,7 +507,7 @@ func (org *User) GetUserRepositories(userID int64, page, pageSize int) ([]*Repos
}

results, err := x.Query(fmt.Sprintf(`SELECT repository.id FROM repository
INNER JOIN team_repo
INNER JOIN team_repo
Copy link
Member

Choose a reason for hiding this comment

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

Same here about the pending space since the SQL Query is multi-lines

Copy link
Contributor Author

@thibaultmeyer thibaultmeyer Nov 3, 2016

Choose a reason for hiding this comment

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

no problem, the query still working cause SQL threat \n like space. You can see other files where space has been trimmed and the query still working

@@ -534,7 +534,7 @@ func (org *User) GetUserMirrorRepositories(userID int64) ([]*Repository, error)

repos := make([]*Repository, 0, 10)
if err = x.Sql(fmt.Sprintf(`SELECT repository.* FROM repository
INNER JOIN team_repo
INNER JOIN team_repo
Copy link
Member

Choose a reason for hiding this comment

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

Same here about the pending space since the SQL Query is multi-lines

Copy link
Contributor Author

@thibaultmeyer thibaultmeyer Nov 3, 2016

Choose a reason for hiding this comment

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

no problem, the query still working cause SQL threat \n like space. You can see other files where space has been trimmed and the query still working

@codecov-io
Copy link

codecov-io commented Nov 3, 2016

Current coverage is 2.18% (diff: 0.00%)

Merging #48 into master will decrease coverage by 0.02%

@@            master       #48   diff @@
========================================
  Files           31        31          
  Lines         7508      7508          
  Methods          0         0          
  Messages         0         0          
  Branches         0         0          
========================================
- Hits           166       164     -2   
- Misses        7326      7327     +1   
- Partials        16        17     +1   

Powered by Codecov. Last update a0e54c0...c595de7

@tboerger tboerger added this to the 1.0.0 milestone Nov 3, 2016
@tboerger tboerger added the type/enhancement An improvement of existing functionality label Nov 3, 2016
@tboerger
Copy link
Member

tboerger commented Nov 3, 2016

LGTM, can you please update/rebase the branch?

@thibaultmeyer
Copy link
Contributor Author

thibaultmeyer commented Nov 3, 2016

You could choose "Rebase and Merge" during the merge process : https://github.com/blog/2243-rebase-and-merge-pull-requests

@tboerger
Copy link
Member

tboerger commented Nov 3, 2016

You could choose "Rebase and Merge" during the merge process : https://github.com/blog/2243-rebase-and-merge-pull-requests

But that adds an unneeded additional commit. I prefer to have the commits rebased without any additional merge commit...

@thibaultmeyer
Copy link
Contributor Author

And what the problem ? that Git !

@tboerger
Copy link
Member

tboerger commented Nov 3, 2016

I can understand that github takes the conservative approach

@bkcsoft
Copy link
Member

bkcsoft commented Nov 4, 2016

@tboerger Rebase and Merge doesn't create additional commits. It does git rebase master && git merge <branch> master 🙂

LGTM

@@ -50,7 +50,7 @@ func (org *User) GetOwnerTeam() (*Team, error) {
}

func (org *User) getTeams(e Engine) error {
return e.Where("org_id=?", org.ID).Find(&org.Teams)
return e.Where("org_id=?", org.ID).OrderBy("CASE WHEN name LIKE '" + OWNER_TEAM + "' THEN '' ELSE name END").Find(&org.Teams)
Copy link
Contributor

Choose a reason for hiding this comment

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

Use proper SQL params instead of concatenating strings. Like this:

OrderBy("name LIKE ?", variable)

Also, why LIKE and not =?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is not possible.

image

Copy link
Contributor

Choose a reason for hiding this comment

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

OK then, I thought it was possible.

Copy link
Member

Choose a reason for hiding this comment

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

I agree it should not be LIKE but equality operator.
Is OWNER_TEAM guaranteed to be SQL-safe ? I'd feel more comfortable if we did not rely on that and use some xorm-provided quoting function, is it available @lunny ?

@andreynering
Copy link
Contributor

LGTM

@DblK DblK added the lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. label Nov 5, 2016
@strk
Copy link
Member

strk commented Nov 5, 2016

For some reason codecov/ tests are failing, not sure why. Who set those up ?

@strk
Copy link
Member

strk commented Nov 6, 2016

Beside nitpicking, better get things moved. Github did let me commit even if coverage tests were failing.
About usage of LIKE, as long as the OWNER_TEAM literal does not contain percent signs, it would be equivalent to equality

@strk strk merged commit fe8bfa5 into go-gitea:master Nov 6, 2016
@tboerger tboerger removed the lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. label Nov 11, 2016
@tboerger tboerger added the lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. label Nov 29, 2016
@go-gitea go-gitea locked and limited conversation to collaborators Nov 23, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. type/enhancement An improvement of existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants