adelsz / pgtyped

pgTyped - Typesafe SQL in TypeScript
https://pgtyped.dev
MIT License
2.91k stars 94 forks source link

"varchar || varchar" value will be string but resolved as "string | null" #575

Closed nabe1653 closed 5 months ago

nabe1653 commented 5 months ago

Describe the bug

"varchar || varchar" value will be string but resolved as "string | null"

This is happedned even if both values are static string or not null column.

Expected behavior

Resolve as string.

Test case

Tested with "@pgtyped/cli": "^2.2.1" with node v18.15.0.

Below sql will return string | null:

/*
  @name test
 */
SELECT
    'a' || 'b' as not_null_string
;
/** 'Test' return type */
export interface ITestResult {
  not_null_string: string | null;
}
nabe1653 commented 5 months ago

So sorry, I forgot export name can use ! assertion too.

/*
  @name test
 */
SELECT
    'a' || 'b' as "not_null_string!"
;