Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

INTERVAL postgres data types have (possibly) incorrect typescript types #552

Open
yasiruk opened this issue Nov 27, 2023 · 0 comments
Open
Labels
bug Something isn't working

Comments

@yasiruk
Copy link

yasiruk commented Nov 27, 2023

Describe the bug

Recreated on:

pg typed version: 2.3.0
postgres version: 11.4
pg version: 8.11.3
node version: 18.16.0
pg typed version: master commit:fe3539b6a78fb7ef39b77af081342c30c642660b
postgres version: 16
pg version: 8.11.3
node version: 18

The default configs of pg-typed parses Postgres INTERVAL column data using postgres-interval npm package. This results in types generated for row object properties corresponding to interval results to be of type PostgresInterval that has a shape as follows:

{
"milliseconds" : 0,
"seconds": 1,
"minutes: 10
//....
}

But the corresponding types in the generated type definitions are of string type.

/** 'GetAllMovies' parameters type */
export type IGetAllMoviesParams = void;

/** 'GetAllMovies' return type */
export interface IGetAllMoviesResult {
  duration: string;
  title: string;
}

/** 'GetAllMovies' query type */
export interface IGetAllMoviesQuery {
  params: IGetAllMoviesParams;
  result: IGetAllMoviesResult;
}

const getAllMoviesIR: any = {"usedParamSet":{},"params":[],"statement":"select * from movie"};

/**
 * Query generated from SQL:
 * ```
 * select * from movie
 * ```
 */
export const getAllMovies = new PreparedQuery<IGetAllMoviesParams,IGetAllMoviesResult>(getAllMoviesIR);

Expected behavior

To have consistent compile time and runtime types for corresponding interval values.

Test case

Test cases added on #553

@yasiruk yasiruk added the bug Something isn't working label Nov 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant