Skip to content

Commit

Permalink
make typegen tests pass again
Browse files Browse the repository at this point in the history
  • Loading branch information
mmkal committed Sep 20, 2024
1 parent 90e7b03 commit 78e3649
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 21 deletions.
3 changes: 1 addition & 2 deletions packages/typegen/src/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,8 @@ export const generate = async (inputOptions: Partial<Options>) => {

if (queries.length > 0) {
const ignoreMsg = ignoreCount > 0 ? ` (${ignoreCount} ignored)` : ''
const averageFieldsPerQuery = lodash.sumBy(successfuls, q => q.fields.length) / successfuls.length
logger.info(
`${getLogPath(file)} finished. Processed ${successfuls.length}/${queries.length} queries${ignoreMsg}. Fields per query: ${averageFieldsPerQuery.toFixed(1)}`,
`${getLogPath(file)} finished. Processed ${successfuls.length}/${queries.length} queries${ignoreMsg}.`,
)
}

Expand Down
4 changes: 2 additions & 2 deletions packages/typegen/test/limitations.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,9 @@ test('duplicate columns', async () => {
*
* regtype: \`integer\`
*
* regtype: \`text\`
* regtype: \`integer\`
*/
a: (number | null) | (string | null)
a: number | null
}
}
"
Expand Down
4 changes: 2 additions & 2 deletions packages/typegen/test/options.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -519,8 +519,8 @@ test('ignore irrelevant syntax', async () => {
/** - query: \`select 1\` */
export interface Column {
/** not null: \`true\`, regtype: \`integer\` */
'?column?': number
/** regtype: \`integer\` */
'?column?': number | null
}
}
"
Expand Down
18 changes: 8 additions & 10 deletions packages/typegen/test/primitives.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ test('primitives are non-nullable', async () => {
sql<queries.TestTable_sum>\`select sum(b) from test_table\`,
sql<queries.CurrentDate>\`select current_date\`,
sql<queries.Column>\`select 'foo' || 'bar'\`,
sql<queries.Column_4>\`select 'foo' || null\`,
sql<queries.Column>\`select 'foo' || null\`,
sql<queries.TestTable>\`select a > 1 from test_table\`,
sql<queries.A_21>\`select 2 > 1 as a\`,
]
Expand Down Expand Up @@ -106,18 +106,16 @@ test('primitives are non-nullable', async () => {
/** - query: \`select current_date\` */
export interface CurrentDate {
/** not null: \`true\`, regtype: \`date\` */
current_date: Date
/** regtype: \`date\` */
current_date: Date | null
}
/** - query: \`select 'foo' || 'bar'\` */
/**
* queries:
* - \`select 'foo' || 'bar'\`
* - \`select 'foo' || null\`
*/
export interface Column {
/** not null: \`true\`, regtype: \`text\` */
'?column?': string
}
/** - query: \`select 'foo' || null\` */
export interface Column_4 {
/** regtype: \`text\` */
'?column?': string | null
}
Expand Down
4 changes: 2 additions & 2 deletions packages/typegen/test/type-mappings.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ test(`default type mappings`, async () => {
/** regtype: \`time without time zone\` */
f: string | null
/** regtype: \`bit(1)\` */
/** regtype: \`bit\` */
g: number | null
/** regtype: \`money\` */
Expand All @@ -109,7 +109,7 @@ test(`default type mappings`, async () => {
/** regtype: \`real\` */
l: number | null
/** regtype: \`character(1)\` */
/** regtype: \`character\` */
m: string | null
/** regtype: \`character varying\` */
Expand Down
5 changes: 2 additions & 3 deletions packages/typegen/test/ugly.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ test('prettier is optional', async () => {
expect(mockWarn).toBeCalledTimes(1)
expect(mockWarn.mock.calls[0]).toMatchInlineSnapshot(`
[
"prettier failed to run; Your output might be ugly! Install prettier to fix this. prettier not found",
[Error: prettier failed to run; Your output might be ugly! Install prettier to fix this. prettier not found],
]
`)

Expand Down Expand Up @@ -99,8 +99,7 @@ test('prettier can fail', async () => {
expect(mockWarn).toBeCalledTimes(1)
expect(mockWarn.mock.calls[0]).toMatchInlineSnapshot(`
[
"prettier failed to run; Your output might be ugly! Error below:
Syntax error on line 1234",
[Error: prettier failed to run; Your output might be ugly!],
]
`)

Expand Down

0 comments on commit 78e3649

Please sign in to comment.