andywer / andywer/postguard

Validating TypeScript types vs. database types

Aperta
#31 1 commento 0 reazioni 0 assegnatari Vedi su GitHub
bug question
Lingua principale
TypeScript
Stelle
179
Fork
7
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

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?

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.