andywer / andywer/postguard

Validating TypeScript types vs. database types

Abierto
#31 1 comentario 0 reacciones 0 asignados Ver en GitHub
bug question
Lenguaje dominante
TypeScript
Estrellas
179
Forks
7
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

I'm not sure if this is something that postguard handles.

I have a table like this:
```sql
CREATE TABLE users (
id uuid PRIMARY KEY DEFAULT gen_random_uuid (),
name text NOT NULL,
);
```

Then in my code:

```ts
const usersTable = defineTable('users', {
id: Schema.Number,
name: Schema.String,
});

type UserRecord = TableRow;

console.log(await pool.query(
sql`SELECT id, name FROM users WHERE name = 'test'`,
));
```

Postguard sees no issues here. I was hoping it would fail since I defined `id` in the table as `Schema.Number` but the data type of the `id` column is `uuid` which is parsed as a `string` by `node-postgres`. Am I doing something wrong or this is not supported / not how it works?

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

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.