feldroy / feldroy/AirModel

Bug: `UUID` primary key fields create `INTEGER` columns instead of `UUID`

Abierto
#3 0 comentarios 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
Python
Estrellas
1
Forks
0
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

## Description
When a model defines an ID field as a UUID with `primary_key=True`, the ORM incorrectly creates a BIGSERIAL (auto-incrementing integer) column instead of a UUID column.

## Steps to Reproduce

1. Define a model with a UUID primary key:
```python
from uuid import UUID
from airmodel import AirModel, AirField

class MyModel(AirModel):
id: UUID = AirField(primary_key=True)
name: str
```

2. Call `_column_defs()` to inspect the generated column definitions:
```python
cols = MyModel._column_defs()
print(cols[0])
# Expected: '"id" UUID PRIMARY KEY'
# Actual (before fix): '"id" BIGSERIAL PRIMARY KEY'
```

## Expected Behavior
UUID primary key fields should create `UUID PRIMARY KEY` columns in PostgreSQL, not `BIGSERIAL PRIMARY KEY` columns.

## Actual Behavior
UUID primary key fields are incorrectly mapped to BIGSERIAL columns, which are auto-incrementing integers.

## Root Cause
The `_column_defs()` method in `src/airmodel/main.py` assumes all primary keys should be BIGSERIAL without checking the actual field type.

## Environment
- **OS**: macOS 26.2 (Darwin 25.2.0)
- **Python**: 3.13.3
- **AirModel**: Latest main branch

## Fix
The fix checks the primary key field's type and uses the appropriate PostgreSQL type:
- `int` types → `BIGSERIAL PRIMARY KEY`
- `UUID` types → `UUID PRIMARY KEY`
- Other types → appropriate type + `PRIMARY KEY`

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.