* Compiles a single OrderByClause to SQL.
( clause: IR.OrderByClause, params: Array<unknown>, compileOptions?: CompileSQLiteOptions, )
| 133 | * Compiles a single OrderByClause to SQL. |
| 134 | */ |
| 135 | function compileOrderByClause( |
| 136 | clause: IR.OrderByClause, |
| 137 | params: Array<unknown>, |
| 138 | compileOptions?: CompileSQLiteOptions, |
| 139 | ): string { |
| 140 | const { expression, compareOptions } = clause |
| 141 | let sql = compileExpression(expression, params, compileOptions) |
| 142 | |
| 143 | if (compareOptions.direction === `desc`) { |
| 144 | sql = `${sql} DESC` |
| 145 | } |
| 146 | |
| 147 | // SQLite supports NULLS FIRST/LAST (since 3.30.0) |
| 148 | if (compareOptions.nulls === `first`) { |
| 149 | sql = `${sql} NULLS FIRST` |
| 150 | } else { |
| 151 | // Default to NULLS LAST (nulls === 'last') |
| 152 | sql = `${sql} NULLS LAST` |
| 153 | } |
| 154 | |
| 155 | return sql |
| 156 | } |
| 157 | |
| 158 | /** |
| 159 | * Check if a BasicExpression represents a null/undefined value |
no test coverage detected