andywer / andywer/postguard

Validating TypeScript types vs. database types

Đang mở
#31 1 bình luận 0 reaction 0 người được giao Xem trên GitHub
bug question
Ngôn ngữ chính
TypeScript
Star
179
Fork
7
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

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?

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.