Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/func.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,10 @@ function funcToSQL(expr) {
const funcName = [literalToSQL(name.schema), name.name.map(literalToSQL).join('.')].filter(hasVal).join('.')
if (!args) return [funcName, withinGroupStr, overStr].filter(hasVal).join(' ')
let separator = expr.separator || ', '
if (toUpper(funcName) === 'TRIM') separator = ' '
let str = [funcName]
str.push(args_parentheses === false ? ' ' : '(')
const argsList = exprToSQL(args)
if (toUpper(funcName) === 'TRIM' && argsList.length > 2) separator = ' '
if (Array.isArray(separator)) {
let argsSQL = argsList[0]
for (let i = 1, len = argsList.length; i < len; ++i) {
Expand Down
8 changes: 8 additions & 0 deletions test/snowflake.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,14 @@ describe('snowflake', () => {
"SELECT split('12-34', '-')[0] FROM DUAL"
]
},
{
title: 'trim with two parameters',
sql: [
"SELECT trim(col, ' ') FROM DUAL",
"SELECT trim(\"col\", ' ') FROM DUAL",
]
},

]
SQL_LIST.forEach(sqlInfo => {
const { title, sql } = sqlInfo
Expand Down