INTERVAL postgres data types have (possibly) incorrect typescript types
yasiruk opened this issue · 0 comments
yasiruk commented
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