From 0b7b6beccdccda09ebebc93b3c5d016ce3123225 Mon Sep 17 00:00:00 2001 From: soxx Date: Fri, 21 Jun 2024 22:58:52 +0200 Subject: [PATCH] fix(postgres): Update CheckIfAnthrovePostNodeExistsBySourceURL to return pointer instead of value Signed-off-by: soxx --- internal/postgres/post.go | 4 ++-- pkg/database/postgres.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/postgres/post.go b/internal/postgres/post.go index 3fc9ec1..d8158d9 100644 --- a/internal/postgres/post.go +++ b/internal/postgres/post.go @@ -40,7 +40,7 @@ func CheckIfAnthrovePostNodeExistsByAnthroveID(ctx context.Context, db *gorm.DB, return executeCheckQuery(ctx, db, "id = ?", string(anthrovePostID)) } -func CheckIfAnthrovePostNodeExistsBySourceURL(ctx context.Context, db *gorm.DB, sourceURL string) (graphModels.AnthrovePost, bool, error) { +func CheckIfAnthrovePostNodeExistsBySourceURL(ctx context.Context, db *gorm.DB, sourceURL string) (*graphModels.AnthrovePost, bool, error) { var post pgModels.Post err := db.WithContext(ctx).Model(&pgModels.Post{}).InnerJoins("References", db.Where("url = ?", sourceURL)).First(&post).Error @@ -59,7 +59,7 @@ func CheckIfAnthrovePostNodeExistsBySourceURL(ctx context.Context, db *gorm.DB, //TODO Now test it! :D // Naaa // D: - return pgPost, true, nil + return &pgPost, true, nil } func CheckIfAnthrovePostNodeExistsBySourceID(ctx context.Context, db *gorm.DB, sourceID string) (bool, error) { diff --git a/pkg/database/postgres.go b/pkg/database/postgres.go index aec5911..62a4d2c 100644 --- a/pkg/database/postgres.go +++ b/pkg/database/postgres.go @@ -90,7 +90,7 @@ func (p *postgresqlConnection) CheckPostNodeExistsByAnthroveID(ctx context.Conte // CheckPostNodeExistsBySourceURL NOT WORKING! TODO! func (p *postgresqlConnection) CheckPostNodeExistsBySourceURL(ctx context.Context, sourceUrl string) (*graphModels.AnthrovePost, bool, error) { post, exists, err := postgres.CheckIfAnthrovePostNodeExistsBySourceURL(ctx, p.db, sourceUrl) - return &post, exists, err + return post, exists, err } // CheckPostNodeExistsBySourceID NOT WORKING! TODO!