Skip to content

Commit eee84a9

Browse files
authored
Merge pull request #93 from stephenh/fix-excluding-pgsodium-schema
fix(main): escape underscore to avoid over-ignoring schemas
2 parents 0c197a0 + 3d3080f commit eee84a9

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

src/main.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ async function getSchemas(
8282
const where: string[] = ["NOT pg_is_other_temp_schema(oid)", "nspname <> 'pg_toast'"];
8383
const whereInclude: string[] = [];
8484
const parameters: string[] = [];
85-
const includedPatterns = include.concat(system && include.length > 0 ? ["information_schema", "pg_%"] : []);
86-
const excludedPatterns = exclude.concat(system ? [] : ["information_schema", "pg_%"]);
85+
const includedPatterns = include.concat(system && include.length > 0 ? ["information\\_schema", "pg\\_%"] : []);
86+
const excludedPatterns = exclude.concat(system ? [] : ["information\\_schema", "pg\\_%"]);
8787

8888
includedPatterns.forEach((pattern, i) => {
8989
whereInclude.push(`nspname LIKE $${i + 1}`); // nspname LIKE $1

src/pg-structure/constraint/foreign-key.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ export default class ForeignKey extends Constraint {
3131
this.columns = IndexableArray.throwingFrom(args.columns, "name");
3232
this.table = args.table;
3333
this.mandatoryParent = this.columns.every((column) => column.notNull);
34+
/* istanbul ignore if */
35+
if (this.index === undefined) throw new Error(`Foreign key ${this.fullName} did not find an index, it might be in another schema`);
3436
}
3537

3638
/**

src/types/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ export interface Options {
154154
* List of the schemas or a pattern similar to SQL's `LIKE` to select included schemas.
155155
*
156156
* @example
157-
* const config = { includeSchemas: "public_%" }; // include all schemas starting with "public_"
157+
* const config = { includeSchemas: "public\\_%" }; // include all schemas starting with "public_". `_` is an SQL wildcard character. You should escape it.
158158
*
159159
* @example
160160
* const config = { includeSchemas: ["public", "extra"] };

0 commit comments

Comments
 (0)