Skip to content

feat: batch endpoints for column creation and retrieval #206

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix(lib/columns): error handling
  • Loading branch information
soedirgo committed Mar 20, 2022
commit dc86a6ea5d9007291249840c00b8a512d85d5af0
9 changes: 6 additions & 3 deletions src/lib/PostgresMetaColumns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,14 @@ export default class PostgresMetaColumns {
}): Promise<PostgresMetaResult<PostgresColumn[]>> {
if (ids && ids.length > 0) {
const regexp = /^(\d+)\.(\d+)$/

const invalidId = ids.find((id) => !regexp.test(id))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would recommend findAll (or equivalent) here

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

if (invalidId) {
return { data: null, error: { message: `Invalid format for column ID: ${invalidId}` } }
}

const filteringClauses = ids
.map((id) => {
if (!regexp.test(id)) {
return { data: null, error: { message: 'Invalid format for column ID' } }
}
const matches = id.match(regexp) as RegExpMatchArray
const [tableId, ordinalPos] = matches.slice(1).map(Number)
return `(c.oid = ${tableId} AND a.attnum = ${ordinalPos})`
Expand Down