-
-
Notifications
You must be signed in to change notification settings - Fork 154
Feat: add triggers endpoints #116
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
Conversation
Adding the following list to keep track of development. PR Status:
|
This comment has been minimized.
This comment has been minimized.
@kiwicopple @soedirgo I have a bit more work to follow up 987f84f but wanted to push up my progress so everyone can play around with the endpoints and provide feedback. |
1f9fc50
to
263b1c6
Compare
src/lib/PostgresMetaTriggers.ts
Outdated
private splitQualifiedName(schemas: string[], fullName: string): string[] { | ||
const names = [] | ||
const sortedDescSchemas = schemas.sort((a, b) => b.length - a.length) | ||
|
||
for (const schema of sortedDescSchemas) { | ||
const startIdx = fullName.indexOf(schema) | ||
const splitIdx = schema.length | ||
|
||
if (startIdx === 0 && fullName[splitIdx] === '.') { | ||
names.push(fullName.slice(0, splitIdx)) | ||
names.push(fullName.slice(splitIdx + 1)) | ||
break | ||
} | ||
} | ||
|
||
return names[0] ? names : [fullName] | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@soedirgo this is something we discussed a few days ago about escaping qualified table names. Even though this has to make an additional query for existing schemas, thought it covers the edge case when schema name itself has period(s). It doesn't cover every edge case of qualified table names but I think it's more than good enough for now. Let me know what you think!
test/integration/index.spec.js
Outdated
describe('/triggers', () => { | ||
const trigger = { | ||
name: 'test_trigger', | ||
table: 'public.users_audit', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see you have a fully qualified function in the triggers logic, but I think on all the other routes we use table
and schema
. I think that's a bit cleaner
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kiwicopple sounds good, I'll go and make the changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@w3b6x9 left some comments. Bit of a chore to slog through, sorry about that... Let me know if you need some help, esp. for consuming the system catalog, it can be kinda finnicky sometimes.
At this point we are returning tiggers but the rest of the CRUD is not working
f03f85b
to
5492411
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, just a few more small changes and I think this is ready to be merged :)
@soedirgo thanks so much for the review! |
🎉 This PR is included in version 0.19.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Feat: add triggers endpoints
What kind of change does this PR introduce?
Fix #114