pg-introspection
Advanced tools
Comparing version
# pg-introspection | ||
## 0.0.1-alpha.3 | ||
### Patch Changes | ||
- [#386](https://github.com/benjie/postgraphile-private/pull/386) | ||
[`8230fcaeb`](https://github.com/benjie/postgraphile-private/commit/8230fcaeb0286c905fc0dad4b7af2d94bac88a44) | ||
Thanks [@benjie](https://github.com/benjie)! - If an issue occurs whilst | ||
retrieving attributes for a constraint, we now log an error and return an | ||
empty array. | ||
## 0.0.1-alpha.2 | ||
@@ -4,0 +14,0 @@ |
@@ -183,5 +183,15 @@ "use strict"; | ||
const klass = getClass(entity.conrelid); | ||
if (!klass || !entity.conkey) { | ||
return; | ||
if (!klass) { | ||
console.error(`getAttributes() called on constraint '${entity.conname}' (type = '${entity.contype}'), but we could not find the constraint's table (oid = '${entity.conrelid}') in the introspection results; returning empty array`); | ||
return []; | ||
} | ||
if (!entity.conkey) { | ||
if (entity.contype === "f") { | ||
console.error(`getAttributes() called on constraint '${entity.conname}' (type = '${entity.contype}'), but that constraint has no 'conkey'; returning empty array`); | ||
return []; | ||
} | ||
else { | ||
return; | ||
} | ||
} | ||
const attrs = klass.getAttributes(); | ||
@@ -193,6 +203,25 @@ return entity.conkey.map((key) => attrs.find((att) => att.attnum === key)); | ||
entity.getForeignAttributes = memo(() => { | ||
if (entity.confrelid == null) { | ||
if (entity.contype === "f") { | ||
console.error(`getForeignAttributes() called on constraint '${entity.conname}' (type = '${entity.contype}'), but that constraint has no 'confrelid'; returning empty array`); | ||
return []; | ||
} | ||
else { | ||
return; | ||
} | ||
} | ||
const klass = getClass(entity.confrelid); | ||
if (!klass || !entity.confkey) { | ||
return; | ||
if (!klass) { | ||
console.error(`getForeignAttributes() called on constraint '${entity.conname}' (type = '${entity.contype}'), but we could not find the constraint's foreign table (oid = '${entity.confrelid}') in the introspection results; returning empty array`); | ||
return []; | ||
} | ||
if (!entity.confkey) { | ||
if (entity.contype === "f") { | ||
console.error(`getForeignAttributes() called on constraint '${entity.conname}' (type = '${entity.contype}'), but that constraint has no 'confkey'; returning empty array`); | ||
return []; | ||
} | ||
else { | ||
return; | ||
} | ||
} | ||
const attrs = klass.getAttributes(); | ||
@@ -199,0 +228,0 @@ return entity.confkey.map((key) => attrs.find((att) => att.attnum === key)); |
{ | ||
"name": "pg-introspection", | ||
"version": "0.0.1-alpha.2", | ||
"version": "0.0.1-alpha.3", | ||
"description": "Strongly typed PostgreSQL introspection library", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -27,10 +27,8 @@ # pg-introspection | ||
<table><tr> | ||
<td align="center"><a href="https://surge.io/"><img src="https://graphile.org/images/sponsors/surge.png" width="90" height="90" alt="Surge" /><br />Surge</a> *</td> | ||
<td align="center"><a href="https://www.the-guild.dev/"><img src="https://graphile.org/images/sponsors/theguild.png" width="90" height="90" alt="The Guild" /><br />The Guild</a> *</td> | ||
<td align="center"><a href="https://dovetailapp.com/"><img src="https://graphile.org/images/sponsors/dovetail.png" width="90" height="90" alt="Dovetail" /><br />Dovetail</a> *</td> | ||
<td align="center"><a href="https://qwick.com/"><img src="https://graphile.org/images/sponsors/qwick.png" width="90" height="90" alt="Qwick" /><br />Qwick</a> *</td> | ||
<td align="center"><a href="https://www.netflix.com/"><img src="https://graphile.org/images/sponsors/Netflix.png" width="90" height="90" alt="Netflix" /><br />Netflix</a> *</td> | ||
</tr><tr> | ||
<td align="center"><a href="https://www.netflix.com/"><img src="https://graphile.org/images/sponsors/Netflix.png" width="90" height="90" alt="Netflix" /><br />Netflix</a> *</td> | ||
<td align="center"><a href=""><img src="https://graphile.org/images/sponsors/chadf.png" width="90" height="90" alt="Chad Furman" /><br />Chad Furman</a> *</td> | ||
<td align="center"><a href="https://www.enzuzo.com/"><img src="https://graphile.org/images/sponsors/enzuzo.png" width="90" height="90" alt="Enzuzo" /><br />Enzuzo</a> *</td> | ||
<td align="center"><a href="https://stellate.co/"><img src="https://graphile.org/images/sponsors/Stellate.png" width="90" height="90" alt="Stellate" /><br />Stellate</a> *</td> | ||
@@ -37,0 +35,0 @@ </tr></table> |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
172796
1.52%2421
1.21%102
-1.92%