|
|
@ -34,6 +34,14 @@ var unaryMethod = function(name, operator) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
var contextify = function(base) { |
|
|
|
var context = Object.create(Column.prototype); |
|
|
|
Object.keys(base).forEach(function (key) { |
|
|
|
context[key] = base[key]; |
|
|
|
}) |
|
|
|
return context; |
|
|
|
} |
|
|
|
|
|
|
|
Column.prototype.value = function(value) { |
|
|
|
this._value = value; |
|
|
|
return this; |
|
|
@ -45,12 +53,13 @@ Column.prototype.getValue = function() { |
|
|
|
|
|
|
|
Column.prototype.toNode = function() { |
|
|
|
//creates a query node from this column
|
|
|
|
return new ColumnNode(this); |
|
|
|
return new ColumnNode(contextify(this)); |
|
|
|
} |
|
|
|
|
|
|
|
Column.prototype.as = function(alias) { |
|
|
|
this.alias = alias; |
|
|
|
return new ColumnNode(this); |
|
|
|
var context = contextify(this); |
|
|
|
context.alias = alias; |
|
|
|
return new ColumnNode(context); |
|
|
|
} |
|
|
|
|
|
|
|
binaryMethod('equals', '='); |
|
|
|