* Quote table name with optional alias and schema attribution * * @param {string|object} param table string or object * @param {string|boolean} alias alias name * * @returns {string}
(param, alias)
| 1089 | * @returns {string} |
| 1090 | */ |
| 1091 | quoteTable(param, alias) { |
| 1092 | let table = ''; |
| 1093 | |
| 1094 | if (alias === true) { |
| 1095 | alias = param.as || param.name || param; |
| 1096 | } |
| 1097 | |
| 1098 | if (_.isObject(param)) { |
| 1099 | if (this._dialect.supports.schemas) { |
| 1100 | if (param.schema) { |
| 1101 | table += `${this.quoteIdentifier(param.schema)}.`; |
| 1102 | } |
| 1103 | |
| 1104 | table += this.quoteIdentifier(param.tableName); |
| 1105 | } else { |
| 1106 | if (param.schema) { |
| 1107 | table += param.schema + (param.delimiter || '.'); |
| 1108 | } |
| 1109 | |
| 1110 | table += param.tableName; |
| 1111 | table = this.quoteIdentifier(table); |
| 1112 | } |
| 1113 | } else { |
| 1114 | table = this.quoteIdentifier(param); |
| 1115 | } |
| 1116 | |
| 1117 | if (alias) { |
| 1118 | table += ` ${this.getAliasToken()} ${this.quoteIdentifier(alias)}`; |
| 1119 | } |
| 1120 | |
| 1121 | return table; |
| 1122 | } |
| 1123 | |
| 1124 | /* |
| 1125 | Escape a value (e.g. a string, number or date) |