fix: DEBT-022 - complete repo-wide jsonb/inet cast audit, fix OpenDartService

DEBT-022 previously only checked AuditSql/TradeSql/SellDecisionSql
(where the bug was first found) and left PortfolioReconciliation/
ApprovalWorkflow explicitly "not yet checked". This pass enumerates
every jsonb/inet column across db/migrations/*.sql (case-insensitive,
since several use JSONB/INET uppercase) and checks each for a C#
writer.

PortfolioReconciliation has no jsonb/inet columns at all.
ApprovalWorkflow's one jsonb column was already cast correctly.
Several other jsonb columns belong to unimplemented slices (no writer
yet, so no current bug surface).

Found one new, real instance of the bug: OpenDartService.CacheResultAsync
inserted a JSON string into opendata.opendart_cache.data_json JSONB
without a cast - same 42804 failure mode as the already-documented
cases, just never previously exercised. Fixed with @dataJson::jsonb.

dotnet build KArtSell.sln -c Release: clean. Not run against a live
database this session.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-09 00:25:14 +09:00
parent ace9fe8a9c
commit cbcc4849ec
2 changed files with 2 additions and 2 deletions
@@ -153,7 +153,7 @@ public class OpenDartService
{
const string sql = """
INSERT INTO opendata.opendart_cache (ticker, quarter, data_json, expires_at, published_at)
VALUES (@ticker, @quarter, @dataJson, @expiresAt, @publishedAt)
VALUES (@ticker, @quarter, @dataJson::jsonb, @expiresAt, @publishedAt)
ON CONFLICT (ticker, quarter) DO UPDATE SET
data_json = EXCLUDED.data_json,
expires_at = EXCLUDED.expires_at,