|
| 1 | +import assert from "assert"; |
| 2 | +import QueryCompiler from "../../../compiler/QueryCompiler.js"; |
| 3 | +import Sql from "../../../sql/Sql.js"; |
| 4 | + |
| 5 | +export default function () { |
| 6 | + |
| 7 | + const compiler = QueryCompiler.instance; |
| 8 | + |
| 9 | + const names = ["Akash", "Simmi"]; |
| 10 | + |
| 11 | + let r = compiler.execute({ names }, (p) => (x) => Sql.window.rank.orderBy(x.marks)); |
| 12 | + assert.equal("RANK() OVER (ORDER BY x.marks)", r.text); |
| 13 | + |
| 14 | + r = compiler.execute({ names }, (p) => (x) => Sql.window.rank.partitionByOrderBy(x.classRoom, x.marks)); |
| 15 | + assert.equal("RANK() OVER (PARTITION BY x.classRoom ORDER BY x.marks)", r.text); |
| 16 | + |
| 17 | + r = compiler.execute({ names }, (p) => (x) => Sql.window.denseRank.orderBy(x.marks)); |
| 18 | + assert.equal("DENSE_RANK() OVER (ORDER BY x.marks)", r.text); |
| 19 | + |
| 20 | + r = compiler.execute({ names }, (p) => (x) => Sql.window.denseRank.partitionByOrderBy(x.classRoom, x.marks)); |
| 21 | + assert.equal("DENSE_RANK() OVER (PARTITION BY x.classRoom ORDER BY x.marks)", r.text); |
| 22 | + |
| 23 | + r = compiler.execute({ names }, (p) => (x) => Sql.window.rowNumber.orderBy(x.marks)); |
| 24 | + assert.equal("ROW_NUMBER() OVER (ORDER BY x.marks)", r.text); |
| 25 | + |
| 26 | + r = compiler.execute({ names }, (p) => (x) => Sql.window.rowNumber.partitionByOrderBy(x.classRoom, x.marks)); |
| 27 | + assert.equal("ROW_NUMBER() OVER (PARTITION BY x.classRoom ORDER BY x.marks)", r.text); |
| 28 | + |
| 29 | +} |
| 30 | + |
0 commit comments