From 78c832eb1f3faacc7bd1c7ae9996f283ef69637c Mon Sep 17 00:00:00 2001 From: Paul Trowbridge Date: Wed, 17 Jun 2026 16:31:45 -0400 Subject: [PATCH] fix: quote json/jsonb/bpchar/uuid values in migration INSERTs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The migration INSERT builder's switch quoted varchar/text/char/clob/date/time but let everything else fall to a default that emits rs.getString() unquoted (correct for numerics, broken for strings). A pg->SQL Server pull of a jsonb column failed with "Incorrect syntax near 'volume_bucket'" — the JSON text's embedded double-quotes were read as a SQL identifier. Quote json/jsonb, plus bpchar (PG char(n)) and uuid, like varchar. Note: the default case still emits unquoted; other unhandled string types (e.g. bool->'t'/'f') would need similar handling or a quote-by-default flip. Co-Authored-By: Claude Opus 4.8 --- jrunner/src/main/java/jrunner/jrunner.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/jrunner/src/main/java/jrunner/jrunner.java b/jrunner/src/main/java/jrunner/jrunner.java index f786052..53efd93 100644 --- a/jrunner/src/main/java/jrunner/jrunner.java +++ b/jrunner/src/main/java/jrunner/jrunner.java @@ -311,6 +311,14 @@ public class jrunner { nr = ""; for (int i = 1; i <= cols; i++){ switch (dtn[i].toUpperCase()){ + // PG string-ish types that otherwise fall to the default + // case and get emitted UNQUOTED (breaking the INSERT): + // jsonb/json carry embedded quotes, bpchar is PG's char(n), + // uuid is a quoted literal. Quote them like varchar. + case "JSON": + case "JSONB": + case "BPCHAR": + case "UUID": case "VARCHAR": case "NVARCHAR": nc = rs.getString(i);