[Bug]: Data type mismatch in database #1539

Closed
opened 2026-04-24 23:49:18 +02:00 by adam · 1 comment
Owner

Originally created by @lkiesow on GitHub (Nov 19, 2023).

Describe the issue

I've noticed that in the SQLite database libraryItems.mediaId, books.id and podcasts.id actually have different column types. Given that ABS constantly joins on these tables, they should probably match:

sqlite> PRAGMA table_info(books);
  cid|name|type|notnull|dflt_value|pk
  0|id|UUID|0||1
sqlite> PRAGMA table_info(podcasts);                                                                                    
  cid|name|type|notnull|dflt_value|pk
  0|id|UUID|0||1
sqlite> PRAGMA table_info(libraryItems);                                                                                
  cid|name|type|notnull|dflt_value|pk
  …
  4|mediaId|UUIDV4|0||0

Not sure if that's a problem right now, but this could easily become a problem at any time.

The relevant code is:

https://github.com/advplyr/audiobookshelf/blob/e07d17c472f9a799c08e28d17861e27588991a80/server/models/LibraryItem.js#L771

https://github.com/advplyr/audiobookshelf/blob/e07d17c472f9a799c08e28d17861e27588991a80/server/models/Book.js#L246-L250

https://github.com/advplyr/audiobookshelf/blob/e07d17c472f9a799c08e28d17861e27588991a80/server/models/Podcast.js#L140-L144

But, this might also need additional data migration.

Audiobookshelf version

2.5.0 (d2aea869)

Originally created by @lkiesow on GitHub (Nov 19, 2023). ### Describe the issue I've noticed that in the SQLite database `libraryItems.mediaId`, `books.id` and `podcasts.id` actually have different column types. Given that ABS constantly joins on these tables, they should probably match: ``` sqlite> PRAGMA table_info(books); cid|name|type|notnull|dflt_value|pk 0|id|UUID|0||1 sqlite> PRAGMA table_info(podcasts); cid|name|type|notnull|dflt_value|pk 0|id|UUID|0||1 sqlite> PRAGMA table_info(libraryItems); cid|name|type|notnull|dflt_value|pk … 4|mediaId|UUIDV4|0||0 ``` Not sure if that's a problem right now, but this could easily become a problem at any time. The relevant code is: https://github.com/advplyr/audiobookshelf/blob/e07d17c472f9a799c08e28d17861e27588991a80/server/models/LibraryItem.js#L771 https://github.com/advplyr/audiobookshelf/blob/e07d17c472f9a799c08e28d17861e27588991a80/server/models/Book.js#L246-L250 https://github.com/advplyr/audiobookshelf/blob/e07d17c472f9a799c08e28d17861e27588991a80/server/models/Podcast.js#L140-L144 But, this might also need additional data migration. ### Audiobookshelf version > 2.5.0 (d2aea869)
adam added the bug label 2026-04-24 23:49:18 +02:00
adam closed this issue 2026-04-24 23:49:19 +02:00
Author
Owner

@github-actions[bot] commented on GitHub (Nov 17, 2024):

Fixed in v2.17.0.

@github-actions[bot] commented on GitHub (Nov 17, 2024): Fixed in [v2.17.0](https://github.com/advplyr/audiobookshelf/releases/tag/v2.17.0).
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/audiobookshelf#1539