-
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
change nullable generic to type union (#69)
- Loading branch information
Showing
13 changed files
with
35 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"@ts-safeql/eslint-plugin": patch | ||
"@ts-safeql/generate": patch | ||
--- | ||
|
||
Change autofix fromNullable generic (e.g. `Nullable<string>`) to type union format (e.g. string | null) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
import { Db, Nullable } from "@ts-safeql-demos/shared/client"; | ||
import { Db } from "@ts-safeql-demos/shared/client"; | ||
import postgres from "postgres"; | ||
|
||
export function check(client: Db) { | ||
const sql = postgres(); | ||
|
||
client.queryOne<{ id: number; post_id: Nullable<number>; body: Nullable<string> }>(sql` | ||
client.queryOne<{ id: number; post_id: number | null; body: string | null }>(sql` | ||
SELECT * FROM comments | ||
`); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,15 @@ | ||
import postgres from "postgres"; | ||
|
||
type Nullable<T> = T | null; | ||
|
||
interface Starship { | ||
id: number; | ||
name: string; | ||
captain_id: Nullable<number>; | ||
captain_id: number | null; | ||
} | ||
|
||
export function check() { | ||
const sql = postgres(); | ||
|
||
sql<{ id: number }[]>`SELECT id FROM starship`; | ||
sql<{ id: number; name: string; captain_id: Nullable<number> }[]>`SELECT * FROM starship`; | ||
sql<{ id: number; name: string; captain_id: number | null }[]>`SELECT * FROM starship`; | ||
sql<Starship[]>`SELECT * FROM starship`; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
import { Db, Nullable } from "@ts-safeql-demos/shared/client"; | ||
import { Db } from "@ts-safeql-demos/shared/client"; | ||
import postgres from "postgres"; | ||
|
||
export function check(client1: Db, client2: Db) { | ||
const sql = postgres(); | ||
|
||
// client 1 points to acme/migrations1/ | ||
client1.queryOne<{ post_id: Nullable<number> }>(sql`SELECT post_id FROM comments`); | ||
client1.queryOne<{ post_id: number | null }>(sql`SELECT post_id FROM comments`); | ||
|
||
// client 2 points to acme/migrations2/ | ||
client2.queryOne<{ name: Nullable<string> }>(sql`SELECT name FROM chat_rooms`); | ||
client2.queryOne<{ name: string | null }>(sql`SELECT name FROM chat_rooms`); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fbdfb61
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
safeql – ./
safeql-git-main-safeql.vercel.app
safeql-safeql.vercel.app
safeql.dev
www.safeql.dev
safeql.vercel.app