Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Projections also project sort specifications

  • Loading branch information...
commit 9671fab13d5832106fa086a80bd2b04e878e80e7 1 parent 89e5368
Nathan Sobo authored
22 lib/monarch/model/relations/projection.js
View
@@ -8,11 +8,7 @@ _.constructor("Monarch.Model.Relations.Projection", Monarch.Model.Relations.Rela
this.projectedColumnsByName[projectedColumn.name()] = projectedColumn;
}, this);
-
- this.sortSpecifications = _.filter(operand.sortSpecifications, function(sortSpec) {
- return this.column(sortSpec.column.name)
- }, this);
-
+ this.sortSpecifications = this.projectSortSpecifications(projectedColumns, operand.sortSpecifications);
this.tupleConstructor = _.constructor(Monarch.Model.Tuple);
this.tupleConstructor.projectedColumnsByName = this.projectedColumnsByName;
this.tupleConstructor.initializeFieldReaders();
@@ -20,6 +16,22 @@ _.constructor("Monarch.Model.Relations.Projection", Monarch.Model.Relations.Rela
this.initializeEventsSystem();
},
+ projectSortSpecifications: function(projectedColumns, sortSpecifications) {
+ var projectedSortSpecifications = [];
+
+ _.each(sortSpecifications, function(sortSpec) {
+ var projectedColumn = _.detect(projectedColumns, function(projectedColumn) {
+ return projectedColumn.column === sortSpec.column;
+ });
+
+ if (projectedColumn) {
+ projectedSortSpecifications.push(new Monarch.Model.SortSpecification(projectedColumn, sortSpec.direction));
+ }
+ });
+
+ return projectedSortSpecifications;
+ },
+
tuples: function() {
if (this._tuples) return this._tuples.values();
4 lib/monarch/model/tuple.js
View
@@ -22,10 +22,6 @@ _.constructor("Monarch.Model.Tuple", {
} else {
projectedColumn = projectedColumnOrName;
}
-
-
- if (!projectedColumn.column) throw new Error("NULL POINTER EXCEPTION WILL HAPPEN LATeER");
-
return this.operandRecord.field(projectedColumn.column);
},
Please sign in to comment.
Something went wrong with that request. Please try again.