diff --git a/src/drivers/AbstractDriver.ts b/src/drivers/AbstractDriver.ts index 29d6873..c7781c1 100644 --- a/src/drivers/AbstractDriver.ts +++ b/src/drivers/AbstractDriver.ts @@ -31,13 +31,13 @@ export abstract class AbstractDriver { v => v.EntityName == relations[0].relatedTable )[0]; relatedTable1.Columns = relatedTable1.Columns.filter( - v => v.name != entity.EntityName + v => v.name.toLowerCase() != entity.EntityName.toLowerCase() ); let relatedTable2 = dbModel.entities.filter( v => v.EntityName == relations[1].relatedTable )[0]; relatedTable2.Columns = relatedTable2.Columns.filter( - v => v.name != entity.EntityName + v => v.name.toLowerCase() != entity.EntityName.toLowerCase() ); dbModel.entities = dbModel.entities.filter(ent => { return ent.EntityName != entity.EntityName; diff --git a/src/drivers/PostgresDriver.ts b/src/drivers/PostgresDriver.ts index a785979..a1a1b43 100644 --- a/src/drivers/PostgresDriver.ts +++ b/src/drivers/PostgresDriver.ts @@ -214,33 +214,31 @@ export class PostgresDriver extends AbstractDriver { is_unique: number; is_primary_key: number; //, is_descending_key: number//, is_included_column: number }[] = (await this.Connection.query(`SELECT - c.relname AS tablename, - i.relname as indexname, - f.attname AS columnname, - CASE - WHEN ix.indisunique = true THEN '1' - ELSE '0' - END AS is_unique, - CASE - WHEN p.contype = 'p' THEN '1' - ELSE '0' - END AS is_primary_key - FROM pg_attribute f - JOIN pg_class c ON c.oid = f.attrelid - JOIN pg_type t ON t.oid = f.atttypid - LEFT JOIN pg_attrdef d ON d.adrelid = c.oid AND d.adnum = f.attnum - LEFT JOIN pg_namespace n ON n.oid = c.relnamespace - LEFT JOIN pg_constraint p ON p.conrelid = c.oid AND f.attnum = ANY (p.conkey) - LEFT JOIN pg_class AS g ON p.confrelid = g.oid - LEFT JOIN pg_index AS ix ON f.attnum = ANY(ix.indkey) and c.oid = f.attrelid and c.oid = ix.indrelid - LEFT JOIN pg_class AS i ON ix.indexrelid = i.oid + c.relname AS tablename, + i.relname as indexname, + f.attname AS columnname, + CASE + WHEN ix.indisunique = true THEN '1' + ELSE '0' + END AS is_unique, + CASE + WHEN ix.indisprimary='true' THEN '1' + ELSE '0' + END AS is_primary_key + FROM pg_attribute f + JOIN pg_class c ON c.oid = f.attrelid + JOIN pg_type t ON t.oid = f.atttypid + LEFT JOIN pg_attrdef d ON d.adrelid = c.oid AND d.adnum = f.attnum + LEFT JOIN pg_namespace n ON n.oid = c.relnamespace + LEFT JOIN pg_index AS ix ON f.attnum = ANY(ix.indkey) and c.oid = f.attrelid and c.oid = ix.indrelid + LEFT JOIN pg_class AS i ON ix.indexrelid = i.oid - WHERE c.relkind = 'r'::char - AND n.nspname in (${schema}) - --AND c.relname = 'nodes' -- Replace with table name, or Comment this for get all tables - AND f.attnum > 0 - AND i.oid<>0 - ORDER BY c.relname,f.attname;`)).rows; + WHERE c.relkind = 'r'::char + AND n.nspname in (${schema}) + --AND c.relname = 'nodes' -- Replace with table name, or Comment this for get all tables + AND f.attnum > 0 + AND i.oid<>0 + ORDER BY c.relname,f.attname;`)).rows; entities.forEach(ent => { response .filter(filterVal => {