alter() on PostgreSQL cannot change an attribute: MODIFY is a syntax error, and a comment change is ignored
I maintainer di solito rispondono entro 6 giorni
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 62/100
Direzione di ricerca
Inspect _make_attribute_alter in declare.py and run the supplied reproduction against PostgreSQL and MySQL to compare the generated SQL. Follow the existing type, nullability, default, rename, and comment comparison paths; PostgreSQL handling must emit backend-specific statements while preserving the core-type marker. Done means all listed PostgreSQL alterations succeed, comment-only changes are applied, and incompatible casts produce a clear error.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Summary
On PostgreSQL, Table.alter() can add, drop and rename attributes, but it cannot change one:
- Changing an attribute's type, nullability or default raises a syntax error.
_make_attribute_alter(declare.py) always emits MySQL'sMODIFY <column definition>. PostgreSQL needsALTER COLUMN ... TYPE ...,SET/DROP NOT NULLandSET/DROP DEFAULT. - Changing only an attribute's comment does nothing, silently. On PostgreSQL the comment is not part of the column definition: it is applied with
COMMENT ON COLUMN. So a comment-only change compares as unchanged, andalter()reports nothing to alter.
MySQL handles all five changes.
Reproduction
DataJoint master, PostgreSQL 15 and MySQL 8.0:
import datajoint as dj
schema = dj.Schema("scratch_alter_pg")
@schema
class Measurement(dj.Manual):
definition = """
measurement_id : int32
---
value : float32 # the value
"""
Measurement.definition = """
measurement_id : int32
---
value : float64 # the value
"""
Measurement.alter(prompt=False)
New definition of value |
MySQL | PostgreSQL |
|---|---|---|
value : float64 # the value |
altered | QuerySyntaxError: syntax error at or near "MODIFY" (MODIFY "value" double precision NOT NULL) |
value = null : float32 # the value |
altered | same error (MODIFY "value" real DEFAULT NULL) |
value = 1.5 : float32 # the value |
altered | same error (MODIFY "value" real NOT NULL DEFAULT '1.5') |
reading : float32 # the value {value} (rename) |
altered | altered |
value : float32 # another comment |
altered | no change, no message |
Expected behavior
On PostgreSQL, alter() makes the same changes it makes on MySQL:
- a type change becomes
ALTER COLUMN ... TYPE ..., withUSINGwhere the cast needs it, or a clear error when the backend cannot convert; - a nullability change becomes
SET/DROP NOT NULL; - a default change becomes
SET/DROP DEFAULT; - a comment change becomes
COMMENT ON COLUMN, with the core-type marker kept, sodescribe()still round-trips.
Repositioning a column has no PostgreSQL equivalent; it is already skipped there (supports_column_position).
- Lingua principale
- Python
- Stelle
- 198
- Fork
- 103
- Merge medio
- 6g 1h
- PR unite (30g)
- 10
Preparare l'ambiente
- Include un Dockerfile o un 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 datajoint/datajoint-python
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
datajoint/datajoint-python#1703 ·
I maintainer di solito rispondono entro 6 giorni
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
datajoint/datajoint-python#1702 ·
I maintainer di solito rispondono entro 6 giorni
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
datajoint/datajoint-python#1701 ·
I maintainer di solito rispondono entro 6 giorni
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
datajoint/datajoint-python#1691 ·
I maintainer di solito rispondono entro 6 giorni
-
dependencies needs-discussion
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
datajoint/datajoint-python#1687 ·
I maintainer di solito rispondono entro 6 giorni
Tutte le issue di datajoint/datajoint-python
Issue simili
-
needs-triage
Difficoltà 1/5 1-3 ore Idoneità per principianti 85/100
gke-labs/kube-agents#6620 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
open-webui/open-webui#34719 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
cognition
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno
-
One non-object JSON record makes the session catalog exitForse già presa @he-yufeng l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 78/100
collabnix/awesome-mcp-lists#433 ·
I maintainer di solito rispondono entro 4 giorni