49 lines
730 B
JavaScript
49 lines
730 B
JavaScript
|
|
var Target = require('./target');
|
|
var Expr = require('./expr');
|
|
var SqlObject = require('./object');
|
|
var Type = require('./join').Type;
|
|
|
|
var TypeSql = [
|
|
'INNER',
|
|
'LEFT',
|
|
'RIGHT'
|
|
];
|
|
|
|
/**
|
|
* The equivalent of a SQL join.
|
|
*/
|
|
module.exports = new Class({
|
|
Extends: SqlObject
|
|
,Tag: 'sql-join-table'
|
|
,Properties: {
|
|
/**
|
|
* The join type.
|
|
*/
|
|
type: {
|
|
enumType: Type
|
|
,value: 0
|
|
},
|
|
/**
|
|
* The right target.
|
|
*/
|
|
target: {
|
|
type: Target
|
|
,value: null
|
|
},
|
|
/**
|
|
* The join on condition.
|
|
*/
|
|
condition: {
|
|
type: Expr
|
|
,value: null
|
|
}
|
|
}
|
|
|
|
,render: function(params) {
|
|
return TypeSql[this.type] +' JOIN '
|
|
+ this.target.render(params)
|
|
+ this.renderIfSet(this.condition, 'ON', params);
|
|
}
|
|
});
|