UNPKG

relax-orm

Version:
23 lines 1.06 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); // tslint:disable-next-line:max-line-length function parserLimitOffset(options, table, columns, whereOptions, orderString) { var rowNumExpression = orderString === '' ? ' ROWNUM as TMP$ROWNUMBER' : " ROW_NUMBER() OVER(" + orderString + " ) as TMP$ROWNUMBER"; var subQuery = "( SELECT " + columns + "," + rowNumExpression + " FROM " + table + whereOptions + " )"; whereOptions = ' WHERE'; var binds = {}; var offset = typeof options.offset === 'number' ? options.offset : 0; var limit = typeof options.limit === 'number' ? options.limit : 0; if (offset > 0) { whereOptions += ' TMP$ROWNUMBER > :TMP$OFFSET AND'; binds.TMP$OFFSET = offset; } if (limit > 0) { whereOptions += ' TMP$ROWNUMBER <= :TMP$LIMIT AND'; binds.TMP$LIMIT = limit + offset; } subQuery += whereOptions.slice(0, -4); return [subQuery, binds]; } exports.parserLimitOffset = parserLimitOffset; //# sourceMappingURL=limit-offset.parser.js.map