( clause: IR.OrderByClause, params: Array<unknown>, encodeColumnName?: ColumnEncoder, )
| 134 | } |
| 135 | |
| 136 | function compileOrderByClause( |
| 137 | clause: IR.OrderByClause, |
| 138 | params: Array<unknown>, |
| 139 | encodeColumnName?: ColumnEncoder, |
| 140 | ): string { |
| 141 | // FIXME: We should handle stringSort and locale. |
| 142 | // Correctly supporting them is tricky as it depends on Postgres' collation |
| 143 | const { expression, compareOptions } = clause |
| 144 | let sql = compileBasicExpression(expression, params, encodeColumnName) |
| 145 | |
| 146 | if (compareOptions.direction === `desc`) { |
| 147 | sql = `${sql} DESC` |
| 148 | } |
| 149 | |
| 150 | if (compareOptions.nulls === `first`) { |
| 151 | sql = `${sql} NULLS FIRST` |
| 152 | } |
| 153 | |
| 154 | if (compareOptions.nulls === `last`) { |
| 155 | sql = `${sql} NULLS LAST` |
| 156 | } |
| 157 | |
| 158 | return sql |
| 159 | } |
| 160 | |
| 161 | /** |
| 162 | * Check if a BasicExpression represents a null/undefined value |
no test coverage detected