@@ -23,7 +23,7 @@ function arrayDimensionToSymbol(target) {
2323}
2424
2525function castToSQL ( expr ) {
26- const { arrows = [ ] , collate, target, expr : expression , keyword, symbol, as : alias , properties = [ ] } = expr
26+ const { arrows = [ ] , collate, target, expr : expression , keyword, symbol, as : alias , parentheses : outParentheses , properties = [ ] } = expr
2727 const { length, dataType, parentheses, quoted, scale, suffix : dataTypeSuffix , expr : targetExpr } = target
2828 let str = targetExpr ? exprToSQL ( targetExpr ) : ''
2929 if ( length != null ) str = scale ? `${ length } , ${ scale } ` : length
@@ -41,8 +41,8 @@ function castToSQL(expr) {
4141 if ( alias ) suffix += ` AS ${ identifierToSql ( alias ) } `
4242 if ( collate ) suffix += ` ${ commonTypeValue ( collate ) . join ( ' ' ) } `
4343 const arrayDimension = arrayDimensionToSymbol ( target )
44- const result = [ prefix , symbolChar , quoted , dataType , quoted , arrayDimension , str , suffix ]
45- return result . filter ( hasVal ) . join ( '' )
44+ const result = [ prefix , symbolChar , quoted , dataType , quoted , arrayDimension , str , suffix ] . filter ( hasVal ) . join ( '' )
45+ return outParentheses ? `( ${ result } )` : result
4646}
4747
4848function extractFunToSQL ( stmt ) {
0 commit comments