andywer / andywer/postguard

Validating TypeScript types vs. database types

オープン
#31 コメント 1 件 リアクション 0 件 担当者 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 を短くまとめたダイジェスト。