builder: Oracle Merge JSON_TABLE infers VARCHAR2(4000) by char length instead of UTF-8 bytes and omits ERROR ON ERROR
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 78/100
Direzione di ricerca
Inizia da sqlspec/builder/_merge.py, soprattutto da _create_oracle_json_source() e _infer_oracle_type(), poi confronta la gestione del limite di byte in sqlspec/adapters/oracledb/core.py. Controlla la proiezione Oracle JSON_TABLE e l’SQL generato per stringhe multibyte che superano i 4.000 byte UTF-8 e per gli errori di conversione. Il risultato atteso è che questi valori vengano inferiti come CLOB e che JSON_TABLE emetta ERROR ON ERROR.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Summary
The Oracle Merge builder's JSON_TABLE source generator infers VARCHAR2(4000) vs CLOB using Python character length (len(str(value))) instead of UTF-8 byte length, and omits ERROR ON ERROR on JSON_TABLE. Under Oracle's default NLS_LENGTH_SEMANTICS=BYTE, multi-byte UTF-8 strings between 2,001 and 4,000 characters exceed 4,000 bytes and are silently coerced to NULL during MERGE.
Details
-
Character count vs. UTF-8 byte length (
sqlspec/builder/_merge.py:375, 419-428):_create_oracle_json_source()compareslen(str(value)) > len(str(existing))(_merge.py:375) and_infer_oracle_type()checkslen(str(value)) > 4000(_merge.py:426).- This is inconsistent with
coerce_large_parameters_sync()/_string_exceeds_byte_limit()insqlspec/adapters/oracledb/core.py, which correctly checks UTF-8 encoded byte length againstvarchar2_byte_limit=4000. - A 2,500-character multi-byte string (e.g.
"é" * 2500, 5,000 UTF-8 bytes) is inferred asVARCHAR2(4000)instead ofCLOB.
-
Silent
NULL ON ERRORdefault onJSON_TABLE(sqlspec/builder/_merge.py:380-397):exp.JSONTable(...)emitsJSON_TABLE(:json_payload, '$[*]' COLUMNS (...))without anERROR ON ERRORclause.- Oracle
JSON_TABLEdefaults toNULL ON ERROR, so any value overflowingVARCHAR2(4000)or failing JSON/type conversion is silently projected asNULLrather than raising an ORA error.
Reproduction (sqlspec==0.74.2)
from sqlspec.builder import Merge
notes = "é" * 2500
assert len(notes) == 2500
assert len(notes.encode("utf-8")) == 5000
stmt = (
Merge(dialect="oracle")
.into("target", alias="t")
.using([{"id": 1, "notes": notes}], alias="s")
.on("t.id = s.id")
.when_matched_then_update(notes="s.notes")
.when_not_matched_then_insert(id="s.id", notes="s.notes")
.build()
)
print(stmt.sql)
# Emits:
# FROM JSON_TABLE(:json_payload, '$[*]' COLUMNS(id NUMBER PATH '$.id', notes VARCHAR2(4000) PATH '$.notes'))
Expected Behavior
- Measure UTF-8 byte length (
len(str(value).encode("utf-8"))) in_create_oracle_json_source()sample selection and_infer_oracle_type()so strings exceeding 4,000 UTF-8 bytes project asCLOB. - Emit
ERROR ON ERRORin OracleJSON_TABLEprojections so overflow or type conversion errors fail explicitly instead of silently writingNULL.
- Lingua principale
- Python
- Stelle
- 110
- Fork
- 11
- Merge medio
- 19h 9m
- PR unite (30g)
- 37
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di litestar-org/sqlspec
-
bug
Difficoltà 3/5 1-2 giorni Idoneità per principianti 68/100
litestar-org/sqlspec#945 ·
I maintainer di solito rispondono entro 1 giorno
-
builder: order_by("col", "asc") silently treats the direction as a columnForse già presa @cofin l’ha presa 1 giorno fa. Apertaenhancement
litestar-org/sqlspec#944 · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
builder: explain why boolean projections are rejected in sql.select() string columnsForse già presa @cofin l’ha presa 1 giorno fa. Apertaenhancement
litestar-org/sqlspec#943 · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
feat(litestar): support Litestar v3 compatibility and DI changesForse già presa @cofin l’ha presa 14 giorni fa. Apertaenhancement
litestar-org/sqlspec#926 · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 20/100
litestar-org/sqlspec#509 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di litestar-org/sqlspec
Issue simili
-
area:cli area:docs Platform vdr
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
NVIDIA-NeMo/Gym#7192 ·
I maintainer di solito rispondono entro 2 giorni
-
Bug: CaseInsensitiveDict (event.headers) returns True for both == and != against the same mappingApertabug triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
aws-powertools/powertools-lambda-python#8948 ·
I maintainer di solito rispondono entro 1 giorno
-
SofyaBotAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
ai-robots-txt/ai.robots.txt#324 ·
-
[Resource]: DashbarApertaresource-submission validation-passed
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 78/100
hesreallyhim/awesome-claude-code#3821 · 1 commento ·
-
bug good first issue help wanted level 1 wocs
Difficoltà 2/5 1-3 ore Idoneità per principianti 92/100
GianlucaBave/murmury#169 ·
I maintainer di solito rispondono entro 1 giorno