debug runtim
This commit is contained in:
@@ -3,6 +3,7 @@ package repositories
|
||||
import (
|
||||
"database/sql"
|
||||
"simplycpq/models"
|
||||
"log"
|
||||
)
|
||||
|
||||
type ProductRepository struct {
|
||||
@@ -72,6 +73,7 @@ func (pr *ProductRepository) DeleteProduct(id int) error {
|
||||
func (pr *ProductRepository) GetProductsByGroupId(groupId int) ([]*models.Product, error) {
|
||||
// Implement the logic to retrieve all products by their group ID from the database
|
||||
query := "SELECT id, label, externalId, description, productGroupId FROM products WHERE productGroupId = $1"
|
||||
log.Println("Executing query:", query, "with groupId:", groupId) // Debugging line
|
||||
rows, err := pr.dbHandler.Query(query, groupId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -81,10 +83,13 @@ func (pr *ProductRepository) GetProductsByGroupId(groupId int) ([]*models.Produc
|
||||
products := []*models.Product{}
|
||||
for rows.Next() {
|
||||
product := &models.Product{}
|
||||
log.Println("Scanning row into product struct") // Debugging line
|
||||
log.Println("Row data:", rows) // Debugging line
|
||||
err := rows.Scan(&product.ID, &product.Label, &product.ExternalID, &product.Description, &product.ProductGroupID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
log.Println("Retrieved product:", product) // Debugging line
|
||||
products = append(products, product)
|
||||
}
|
||||
return products, nil
|
||||
|
||||
Reference in New Issue
Block a user