0
1
Fork 0
hedera-web-mindshore/js/sql/join-item.js

49 lines
730 B
JavaScript
Raw Normal View History

2022-05-30 01:30:33 +00:00
2022-06-06 08:53:59 +00:00
var Target = require('./target');
var Expr = require('./expr');
var SqlObject = require('./object');
var Type = require('./join').Type;
2022-05-30 01:30:33 +00:00
var TypeSql = [
'INNER',
'LEFT',
'RIGHT'
];
/**
* The equivalent of a SQL join.
*/
2022-06-06 08:53:59 +00:00
module.exports = new Class({
2022-05-30 01:30:33 +00:00
Extends: SqlObject
,Tag: 'sql-join-table'
2022-06-06 08:53:59 +00:00
,Properties: {
2022-05-30 01:30:33 +00:00
/**
* The join type.
*/
2022-06-06 08:53:59 +00:00
type: {
2022-05-30 01:30:33 +00:00
enumType: Type
,value: 0
},
/**
* The right target.
*/
2022-06-06 08:53:59 +00:00
target: {
2022-05-30 01:30:33 +00:00
type: Target
,value: null
},
/**
* The join on condition.
*/
2022-06-06 08:53:59 +00:00
condition: {
2022-05-30 01:30:33 +00:00
type: Expr
,value: null
}
}
2022-06-06 08:53:59 +00:00
,render: function(params) {
2022-05-30 01:30:33 +00:00
return TypeSql[this.type] +' JOIN '
2022-06-06 08:53:59 +00:00
+ this.target.render(params)
+ this.renderIfSet(this.condition, 'ON', params);
2022-05-30 01:30:33 +00:00
}
});