Skip to content

fix(idn-admin-regions): impor menulis SQL NULL, bukan string "null" - #396

Merged
ahliweb merged 1 commit into
mainfrom
fix/idn-regions-import-null-columns
Aug 5, 2026
Merged

fix(idn-admin-regions): impor menulis SQL NULL, bukan string "null"#396
ahliweb merged 1 commit into
mainfrom
fix/idn-regions-import-null-columns

Conversation

@ahliweb

@ahliweb ahliweb commented Aug 5, 2026

Copy link
Copy Markdown
Owner

Ditemukan saat mengimpor dataset wilayah ke staging (91.599 baris): nol SQL NULL di seluruh tabel — setiap kolom nullable berisi teks empat karakter "null".

kolom teks 'null' SQL NULL
parent_code 38 (semua provinsi) 0
local_term 7.285 (semua kecamatan) 0
village_code 7.837 0
district_code 552 0
regency_code 38 0

Sebabnya tx.array(values, "text"): Bun menyerialkan elemen null jadi string "null". Diprobe langsung, bukan disimpulkan — sql.array(["a", null, "b"], "text") mengembalikan x = "null" dengan x IS NULL = false; bentuk tanpa tipe juga bukan NULL.

Perbaikannya sentinel eksplisit + NULLIF(t.col, ''), jadi benar terlepas dari perilaku Bun sekarang maupun nanti. Digerbangi test integrasi karena cacat ini tak terlihat oleh typecheck maupun test murni.

🤖 Generated with Claude Code

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

`tx.array(values, "text")` tidak bisa membawa SQL NULL — Bun menyerialkan
elemen `null` menjadi teks empat karakter "null", dan bentuk tanpa tipe pun
tidak menghasilkan NULL (diprobe terhadap PostgreSQL 18.4 di Bun 1.3.14:
`x IS NULL` mengembalikan false untuk keduanya).

Ditemukan pada impor NYATA ke staging, bukan dengan membaca: ke-38 provinsi
mendarat ber-`parent_code` = 'null', dan seluruh 7.285 kecamatan ber-`local_term`
= 'null' — teks yang dirender apa adanya oleh konsumen, sekaligus membuat setiap
filter `IS NULL` mengembalikan nol baris. Delapan kolom nullable terdampak;
nol SQL NULL di seluruh tabel.

Null kini melintas sebagai sentinel string kosong dan dipulihkan
`NULLIF(t.col, '')` di SELECT. Sentinel aman karena tak satu pun kode, nama,
atau local term wilayah yang sah bernilai kosong, dan pemulihannya tetap benar
bila Bun kelak mengirim NULL sungguhan.

Digerbangi test integrasi: cacat ini hidup di batas serialisasi, jadi typecheck
dan test murni tidak bisa melihatnya.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@ahliweb
ahliweb force-pushed the fix/idn-regions-import-null-columns branch from 40b3aea to 4281259 Compare August 5, 2026 10:08
@ahliweb
ahliweb merged commit ce99272 into main Aug 5, 2026
10 checks passed
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