Skip to content
Merged
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
4 changes: 2 additions & 2 deletions src/column.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ function columnOption(definition) {
}

function columnOrderToSQL(columnOrder) {
const { column, collate, nulls, opclass, order_by } = columnOrder
const columnExpr = typeof column === 'string' ? { type: 'column_ref', table: columnOrder.table, column } : columnOrder
const { order_by, column, collate, nulls, opclass } = columnOrder
const columnExpr = typeof column === 'string' ? { type: 'column_ref', table: columnOrder.table, column } : ({ ...columnOrder, order_by: null })
columnExpr.collate = null
const result = [
exprToSQL(columnExpr),
Expand Down
6 changes: 3 additions & 3 deletions src/command.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@ function ifToSQL(stmt) {
if (elseifExpr) {
result.push(
elseifExpr.map(
elseif => [toUpper(elseif.type), exprToSQL(elseif.boolean_expr), 'THEN', astToSQL(elseif.then.ast || elseif.then), elseif.semicolon].filter(hasVal).join(' ')
).join(' ')
elseif => [toUpper(elseif.type), exprToSQL(elseif.boolean_expr), 'THEN', astToSQL(elseif.then.ast || elseif.then), elseif.semicolon].filter(hasVal).join(' '),
).join(' '),
)
}
if (elseExpr) result.push('ELSE', `${astToSQL(elseExpr.ast || elseExpr)}${semicolons[1]}`)
Expand Down Expand Up @@ -207,7 +207,7 @@ function grantAndRevokeToSQL(stmt) {
case 'priv':
result.push(
literalToSQL(on.object_type),
on.priv_level.map(privLevel => [identifierToSql(privLevel.prefix), identifierToSql(privLevel.name)].filter(hasVal).join('.')).join(', ')
on.priv_level.map(privLevel => [identifierToSql(privLevel.prefix), identifierToSql(privLevel.name)].filter(hasVal).join('.')).join(', '),
)
break
case 'proxy':
Expand Down
2 changes: 1 addition & 1 deletion src/tables.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function unnestToSQL(unnestExpr) {
commonOptionConnector(
toUpper(withOffset && withOffset.keyword),
identifierToSql,
withOffset && withOffset.as
withOffset && withOffset.as,
),
]
return result.filter(hasVal).join(' ')
Expand Down
7 changes: 7 additions & 0 deletions test/postgres.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2360,6 +2360,13 @@ describe('Postgres', () => {
'CREATE TEMP TABLE "test" (id INT, price MONEY)'
]
},
{
title: 'create index',
sql: [
`CREATE INDEX "test" ON "test" USING BTREE ("a" ASC, "b" ASC, "c" DESC);`,
'CREATE INDEX "test" ON "test" USING BTREE ("a" ASC, "b" ASC, "c" DESC)'
]
}
]
neatlyNestTestedSQL(SQL_LIST)
})
Expand Down