drivers query IN
This commit is contained in:
parent
defe6fd63f
commit
b1335eed7f
@ -40,12 +40,17 @@ export default class MssqlDriver extends AbstractDriver {
|
||||
public GetAllTablesQuery = async (
|
||||
schema: string,
|
||||
dbNames: string,
|
||||
tableNames: string[]
|
||||
notInTables: string[],
|
||||
inTables: string[]
|
||||
) => {
|
||||
const request = new this.MSSQL.Request(this.Connection);
|
||||
const tableCondition =
|
||||
tableNames.length > 0
|
||||
? ` AND NOT TABLE_NAME IN ('${tableNames.join("','")}')`
|
||||
notInTables.length > 0
|
||||
? ` AND NOT TABLE_NAME IN ('${notInTables.join("','")}')`
|
||||
: "";
|
||||
const inTableCondition =
|
||||
inTables.length > 0
|
||||
? ` AND TABLE_NAME IN ('${inTables.join("','")}')`
|
||||
: "";
|
||||
const response: {
|
||||
TABLE_SCHEMA: string;
|
||||
@ -56,7 +61,7 @@ export default class MssqlDriver extends AbstractDriver {
|
||||
`SELECT TABLE_SCHEMA,TABLE_NAME, table_catalog as "DB_NAME" FROM INFORMATION_SCHEMA.TABLES
|
||||
WHERE TABLE_TYPE='BASE TABLE' and TABLE_SCHEMA in (${schema}) AND TABLE_CATALOG in (${MssqlDriver.escapeCommaSeparatedList(
|
||||
dbNames
|
||||
)}) ${tableCondition}`
|
||||
)}) ${tableCondition} ${inTableCondition}`
|
||||
)
|
||||
).recordset;
|
||||
return response;
|
||||
|
@ -42,11 +42,16 @@ export default class MysqlDriver extends AbstractDriver {
|
||||
public GetAllTablesQuery = async (
|
||||
schema: string,
|
||||
dbNames: string,
|
||||
tableNames: string[]
|
||||
notInTables: string[],
|
||||
inTables: string[]
|
||||
) => {
|
||||
const tableCondition =
|
||||
tableNames.length > 0
|
||||
? ` AND NOT TABLE_NAME IN ('${tableNames.join("','")}')`
|
||||
notInTables.length > 0
|
||||
? ` AND NOT TABLE_NAME IN ('${notInTables.join("','")}')`
|
||||
: "";
|
||||
const inTableCondition =
|
||||
inTables.length > 0
|
||||
? ` AND TABLE_NAME IN ('${inTables.join("','")}')`
|
||||
: "";
|
||||
const response = this.ExecQuery<{
|
||||
TABLE_SCHEMA: string;
|
||||
@ -57,7 +62,7 @@ export default class MysqlDriver extends AbstractDriver {
|
||||
WHERE table_type='BASE TABLE'
|
||||
AND table_schema IN (${MysqlDriver.escapeCommaSeparatedList(
|
||||
dbNames
|
||||
)}) ${tableCondition}`);
|
||||
)}) ${tableCondition} ${inTableCondition}`);
|
||||
return response;
|
||||
};
|
||||
|
||||
|
@ -41,11 +41,16 @@ export default class OracleDriver extends AbstractDriver {
|
||||
public GetAllTablesQuery = async (
|
||||
schema: string,
|
||||
dbNames: string,
|
||||
tableNames: string[]
|
||||
notInTables: string[],
|
||||
inTables: string[]
|
||||
) => {
|
||||
const tableCondition =
|
||||
tableNames.length > 0
|
||||
? ` AND NOT TABLE_NAME IN ('${tableNames.join("','")}')`
|
||||
notInTables.length > 0
|
||||
? ` AND NOT TABLE_NAME IN ('${notInTables.join("','")}')`
|
||||
: "";
|
||||
const inTableCondition =
|
||||
inTables.length > 0
|
||||
? ` AND TABLE_NAME IN ('${inTables.join("','")}')`
|
||||
: "";
|
||||
const response = (
|
||||
await this.Connection.execute<{
|
||||
@ -53,7 +58,7 @@ export default class OracleDriver extends AbstractDriver {
|
||||
TABLE_NAME: string;
|
||||
DB_NAME: string;
|
||||
}>(
|
||||
`SELECT NULL AS TABLE_SCHEMA, TABLE_NAME, NULL AS DB_NAME FROM all_tables WHERE owner = (select user from dual) ${tableCondition}`
|
||||
`SELECT NULL AS TABLE_SCHEMA, TABLE_NAME, NULL AS DB_NAME FROM all_tables WHERE owner = (select user from dual) ${tableCondition} ${inTableCondition}`
|
||||
)
|
||||
).rows!;
|
||||
return response;
|
||||
|
@ -40,11 +40,16 @@ export default class PostgresDriver extends AbstractDriver {
|
||||
public GetAllTablesQuery = async (
|
||||
schema: string,
|
||||
dbNames: string,
|
||||
tableNames: string[]
|
||||
notInTables: string[],
|
||||
inTables: string[]
|
||||
) => {
|
||||
const tableCondition =
|
||||
tableNames.length > 0
|
||||
? ` AND NOT table_name IN ('${tableNames.join("','")}')`
|
||||
notInTables.length > 0
|
||||
? ` AND NOT table_name IN ('${notInTables.join("','")}')`
|
||||
: "";
|
||||
const inTableCondition =
|
||||
inTables.length > 0
|
||||
? ` AND table_name IN ('${inTables.join("','")}')`
|
||||
: "";
|
||||
const response: {
|
||||
TABLE_SCHEMA: string;
|
||||
@ -52,7 +57,7 @@ export default class PostgresDriver extends AbstractDriver {
|
||||
DB_NAME: string;
|
||||
}[] = (
|
||||
await this.Connection.query(
|
||||
`SELECT table_schema as "TABLE_SCHEMA",table_name as "TABLE_NAME", table_catalog as "DB_NAME" FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE='BASE TABLE' AND table_schema in (${schema}) ${tableCondition}`
|
||||
`SELECT table_schema as "TABLE_SCHEMA",table_name as "TABLE_NAME", table_catalog as "DB_NAME" FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE='BASE TABLE' AND table_schema in (${schema}) ${tableCondition} ${inTableCondition}`
|
||||
)
|
||||
).rows;
|
||||
return response;
|
||||
|
@ -47,16 +47,21 @@ export default class SqliteDriver extends AbstractDriver {
|
||||
public async GetAllTables(
|
||||
schema: string,
|
||||
dbNames: string,
|
||||
tableNames: string[]
|
||||
notInTables: string[],
|
||||
inTables: string[]
|
||||
): Promise<Entity[]> {
|
||||
const ret: Entity[] = [] as Entity[];
|
||||
const tableCondition =
|
||||
tableNames.length > 0
|
||||
? ` AND NOT tbl_name IN ('${tableNames.join("','")}')`
|
||||
notInTables.length > 0
|
||||
? ` AND NOT tbl_name IN ('${notInTables.join("','")}')`
|
||||
: "";
|
||||
const inTableCondition =
|
||||
inTables.length > 0
|
||||
? ` AND tbl_name IN ('${inTables.join("','")}')`
|
||||
: "";
|
||||
// eslint-disable-next-line camelcase
|
||||
const rows = await this.ExecQuery<{ tbl_name: string; sql: string }>(
|
||||
`SELECT tbl_name, sql FROM "sqlite_master" WHERE "type" = 'table' AND name NOT LIKE 'sqlite_%' ${tableCondition}`
|
||||
`SELECT tbl_name, sql FROM "sqlite_master" WHERE "type" = 'table' AND name NOT LIKE 'sqlite_%' ${tableCondition} ${inTableCondition}`
|
||||
);
|
||||
rows.forEach((val) => {
|
||||
if (val.sql.includes("AUTOINCREMENT")) {
|
||||
|
Loading…
Reference in New Issue
Block a user