diff --git a/src/sqlite-query-analyzer/traverse.ts b/src/sqlite-query-analyzer/traverse.ts index 228d070..3f5bbd3 100644 --- a/src/sqlite-query-analyzer/traverse.ts +++ b/src/sqlite-query-analyzer/traverse.ts @@ -1484,6 +1484,19 @@ function traverse_function(expr: ExprContext, function_name: string, traverseCon notNull: 0 } }, + 'char': { + paramsTypes: [ + { + type: 'INTEGER', + notNull: true + } + ], + variableParameters: true, + returnType: { + type: 'TEXT', + notNull: true + } + }, 'json': { paramsTypes: [ { diff --git a/tests/sqlite/sqlite-parse-select-functions.test.ts b/tests/sqlite/sqlite-parse-select-functions.test.ts index 0770783..d67f13d 100644 --- a/tests/sqlite/sqlite-parse-select-functions.test.ts +++ b/tests/sqlite/sqlite-parse-select-functions.test.ts @@ -1443,4 +1443,45 @@ describe('sqlite-parse-select-functions', () => { } assert.deepStrictEqual(actual.right, expected); }); + + it('SELECT char(?, ?, ?) as result', () => { + const sql = 'SELECT char(?, ?, ?) as result'; + const actual = parseSql(sql, sqliteDbSchema); + + const expected: SchemaDef = { + sql, + queryType: 'Select', + multipleRowsResult: false, + columns: [ + { + columnName: 'result', + type: 'TEXT', + notNull: true, + table: '' + } + ], + parameters: [ + { + columnType: 'INTEGER', + name: 'param1', + notNull: true + }, + { + columnType: 'INTEGER', + name: 'param2', + notNull: true + }, + { + columnType: 'INTEGER', + name: 'param3', + notNull: true + } + ] + }; + + if (isLeft(actual)) { + assert.fail(`Shouldn't return an error: ${actual.left.description}`); + } + assert.deepStrictEqual(actual.right, expected); + }); });