andywer / andywer/postguard

Validating TypeScript types vs. database types

未关闭
#31 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
bug question
主要语言
TypeScript
星标
179
派生
7
PR 合并指标
30 天内没有已合并 PR

描述

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?

贡献指南

这个仓库没有索引到贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。