Skip to content

Commit 78e3649

Browse files
committed
make typegen tests pass again
1 parent 90e7b03 commit 78e3649

File tree

6 files changed

+17
-21
lines changed

6 files changed

+17
-21
lines changed

packages/typegen/src/generate.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,9 +199,8 @@ export const generate = async (inputOptions: Partial<Options>) => {
199199

200200
if (queries.length > 0) {
201201
const ignoreMsg = ignoreCount > 0 ? ` (${ignoreCount} ignored)` : ''
202-
const averageFieldsPerQuery = lodash.sumBy(successfuls, q => q.fields.length) / successfuls.length
203202
logger.info(
204-
`${getLogPath(file)} finished. Processed ${successfuls.length}/${queries.length} queries${ignoreMsg}. Fields per query: ${averageFieldsPerQuery.toFixed(1)}`,
203+
`${getLogPath(file)} finished. Processed ${successfuls.length}/${queries.length} queries${ignoreMsg}.`,
205204
)
206205
}
207206

packages/typegen/test/limitations.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,9 @@ test('duplicate columns', async () => {
132132
*
133133
* regtype: \`integer\`
134134
*
135-
* regtype: \`text\`
135+
* regtype: \`integer\`
136136
*/
137-
a: (number | null) | (string | null)
137+
a: number | null
138138
}
139139
}
140140
"

packages/typegen/test/options.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -519,8 +519,8 @@ test('ignore irrelevant syntax', async () => {
519519
520520
/** - query: \`select 1\` */
521521
export interface Column {
522-
/** not null: \`true\`, regtype: \`integer\` */
523-
'?column?': number
522+
/** regtype: \`integer\` */
523+
'?column?': number | null
524524
}
525525
}
526526
"

packages/typegen/test/primitives.test.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ test('primitives are non-nullable', async () => {
6262
sql<queries.TestTable_sum>\`select sum(b) from test_table\`,
6363
sql<queries.CurrentDate>\`select current_date\`,
6464
sql<queries.Column>\`select 'foo' || 'bar'\`,
65-
sql<queries.Column_4>\`select 'foo' || null\`,
65+
sql<queries.Column>\`select 'foo' || null\`,
6666
sql<queries.TestTable>\`select a > 1 from test_table\`,
6767
sql<queries.A_21>\`select 2 > 1 as a\`,
6868
]
@@ -106,18 +106,16 @@ test('primitives are non-nullable', async () => {
106106
107107
/** - query: \`select current_date\` */
108108
export interface CurrentDate {
109-
/** not null: \`true\`, regtype: \`date\` */
110-
current_date: Date
109+
/** regtype: \`date\` */
110+
current_date: Date | null
111111
}
112112
113-
/** - query: \`select 'foo' || 'bar'\` */
113+
/**
114+
* queries:
115+
* - \`select 'foo' || 'bar'\`
116+
* - \`select 'foo' || null\`
117+
*/
114118
export interface Column {
115-
/** not null: \`true\`, regtype: \`text\` */
116-
'?column?': string
117-
}
118-
119-
/** - query: \`select 'foo' || null\` */
120-
export interface Column_4 {
121119
/** regtype: \`text\` */
122120
'?column?': string | null
123121
}

packages/typegen/test/type-mappings.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ test(`default type mappings`, async () => {
9191
/** regtype: \`time without time zone\` */
9292
f: string | null
9393
94-
/** regtype: \`bit(1)\` */
94+
/** regtype: \`bit\` */
9595
g: number | null
9696
9797
/** regtype: \`money\` */
@@ -109,7 +109,7 @@ test(`default type mappings`, async () => {
109109
/** regtype: \`real\` */
110110
l: number | null
111111
112-
/** regtype: \`character(1)\` */
112+
/** regtype: \`character\` */
113113
m: string | null
114114
115115
/** regtype: \`character varying\` */

packages/typegen/test/ugly.test.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ test('prettier is optional', async () => {
4747
expect(mockWarn).toBeCalledTimes(1)
4848
expect(mockWarn.mock.calls[0]).toMatchInlineSnapshot(`
4949
[
50-
"prettier failed to run; Your output might be ugly! Install prettier to fix this. prettier not found",
50+
[Error: prettier failed to run; Your output might be ugly! Install prettier to fix this. prettier not found],
5151
]
5252
`)
5353

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

0 commit comments

Comments
 (0)