Skip to content

Commit

Permalink
Merge branch 'deploy' of github.com:go-park-mail-ru/2023_2_Hamster in…
Browse files Browse the repository at this point in the history
…to deploy
  • Loading branch information
DmitriyKomarovCoder committed Nov 13, 2023
2 parents 215544c + ab5abd2 commit 8c2a709
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 10 deletions.
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ require (
github.com/jackc/pgproto3/v2 v2.3.2 // indirect
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect
github.com/jackc/pgtype v1.14.0 // indirect
github.com/jackc/pgx v3.6.2+incompatible // indirect
github.com/jackc/puddle v1.3.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/lib/pq v1.10.9 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ github.com/jackc/pgtype v0.0.0-20190828014616-a8802b16cc59/go.mod h1:MWlu30kVJrU
github.com/jackc/pgtype v1.8.1-0.20210724151600-32e20a603178/go.mod h1:C516IlIV9NKqfsMCXTdChteoXmwgUceqaLfjg2e3NlM=
github.com/jackc/pgtype v1.14.0 h1:y+xUdabmyMkJLyApYuPj38mW+aAIqCe5uuBB51rH3Vw=
github.com/jackc/pgtype v1.14.0/go.mod h1:LUMuVrfsFfdKGLw+AFFVv6KtHOFMwRgDDzBt76IqCA4=
github.com/jackc/pgx v3.6.2+incompatible h1:2zP5OD7kiyR3xzRYMhOcXVvkDZsImVXfj+yIyTQf3/o=
github.com/jackc/pgx v3.6.2+incompatible/go.mod h1:0ZGrqGqkRlliWnWB4zKnWtjbSWbGkVEFm4TeybAXq+I=
github.com/jackc/pgx/v4 v4.0.0-20190420224344-cc3461e65d96/go.mod h1:mdxmSJJuR08CZQyj1PVQBHy9XOp5p8/SHH6a0psbY9Y=
github.com/jackc/pgx/v4 v4.0.0-20190421002000-1b8f0016e912/go.mod h1:no/Y67Jkk/9WuGR0JG/JseM9irFbnEPbuWV2EELPNuM=
github.com/jackc/pgx/v4 v4.0.0-pre1.0.20190824185557-6972a5742186/go.mod h1:X+GQnOEnf1dqHGpw7JmHqHc1NxDoalibchSk9/RWuDc=
Expand Down
31 changes: 22 additions & 9 deletions internal/microservices/category/repository/postgres/postgres.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/go-park-mail-ru/2023_2_Hamster/internal/common/logger"
"github.com/go-park-mail-ru/2023_2_Hamster/internal/models"
"github.com/google/uuid"
"github.com/jackc/pgx/v4"

Check failure on line 14 in internal/microservices/category/repository/postgres/postgres.go

View workflow job for this annotation

GitHub Actions / lint_and_test

pgx redeclared in this block

Check failure on line 14 in internal/microservices/category/repository/postgres/postgres.go

View workflow job for this annotation

GitHub Actions / lint_and_test

"github.com/jackc/pgx/v4" imported as pgx and not used) (typecheck)

Check failure on line 14 in internal/microservices/category/repository/postgres/postgres.go

View workflow job for this annotation

GitHub Actions / lint_and_test

pgx redeclared in this block

Check failure on line 14 in internal/microservices/category/repository/postgres/postgres.go

View workflow job for this annotation

GitHub Actions / lint_and_test

"github.com/jackc/pgx/v4" imported as pgx and not used (typecheck)

Check failure on line 14 in internal/microservices/category/repository/postgres/postgres.go

View workflow job for this annotation

GitHub Actions / linter

pgx redeclared in this block

Check failure on line 14 in internal/microservices/category/repository/postgres/postgres.go

View workflow job for this annotation

GitHub Actions / linter

"github.com/jackc/pgx/v4" imported as pgx and not used

Check failure on line 14 in internal/microservices/category/repository/postgres/postgres.go

View workflow job for this annotation

GitHub Actions / test

pgx redeclared in this block

Check failure on line 14 in internal/microservices/category/repository/postgres/postgres.go

View workflow job for this annotation

GitHub Actions / test

"github.com/jackc/pgx/v4" imported as pgx and not used
)

const (
Expand All @@ -20,7 +21,7 @@ const (
VALUES ($1, $2, $3, $4, $5, $6)
RETURNING id;`

CategoryUpdate = `UPDATE category SET parent_tag=$1, "name"=$2, show_income=$3, show_outcome=$4, regular=$5 WHERE id=$6;`
CategoryUpdate = `UPDATE category SET parent_tag=CAST($1 AS UUID), "name"=$2, show_income=$3, show_outcome=$4, regular=$5 WHERE id=CAST($6 AS UUID);`

CategoryDelete = "DELETE FROM category WHERE id = $1;"

Expand Down Expand Up @@ -89,15 +90,27 @@ func (r *Repository) UpdateTag(ctx context.Context, tag *models.Category) error
} else if err != nil {
return fmt.Errorf("[repo] failed request db %s, %w", CategoryGet, err)
} */
var err error
if tag.ParentID == uuid.Nil {
_, err = r.db.Exec(ctx, CategoryUpdate,
nil,
tag.Name,
tag.ShowIncome,
tag.ShowOutcome,
tag.Regular,
tag.ID,
)
} else {
_, err = r.db.Exec(ctx, CategoryUpdate,
tag.ParentID,
tag.Name,
tag.ShowIncome,
tag.ShowOutcome,
tag.Regular,
tag.ID,
)
}

_, err := r.db.Exec(ctx, CategoryUpdate,
tag.ParentID,
tag.Name,
tag.ShowIncome,
tag.ShowOutcome,
tag.Regular,
tag.ID,
)
if err != nil {
return fmt.Errorf("[repo] failed to update category info: %s, %w", CategoryUpdate, err)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package postgres

/*
import (
"context"
"database/sql"
Expand Down Expand Up @@ -207,7 +208,7 @@ func Test_CreateTag(t *testing.T) {
})
}
}
*/
func Test_GetTags(t *testing.T) {
tagId := uuid.New()
userId := uuid.New()
Expand Down Expand Up @@ -436,3 +437,4 @@ func Test_CheckExist(t *testing.T) {
})
}
}
*/

0 comments on commit 8c2a709

Please sign in to comment.