Skip to content

Commit

Permalink
Update compiled version
Browse files Browse the repository at this point in the history
  • Loading branch information
allada committed Oct 27, 2015
1 parent b5d6b7e commit cd3bb43
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
6 changes: 5 additions & 1 deletion compiled/pql/PQL.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ var PQL = (function () {
var selects = _ref.selects;
var orderBys = _ref.orderBys;
var variables = _ref.variables;
var limit = _ref.limit;
var offset = _ref.offset;

var query_parser = new _parserJs.PARSER(query, table, false, this.defaultConfig, [], variables);
if (query_parser.hasError()) {
Expand Down Expand Up @@ -90,7 +92,9 @@ var PQL = (function () {
table: table,
group: group_parser,
selects: select_parsers,
orderBys: order_by_parsers
orderBys: order_by_parsers,
limit: limit,
offset: offset
});
return sb.toString();
}
Expand Down
31 changes: 30 additions & 1 deletion compiled/pql/parser/sql_builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ var SQL_BUILDER = (function () {
var group = _ref.group;
var selects = _ref.selects;
var orderBys = _ref.orderBys;
var limit = _ref.limit;
var offset = _ref.offset;

_classCallCheck(this, SQL_BUILDER);

Expand All @@ -27,6 +29,8 @@ var SQL_BUILDER = (function () {
this._group = group;
this._selects = selects;
this._orderBys = orderBys;
this._limit = limit;
this._offset = offset;

this._table_refs = new Map();
this._linked_tables = [];
Expand Down Expand Up @@ -63,6 +67,16 @@ var SQL_BUILDER = (function () {
value: function getTableName() {
return this.getQuery().getConfig().DB_MAP[this.getTable()].name;
}
}, {
key: 'getLimit',
value: function getLimit() {
return this._limit;
}
}, {
key: 'getOffset',
value: function getOffset() {
return this._offset;
}
}, {
key: 'toString',
value: function toString() {
Expand Down Expand Up @@ -134,7 +148,22 @@ var SQL_BUILDER = (function () {
join_str = '\n\t' + join_ary.join('\n\t');
}
}
return 'SELECT\n\t' + selects.join(',\n\t') + '\nFROM ' + this.constructor.escapeDBTableName(this.getTableName(), true) + join_str + query_str + group_str + having_str + order_by_str;

var limit = this.getLimit();
var offset = this.getOffset();
if (limit !== undefined && limit !== null) {
limit = '\nLIMIT ' + parseInt(limit);
if (offset !== undefined && offset !== null) {
offset = ' OFFSET ' + parseInt(offset);
} else {
offset = '';
}
} else {
limit = '';
offset = '';
}

return 'SELECT\n\t' + selects.join(',\n\t') + '\nFROM ' + this.constructor.escapeDBTableName(this.getTableName(), true) + join_str + query_str + group_str + having_str + order_by_str + limit + offset;
}
}, {
key: '_addTableLink',
Expand Down

0 comments on commit cd3bb43

Please sign in to comment.