chanched handlers
This commit is contained in:
@@ -24,5 +24,9 @@ insert into package(name, url, modules) values ($1, $2, $3);
|
||||
insert into module(name, version, last_version) values
|
||||
%s
|
||||
returning id;
|
||||
`
|
||||
queryGetModule = `
|
||||
select id, name, version, last_version from module
|
||||
where id in %s ;
|
||||
`
|
||||
)
|
||||
|
@@ -1,28 +0,0 @@
|
||||
package postgres
|
||||
|
||||
const (
|
||||
queryListPackage = `
|
||||
select
|
||||
id,
|
||||
name,
|
||||
url,
|
||||
comments
|
||||
--modules,
|
||||
--issues,
|
||||
from package;
|
||||
`
|
||||
queryAddComment = `
|
||||
with insert_comm as (
|
||||
insert into comment(text) values ($1) returning id
|
||||
)
|
||||
update package set comments = array_append(comments, (select * from insert_comm)) where id=$2;
|
||||
`
|
||||
queryAddPackage = `
|
||||
insert into package(name, url, modules) values ($1, $2, $3);
|
||||
`
|
||||
queryInsMsgGetIDs = `
|
||||
insert into module(name, version, last_version) values
|
||||
%s
|
||||
returning id;
|
||||
`
|
||||
)
|
@@ -6,7 +6,6 @@ import (
|
||||
"embed"
|
||||
"errors"
|
||||
"fmt"
|
||||
pb "go.unistack.org/unistack-org/pkgdash/proto"
|
||||
"strings"
|
||||
|
||||
"github.com/golang-migrate/migrate/v4"
|
||||
@@ -16,6 +15,7 @@ import (
|
||||
"go.unistack.org/micro/v4/logger"
|
||||
"go.unistack.org/unistack-org/pkgdash/config"
|
||||
"go.unistack.org/unistack-org/pkgdash/models"
|
||||
pb "go.unistack.org/unistack-org/pkgdash/proto"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -138,7 +138,7 @@ func (s *Postgres) AddComment(ctx context.Context, req *pb.AddCommentReq) error
|
||||
}
|
||||
}()
|
||||
|
||||
res, err := tx.ExecContext(ctx, queryAddComment, req.Text, req.IdPackage.Value)
|
||||
res, err := tx.ExecContext(ctx, queryAddComment, req.Text, req.IdPackage)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -168,7 +168,7 @@ func (s *Postgres) AddPackage(ctx context.Context, req *pb.AddPackageReq) error
|
||||
}
|
||||
}()
|
||||
|
||||
res, err := tx.ExecContext(ctx, queryAddPackage, req.Name.Value, req.Url.Value, pq.Array(req.Modules))
|
||||
res, err := tx.ExecContext(ctx, queryAddPackage, req.Name, req.Url, pq.Array(req.Modules))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
Reference in New Issue
Block a user