mirror of
https://github.com/xfarrow/blink
synced 2025-06-27 09:03:02 +02:00
Change endpoint from persons to people
This commit is contained in:
86
backend/apis/nodejs/node_modules/knex/lib/dialects/redshift/index.js
generated
vendored
Normal file
86
backend/apis/nodejs/node_modules/knex/lib/dialects/redshift/index.js
generated
vendored
Normal file
@ -0,0 +1,86 @@
|
||||
// Redshift
|
||||
// -------
|
||||
const Client_PG = require('../postgres');
|
||||
const map = require('lodash/map');
|
||||
|
||||
const Transaction = require('./transaction');
|
||||
const QueryCompiler = require('./query/redshift-querycompiler');
|
||||
const ColumnBuilder = require('./schema/redshift-columnbuilder');
|
||||
const ColumnCompiler = require('./schema/redshift-columncompiler');
|
||||
const TableCompiler = require('./schema/redshift-tablecompiler');
|
||||
const SchemaCompiler = require('./schema/redshift-compiler');
|
||||
const ViewCompiler = require('./schema/redshift-viewcompiler');
|
||||
|
||||
class Client_Redshift extends Client_PG {
|
||||
transaction() {
|
||||
return new Transaction(this, ...arguments);
|
||||
}
|
||||
|
||||
queryCompiler(builder, formatter) {
|
||||
return new QueryCompiler(this, builder, formatter);
|
||||
}
|
||||
|
||||
columnBuilder() {
|
||||
return new ColumnBuilder(this, ...arguments);
|
||||
}
|
||||
|
||||
columnCompiler() {
|
||||
return new ColumnCompiler(this, ...arguments);
|
||||
}
|
||||
|
||||
tableCompiler() {
|
||||
return new TableCompiler(this, ...arguments);
|
||||
}
|
||||
|
||||
schemaCompiler() {
|
||||
return new SchemaCompiler(this, ...arguments);
|
||||
}
|
||||
|
||||
viewCompiler() {
|
||||
return new ViewCompiler(this, ...arguments);
|
||||
}
|
||||
|
||||
_driver() {
|
||||
return require('pg');
|
||||
}
|
||||
|
||||
// Ensures the response is returned in the same format as other clients.
|
||||
processResponse(obj, runner) {
|
||||
const resp = obj.response;
|
||||
if (obj.output) return obj.output.call(runner, resp);
|
||||
if (obj.method === 'raw') return resp;
|
||||
if (resp.command === 'SELECT') {
|
||||
if (obj.method === 'first') return resp.rows[0];
|
||||
if (obj.method === 'pluck') return map(resp.rows, obj.pluck);
|
||||
return resp.rows;
|
||||
}
|
||||
if (
|
||||
resp.command === 'INSERT' ||
|
||||
resp.command === 'UPDATE' ||
|
||||
resp.command === 'DELETE'
|
||||
) {
|
||||
return resp.rowCount;
|
||||
}
|
||||
return resp;
|
||||
}
|
||||
|
||||
toPathForJson(jsonPath, builder, bindingsHolder) {
|
||||
return jsonPath
|
||||
.replace(/^(\$\.)/, '') // remove the first dollar
|
||||
.split('.')
|
||||
.map(
|
||||
function (v) {
|
||||
return this.parameter(v, builder, bindingsHolder);
|
||||
}.bind(this)
|
||||
)
|
||||
.join(', ');
|
||||
}
|
||||
}
|
||||
|
||||
Object.assign(Client_Redshift.prototype, {
|
||||
dialect: 'redshift',
|
||||
|
||||
driverName: 'pg-redshift',
|
||||
});
|
||||
|
||||
module.exports = Client_Redshift;
|
163
backend/apis/nodejs/node_modules/knex/lib/dialects/redshift/query/redshift-querycompiler.js
generated
vendored
Normal file
163
backend/apis/nodejs/node_modules/knex/lib/dialects/redshift/query/redshift-querycompiler.js
generated
vendored
Normal file
@ -0,0 +1,163 @@
|
||||
// Redshift Query Builder & Compiler
|
||||
// ------
|
||||
const QueryCompiler = require('../../../query/querycompiler');
|
||||
const QueryCompiler_PG = require('../../postgres/query/pg-querycompiler');
|
||||
|
||||
const identity = require('lodash/identity');
|
||||
const {
|
||||
columnize: columnize_,
|
||||
} = require('../../../formatter/wrappingFormatter');
|
||||
|
||||
class QueryCompiler_Redshift extends QueryCompiler_PG {
|
||||
truncate() {
|
||||
return `truncate ${this.tableName.toLowerCase()}`;
|
||||
}
|
||||
|
||||
// Compiles an `insert` query, allowing for multiple
|
||||
// inserts using a single query statement.
|
||||
insert() {
|
||||
const sql = QueryCompiler.prototype.insert.apply(this, arguments);
|
||||
if (sql === '') return sql;
|
||||
this._slightReturn();
|
||||
return {
|
||||
sql,
|
||||
};
|
||||
}
|
||||
|
||||
// Compiles an `update` query, warning on unsupported returning
|
||||
update() {
|
||||
const sql = QueryCompiler.prototype.update.apply(this, arguments);
|
||||
this._slightReturn();
|
||||
return {
|
||||
sql,
|
||||
};
|
||||
}
|
||||
|
||||
// Compiles an `delete` query, warning on unsupported returning
|
||||
del() {
|
||||
const sql = QueryCompiler.prototype.del.apply(this, arguments);
|
||||
this._slightReturn();
|
||||
return {
|
||||
sql,
|
||||
};
|
||||
}
|
||||
|
||||
// simple: if trying to return, warn
|
||||
_slightReturn() {
|
||||
if (this.single.isReturning) {
|
||||
this.client.logger.warn(
|
||||
'insert/update/delete returning is not supported by redshift dialect'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
forUpdate() {
|
||||
this.client.logger.warn('table lock is not supported by redshift dialect');
|
||||
return '';
|
||||
}
|
||||
|
||||
forShare() {
|
||||
this.client.logger.warn(
|
||||
'lock for share is not supported by redshift dialect'
|
||||
);
|
||||
return '';
|
||||
}
|
||||
|
||||
forNoKeyUpdate() {
|
||||
this.client.logger.warn('table lock is not supported by redshift dialect');
|
||||
return '';
|
||||
}
|
||||
|
||||
forKeyShare() {
|
||||
this.client.logger.warn(
|
||||
'lock for share is not supported by redshift dialect'
|
||||
);
|
||||
return '';
|
||||
}
|
||||
|
||||
// Compiles a columnInfo query
|
||||
columnInfo() {
|
||||
const column = this.single.columnInfo;
|
||||
let schema = this.single.schema;
|
||||
|
||||
// The user may have specified a custom wrapIdentifier function in the config. We
|
||||
// need to run the identifiers through that function, but not format them as
|
||||
// identifiers otherwise.
|
||||
const table = this.client.customWrapIdentifier(this.single.table, identity);
|
||||
|
||||
if (schema) {
|
||||
schema = this.client.customWrapIdentifier(schema, identity);
|
||||
}
|
||||
|
||||
const sql =
|
||||
'select * from information_schema.columns where table_name = ? and table_catalog = ?';
|
||||
const bindings = [
|
||||
table.toLowerCase(),
|
||||
this.client.database().toLowerCase(),
|
||||
];
|
||||
|
||||
return this._buildColumnInfoQuery(schema, sql, bindings, column);
|
||||
}
|
||||
|
||||
jsonExtract(params) {
|
||||
let extractions;
|
||||
if (Array.isArray(params.column)) {
|
||||
extractions = params.column;
|
||||
} else {
|
||||
extractions = [params];
|
||||
}
|
||||
return extractions
|
||||
.map((extraction) => {
|
||||
const jsonCol = `json_extract_path_text(${columnize_(
|
||||
extraction.column || extraction[0],
|
||||
this.builder,
|
||||
this.client,
|
||||
this.bindingsHolder
|
||||
)}, ${this.client.toPathForJson(
|
||||
params.path || extraction[1],
|
||||
this.builder,
|
||||
this.bindingsHolder
|
||||
)})`;
|
||||
const alias = extraction.alias || extraction[2];
|
||||
return alias
|
||||
? this.client.alias(jsonCol, this.formatter.wrap(alias))
|
||||
: jsonCol;
|
||||
})
|
||||
.join(', ');
|
||||
}
|
||||
|
||||
jsonSet(params) {
|
||||
throw new Error('Json set is not supported by Redshift');
|
||||
}
|
||||
|
||||
jsonInsert(params) {
|
||||
throw new Error('Json insert is not supported by Redshift');
|
||||
}
|
||||
|
||||
jsonRemove(params) {
|
||||
throw new Error('Json remove is not supported by Redshift');
|
||||
}
|
||||
|
||||
whereJsonPath(statement) {
|
||||
return this._whereJsonPath(
|
||||
'json_extract_path_text',
|
||||
Object.assign({}, statement, {
|
||||
path: this.client.toPathForJson(statement.path),
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
whereJsonSupersetOf(statement) {
|
||||
throw new Error('Json superset is not supported by Redshift');
|
||||
}
|
||||
|
||||
whereJsonSubsetOf(statement) {
|
||||
throw new Error('Json subset is not supported by Redshift');
|
||||
}
|
||||
|
||||
onJsonPathEquals(clause) {
|
||||
return this._onJsonPathEquals('json_extract_path_text', clause);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = QueryCompiler_Redshift;
|
22
backend/apis/nodejs/node_modules/knex/lib/dialects/redshift/schema/redshift-columnbuilder.js
generated
vendored
Normal file
22
backend/apis/nodejs/node_modules/knex/lib/dialects/redshift/schema/redshift-columnbuilder.js
generated
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
const ColumnBuilder = require('../../../schema/columnbuilder');
|
||||
|
||||
class ColumnBuilder_Redshift extends ColumnBuilder {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
}
|
||||
|
||||
// primary needs to set not null on non-preexisting columns, or fail
|
||||
primary() {
|
||||
this.notNullable();
|
||||
return super.primary(...arguments);
|
||||
}
|
||||
|
||||
index() {
|
||||
this.client.logger.warn(
|
||||
'Redshift does not support the creation of indexes.'
|
||||
);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = ColumnBuilder_Redshift;
|
67
backend/apis/nodejs/node_modules/knex/lib/dialects/redshift/schema/redshift-columncompiler.js
generated
vendored
Normal file
67
backend/apis/nodejs/node_modules/knex/lib/dialects/redshift/schema/redshift-columncompiler.js
generated
vendored
Normal file
@ -0,0 +1,67 @@
|
||||
// Redshift Column Compiler
|
||||
// -------
|
||||
|
||||
const ColumnCompiler_PG = require('../../postgres/schema/pg-columncompiler');
|
||||
const ColumnCompiler = require('../../../schema/columncompiler');
|
||||
|
||||
class ColumnCompiler_Redshift extends ColumnCompiler_PG {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
}
|
||||
|
||||
// Types:
|
||||
// ------
|
||||
|
||||
bit(column) {
|
||||
return column.length !== false ? `char(${column.length})` : 'char(1)';
|
||||
}
|
||||
|
||||
datetime(without) {
|
||||
return without ? 'timestamp' : 'timestamptz';
|
||||
}
|
||||
|
||||
timestamp(without) {
|
||||
return without ? 'timestamp' : 'timestamptz';
|
||||
}
|
||||
|
||||
// Modifiers:
|
||||
// ------
|
||||
comment(comment) {
|
||||
this.pushAdditional(function () {
|
||||
this.pushQuery(
|
||||
`comment on column ${this.tableCompiler.tableName()}.` +
|
||||
this.formatter.wrap(this.args[0]) +
|
||||
' is ' +
|
||||
(comment ? `'${comment}'` : 'NULL')
|
||||
);
|
||||
}, comment);
|
||||
}
|
||||
}
|
||||
|
||||
ColumnCompiler_Redshift.prototype.increments = ({ primaryKey = true } = {}) =>
|
||||
'integer identity(1,1)' + (primaryKey ? ' primary key' : '') + ' not null';
|
||||
ColumnCompiler_Redshift.prototype.bigincrements = ({
|
||||
primaryKey = true,
|
||||
} = {}) =>
|
||||
'bigint identity(1,1)' + (primaryKey ? ' primary key' : '') + ' not null';
|
||||
ColumnCompiler_Redshift.prototype.binary = 'varchar(max)';
|
||||
ColumnCompiler_Redshift.prototype.blob = 'varchar(max)';
|
||||
ColumnCompiler_Redshift.prototype.enu = 'varchar(255)';
|
||||
ColumnCompiler_Redshift.prototype.enum = 'varchar(255)';
|
||||
ColumnCompiler_Redshift.prototype.json = 'varchar(max)';
|
||||
ColumnCompiler_Redshift.prototype.jsonb = 'varchar(max)';
|
||||
ColumnCompiler_Redshift.prototype.longblob = 'varchar(max)';
|
||||
ColumnCompiler_Redshift.prototype.mediumblob = 'varchar(16777218)';
|
||||
ColumnCompiler_Redshift.prototype.set = 'text';
|
||||
ColumnCompiler_Redshift.prototype.text = 'varchar(max)';
|
||||
ColumnCompiler_Redshift.prototype.tinyblob = 'varchar(256)';
|
||||
ColumnCompiler_Redshift.prototype.uuid = ColumnCompiler.prototype.uuid;
|
||||
ColumnCompiler_Redshift.prototype.varbinary = 'varchar(max)';
|
||||
ColumnCompiler_Redshift.prototype.bigint = 'bigint';
|
||||
ColumnCompiler_Redshift.prototype.bool = 'boolean';
|
||||
ColumnCompiler_Redshift.prototype.double = 'double precision';
|
||||
ColumnCompiler_Redshift.prototype.floating = 'real';
|
||||
ColumnCompiler_Redshift.prototype.smallint = 'smallint';
|
||||
ColumnCompiler_Redshift.prototype.tinyint = 'smallint';
|
||||
|
||||
module.exports = ColumnCompiler_Redshift;
|
14
backend/apis/nodejs/node_modules/knex/lib/dialects/redshift/schema/redshift-compiler.js
generated
vendored
Normal file
14
backend/apis/nodejs/node_modules/knex/lib/dialects/redshift/schema/redshift-compiler.js
generated
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
/* eslint max-len: 0 */
|
||||
|
||||
// Redshift Table Builder & Compiler
|
||||
// -------
|
||||
|
||||
const SchemaCompiler_PG = require('../../postgres/schema/pg-compiler');
|
||||
|
||||
class SchemaCompiler_Redshift extends SchemaCompiler_PG {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = SchemaCompiler_Redshift;
|
122
backend/apis/nodejs/node_modules/knex/lib/dialects/redshift/schema/redshift-tablecompiler.js
generated
vendored
Normal file
122
backend/apis/nodejs/node_modules/knex/lib/dialects/redshift/schema/redshift-tablecompiler.js
generated
vendored
Normal file
@ -0,0 +1,122 @@
|
||||
/* eslint max-len: 0 */
|
||||
|
||||
// Redshift Table Builder & Compiler
|
||||
// -------
|
||||
|
||||
const has = require('lodash/has');
|
||||
const TableCompiler_PG = require('../../postgres/schema/pg-tablecompiler');
|
||||
|
||||
class TableCompiler_Redshift extends TableCompiler_PG {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
}
|
||||
|
||||
index(columns, indexName, options) {
|
||||
this.client.logger.warn(
|
||||
'Redshift does not support the creation of indexes.'
|
||||
);
|
||||
}
|
||||
|
||||
dropIndex(columns, indexName) {
|
||||
this.client.logger.warn(
|
||||
'Redshift does not support the deletion of indexes.'
|
||||
);
|
||||
}
|
||||
|
||||
// TODO: have to disable setting not null on columns that already exist...
|
||||
|
||||
// Adds the "create" query to the query sequence.
|
||||
createQuery(columns, ifNot, like) {
|
||||
const createStatement = ifNot
|
||||
? 'create table if not exists '
|
||||
: 'create table ';
|
||||
const columnsSql = ' (' + columns.sql.join(', ') + this._addChecks() + ')';
|
||||
let sql =
|
||||
createStatement +
|
||||
this.tableName() +
|
||||
(like && this.tableNameLike()
|
||||
? ' (like ' + this.tableNameLike() + ')'
|
||||
: columnsSql);
|
||||
if (this.single.inherits)
|
||||
sql += ` like (${this.formatter.wrap(this.single.inherits)})`;
|
||||
this.pushQuery({
|
||||
sql,
|
||||
bindings: columns.bindings,
|
||||
});
|
||||
const hasComment = has(this.single, 'comment');
|
||||
if (hasComment) this.comment(this.single.comment);
|
||||
if (like) {
|
||||
this.addColumns(columns, this.addColumnsPrefix);
|
||||
}
|
||||
}
|
||||
|
||||
primary(columns, constraintName) {
|
||||
const self = this;
|
||||
constraintName = constraintName
|
||||
? self.formatter.wrap(constraintName)
|
||||
: self.formatter.wrap(`${this.tableNameRaw}_pkey`);
|
||||
if (columns.constructor !== Array) {
|
||||
columns = [columns];
|
||||
}
|
||||
const thiscolumns = self.grouped.columns;
|
||||
|
||||
if (thiscolumns) {
|
||||
for (let i = 0; i < columns.length; i++) {
|
||||
let exists = thiscolumns.find(
|
||||
(tcb) =>
|
||||
tcb.grouping === 'columns' &&
|
||||
tcb.builder &&
|
||||
tcb.builder._method === 'add' &&
|
||||
tcb.builder._args &&
|
||||
tcb.builder._args.indexOf(columns[i]) > -1
|
||||
);
|
||||
if (exists) {
|
||||
exists = exists.builder;
|
||||
}
|
||||
const nullable = !(
|
||||
exists &&
|
||||
exists._modifiers &&
|
||||
exists._modifiers['nullable'] &&
|
||||
exists._modifiers['nullable'][0] === false
|
||||
);
|
||||
if (nullable) {
|
||||
if (exists) {
|
||||
return this.client.logger.warn(
|
||||
'Redshift does not allow primary keys to contain nullable columns.'
|
||||
);
|
||||
} else {
|
||||
return this.client.logger.warn(
|
||||
'Redshift does not allow primary keys to contain nonexistent columns.'
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return self.pushQuery(
|
||||
`alter table ${self.tableName()} add constraint ${constraintName} primary key (${self.formatter.columnize(
|
||||
columns
|
||||
)})`
|
||||
);
|
||||
}
|
||||
|
||||
// Compiles column add. Redshift can only add one column per ALTER TABLE, so core addColumns doesn't work. #2545
|
||||
addColumns(columns, prefix, colCompilers) {
|
||||
if (prefix === this.alterColumnsPrefix) {
|
||||
super.addColumns(columns, prefix, colCompilers);
|
||||
} else {
|
||||
prefix = prefix || this.addColumnsPrefix;
|
||||
colCompilers = colCompilers || this.getColumns();
|
||||
for (const col of colCompilers) {
|
||||
const quotedTableName = this.tableName();
|
||||
const colCompiled = col.compileColumn();
|
||||
|
||||
this.pushQuery({
|
||||
sql: `alter table ${quotedTableName} ${prefix}${colCompiled}`,
|
||||
bindings: [],
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = TableCompiler_Redshift;
|
11
backend/apis/nodejs/node_modules/knex/lib/dialects/redshift/schema/redshift-viewcompiler.js
generated
vendored
Normal file
11
backend/apis/nodejs/node_modules/knex/lib/dialects/redshift/schema/redshift-viewcompiler.js
generated
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
/* eslint max-len: 0 */
|
||||
|
||||
const ViewCompiler_PG = require('../../postgres/schema/pg-viewcompiler.js');
|
||||
|
||||
class ViewCompiler_Redshift extends ViewCompiler_PG {
|
||||
constructor(client, viewCompiler) {
|
||||
super(client, viewCompiler);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = ViewCompiler_Redshift;
|
32
backend/apis/nodejs/node_modules/knex/lib/dialects/redshift/transaction.js
generated
vendored
Normal file
32
backend/apis/nodejs/node_modules/knex/lib/dialects/redshift/transaction.js
generated
vendored
Normal file
@ -0,0 +1,32 @@
|
||||
const Transaction = require('../../execution/transaction');
|
||||
|
||||
module.exports = class Redshift_Transaction extends Transaction {
|
||||
begin(conn) {
|
||||
const trxMode = [
|
||||
this.isolationLevel ? `ISOLATION LEVEL ${this.isolationLevel}` : '',
|
||||
this.readOnly ? 'READ ONLY' : '',
|
||||
]
|
||||
.join(' ')
|
||||
.trim();
|
||||
|
||||
if (trxMode.length === 0) {
|
||||
return this.query(conn, 'BEGIN;');
|
||||
}
|
||||
return this.query(conn, `BEGIN ${trxMode};`);
|
||||
}
|
||||
|
||||
savepoint(conn) {
|
||||
this.trxClient.logger('Redshift does not support savepoints.');
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
release(conn, value) {
|
||||
this.trxClient.logger('Redshift does not support savepoints.');
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
rollbackTo(conn, error) {
|
||||
this.trxClient.logger('Redshift does not support savepoints.');
|
||||
return Promise.resolve();
|
||||
}
|
||||
};
|
Reference in New Issue
Block a user