fix id on find

This commit is contained in:
Erik Winter 2023-12-25 11:30:05 +01:00
parent 36c34ce2d8
commit 8ca12c8862
1 changed files with 3 additions and 3 deletions

View File

@ -113,7 +113,7 @@ func (s *SQLite) Delete(id string) error {
func (s *SQLite) FindOne(id string) (*model.Movie, error) { func (s *SQLite) FindOne(id string) (*model.Movie, error) {
row := s.db.QueryRow(` row := s.db.QueryRow(`
SELECT tmdb_id, imdb_id, title, english_title, year, directors, summary, watched_on, rating, comment SELECT id, tmdb_id, imdb_id, title, english_title, year, directors, summary, watched_on, rating, comment
FROM movie FROM movie
WHERE id=?`, id) WHERE id=?`, id)
if row.Err() != nil { if row.Err() != nil {
@ -134,7 +134,7 @@ WHERE id=?`, id)
func (s *SQLite) FindAll() ([]*model.Movie, error) { func (s *SQLite) FindAll() ([]*model.Movie, error) {
rows, err := s.db.Query(` rows, err := s.db.Query(`
SELECT tmdb_id, imdb_id, title, english_title, year, directors, summary, watched_on, rating, comment SELECT id, tmdb_id, imdb_id, title, english_title, year, directors, summary, watched_on, rating, comment
FROM movie`) FROM movie`)
if err != nil { if err != nil {
return nil, fmt.Errorf("%w: %v", ErrSqliteFailure, err) return nil, fmt.Errorf("%w: %v", ErrSqliteFailure, err)
@ -145,7 +145,7 @@ FROM movie`)
for rows.Next() { for rows.Next() {
m := &model.Movie{} m := &model.Movie{}
var directors string var directors string
if err := rows.Scan(&m.TMDBID, &m.IMDBID, &m.Title, &m.EnglishTitle, &m.Year, &directors, &m.Summary, &m.WatchedOn, &m.Rating, &m.Comment); err != nil { if err := rows.Scan(&m.ID, &m.TMDBID, &m.IMDBID, &m.Title, &m.EnglishTitle, &m.Year, &directors, &m.Summary, &m.WatchedOn, &m.Rating, &m.Comment); err != nil {
return nil, fmt.Errorf("%w: %v", ErrSqliteFailure, err) return nil, fmt.Errorf("%w: %v", ErrSqliteFailure, err)
} }
m.Directors = strings.Split(directors, ",") m.Directors = strings.Split(directors, ",")