diff --git a/Makefile b/Makefile index 0fab05560..e6efdd2a0 100644 --- a/Makefile +++ b/Makefile @@ -13,8 +13,9 @@ test: go test -cover -short ./... test_mysql: - mysql -P 3306 --protocol=tcp -u root -e 'create database test;' + mysql -P 3306 --protocol=tcp -u root -e 'create database if not exists test;' TEST_DRIVER="mysql" TEST_DATASOURCE="root@tcp(127.0.0.1:3306)/test" go test -short github.com/drone/drone/server/datastore/database + mysql -P 3306 --protocol=tcp -u root -e 'drop database test;' test_postgres: TEST_DRIVER="postgres" TEST_DATASOURCE="host=127.0.0.1 user=postgres dbname=postgres sslmode=disable" go test -short github.com/drone/drone/server/datastore/database @@ -26,8 +27,8 @@ build: go build -o packaging/root/usr/local/bin/droned -ldflags "-X main.revision $(SHA)" github.com/drone/drone/server install: - install -t /usr/local/bin packaging/root/usr/local/bin/drone - install -t /usr/local/bin packaging/root/usr/local/bin/droned + install -t /usr/local/bin packaging/root/usr/local/bin/drone + install -t /usr/local/bin packaging/root/usr/local/bin/droned run: @go run server/main.go --config=$$HOME/.drone/config.toml diff --git a/server/datastore/database/repo.go b/server/datastore/database/repo.go index 464f0589e..ff1381d7d 100644 --- a/server/datastore/database/repo.go +++ b/server/datastore/database/repo.go @@ -79,13 +79,12 @@ LIMIT 1; // SQL statement to retrieve a list of Repos // with permissions for the given User ID. const repoListQuery = ` -SELECT * -FROM repos -WHERE repo_id IN ( - SELECT repo_id - FROM perms - WHERE user_id = ? -); +SELECT r.* +FROM + repos r +,perms p +WHERE r.repo_id = p.repo_id + AND p.user_id = ? ` // SQL statement to delete a User by ID.