Skip to content

Fix text accessor returning t/f booleans and datetime-formatted max() (empty Categories, truncated Continue Watching) - #95

Open
rogly wants to merge 1 commit into
cgnl:mainfrom
rogly-net:pr/pg-bool-and-max-text
Open

rogly wants to merge 1 commit into
cgnl:mainfrom
rogly-net:pr/pg-bool-and-max-text

Conversation

@rogly

@rogly rogly commented Nov 19, 2026 •

Copy link
Copy Markdown

Potential fix for #92.

Summary

After migrating Plex 1.43.5 from SQLite to PostgreSQL, two things broke:

  • The Library Categories tab returned 0 entries.
  • Continue Watching returned 0 entries for the migrated history. The only item shown was one watched after the migration.

Both come from sqlite3_column_text() returning something different from what SQLite returns. Plex's SOCI backend reads every integer column through that accessor and parses the string (see the v0.8.12 CHANGELOG notes), so any deviation silently changes the parsed value.

Causes and fixes

1. Booleans came back as t/f

  • PG returns t/f for SELECT EXISTS(...). SQLite returns 1/0.
  • Plex parsed t as 0, so every category-existence check was false.
  • Fix: rust_column_text_transform now maps OID 16 t/f to 1/0.

2. max(viewed_at) was rendered as a datetime string

  • The aggregate reformat branch formatted any max/min BIGINT as YYYY-MM-DD HH:MM:SS whenever the SQL contained _at anywhere, for example originally_available_at in a join.
  • SQLite returns plain digits here. Plex parsed 2026-11-18 ... as the number 2026, so the On Deck history query dropped every show.
  • Fix: max/min of integer columns stay decimal. This removes the datetime branch and the now-unused pg_sql_has_timestamp_hint.

Verification

Tested on a live Plex 1.43.5 instance in Kubernetes, with the shim overlaid on the production image:

Endpoint Before After
/library/sections/1/categories 0 31 (matches vanilla)
/hubs/continueWatching 0 entries 15 items

Unit tests were added for the bool conversion, for leaving non-bool t/f alone, and for max() of an epoch staying decimal. I could not link the test binary in my build environment, so they have not been run locally. CI is the first real run.

Notes for review

  • I did not audit other column_text deviations. I only found these two.

🤖 Generated with Claude Code

Plex's SOCI backend reads every integer column through
sqlite3_column_text() and parses the string, so any deviation from
SQLite's text output changes the parsed value.

- PostgreSQL booleans arrive as "t"/"f"; SQLite yields 1/0 (e.g.
  SELECT EXISTS(...)). Plex parsed "t" as 0, so every category
  existence check was false and Library Categories returned 0 entries.
  The text transform now maps OID 16 t/f to 1/0.
- max()/min() of a BIGINT column was rendered as a datetime string
  whenever the SQL contained "_at" anywhere (e.g. originally_available_at).
  Plex parsed "2026-11-18 ..." as the number 2026 and the On Deck history
  query dropped every show. These aggregates now stay plain digits, and
  the unused pg_sql_has_timestamp_hint is removed.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BhzRzGrcQsh5xuVFKYGNNg
@rogly
rogly marked this pull request as ready for review November 19, 2026 02:55

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant