Skip to content

Commit

Permalink
add support for char function
Browse files Browse the repository at this point in the history
  • Loading branch information
wsporto committed Nov 28, 2024
1 parent a753668 commit b793b6d
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/sqlite-query-analyzer/traverse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
{
Expand Down
41 changes: 41 additions & 0 deletions tests/sqlite/sqlite-parse-select-functions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});

0 comments on commit b793b6d

Please sign in to comment.