Skip to content
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

feat(grants): support grant and revoke for roles, tables and schemas #865

Merged
merged 28 commits into from Apr 23, 2024

Conversation

littlewhywhat
Copy link
Contributor

@littlewhywhat littlewhywhat commented Jan 5, 2022

Add grant/revoke for roles, tables and schemas privileges

@littlewhywhat littlewhywhat force-pushed the gh-761-grants branch 3 times, most recently from 8485966 to 19f32da Compare January 5, 2022 14:22
@littlewhywhat littlewhywhat force-pushed the gh-761-grants branch 2 times, most recently from 1841c04 to 7fc52de Compare January 7, 2022 14:25
@Shinigami92 Shinigami92 linked an issue Jan 8, 2022 that may be closed by this pull request
@littlewhywhat littlewhywhat marked this pull request as ready for review January 11, 2022 00:38
@littlewhywhat littlewhywhat changed the title gh-761: Add grant gh-761: Add base support for grant/revoke Jan 11, 2022
@littlewhywhat
Copy link
Contributor Author

200 lines of prod code (types + logic) and 400 lines of tests (unit and migration ones). @goce-cz would you like to take a look? 👀

@goce-cz
Copy link
Contributor

goce-cz commented Jan 12, 2022

@littlewhywhat Sadly I won't get to it anytime soon. Sorry. I'll leave the judgement to you guys.

The only immediate remark I have is that there is a built-in function to recognize an array:

Array.isArray([])

@jaulz
Copy link

jaulz commented Dec 31, 2023

Any chance to take a look at this again? 😊
Happy new year to you guys anyway!

@Shinigami92
Copy link
Collaborator

Shinigami92 commented Jan 2, 2024

Uh... master branch has no updates for 2 years now 😬
Is this project actually dead?

I'm thinking about to fork this project and take it over 🤔

... #930 (reply in thread)

@Shinigami92 Shinigami92 self-assigned this Apr 5, 2024
@Shinigami92 Shinigami92 added the c: feature Request for new feature label Apr 5, 2024
@Shinigami92 Shinigami92 added this to the v7.x milestone Apr 5, 2024
@Shinigami92 Shinigami92 added needs rebase There is a merge conflict p: 1-normal Nothing urgent labels Apr 5, 2024
@Shinigami92
Copy link
Collaborator

I will revisit this for v7.1

@Shinigami92 Shinigami92 marked this pull request as draft April 5, 2024 22:41
Copy link

github-actions bot commented Apr 23, 2024

Coverage Report

Status Category Percentage Covered / Total
🟢 Lines 95.45% (🎯 90%)
⬆️ +0.26%
6549 / 6861
🟢 Statements 95.45% (🎯 90%)
⬆️ +0.26%
6549 / 6861
🟢 Functions 95.33% (🎯 90%)
⬆️ +0.31%
245 / 257
🟢 Branches 89.16% (🎯 85%)
⬆️ +0.42%
815 / 914
File Coverage
File Stmts % Branch % Funcs % Lines Uncovered Lines
Unchanged Files
src/db.ts 87.87% 88.46% 87.5% 87.87% 66-68, 97, 100-112, 152-154
src/index.ts 100% 100% 100% 100%
src/migration.ts 75.57% 78.04% 58.33% 75.57% 63, 66-68, 70-82, 111-116, 121-157, 214-215, 240-243, 251-252, 269-272, 301-302
src/migrationBuilder.ts 97.51% 92.3% 87.5% 97.51% 349-353, 487-492, 516-517
src/runner.ts 74.43% 58.18% 80% 74.43% 42, 69-70, 79-80, 84-91, 129-130, 169-172, 181-185, 198, 203-215, 234, 236-242, 245, 258, 270-283, 286-289, 299-300, 309-311, 320, 322-331, 343-350
src/sqlMigration.ts 91.83% 100% 80% 91.83% 46-49
src/types.ts 100% 100% 100% 100%
src/operations/sql.ts 100% 100% 100% 100%
src/operations/domains/alterDomain.ts 100% 100% 100% 100%
src/operations/domains/createDomain.ts 100% 100% 100% 100%
src/operations/domains/dropDomain.ts 100% 100% 100% 100%
src/operations/domains/index.ts 100% 100% 100% 100%
src/operations/domains/renameDomain.ts 100% 100% 100% 100%
src/operations/domains/shared.ts 100% 100% 100% 100%
src/operations/extensions/createExtension.ts 100% 100% 100% 100%
src/operations/extensions/dropExtension.ts 100% 100% 100% 100%
src/operations/extensions/index.ts 100% 100% 100% 100%
src/operations/extensions/shared.ts 100% 100% 100% 100%
src/operations/functions/createFunction.ts 100% 100% 100% 100%
src/operations/functions/dropFunction.ts 100% 100% 100% 100%
src/operations/functions/index.ts 100% 100% 100% 100%
src/operations/functions/renameFunction.ts 100% 100% 100% 100%
src/operations/functions/shared.ts 100% 100% 100% 100%
src/operations/grants/grantOnSchemas.ts 100% 100% 100% 100%
src/operations/grants/grantOnTables.ts 100% 100% 100% 100%
src/operations/grants/grantRoles.ts 100% 100% 100% 100%
src/operations/grants/index.ts 100% 100% 100% 100%
src/operations/grants/revokeOnSchemas.ts 100% 100% 100% 100%
src/operations/grants/revokeOnTables.ts 100% 100% 100% 100%
src/operations/grants/revokeRoles.ts 100% 100% 100% 100%
src/operations/grants/shared.ts 98.68% 90% 100% 98.68% 74
src/operations/indexes/createIndex.ts 98.01% 96% 100% 98.01% 68-69
src/operations/indexes/dropIndex.ts 97.61% 88.88% 100% 97.61% 26
src/operations/indexes/index.ts 100% 100% 100% 100%
src/operations/indexes/shared.ts 91.17% 86.95% 100% 91.17% 22, 32-35, 47
src/operations/materializedViews/alterMaterializedView.ts 100% 100% 100% 100%
src/operations/materializedViews/createMaterializedView.ts 100% 100% 100% 100%
src/operations/materializedViews/dropMaterializedView.ts 100% 100% 100% 100%
src/operations/materializedViews/index.ts 100% 100% 100% 100%
src/operations/materializedViews/refreshMaterializedView.ts 100% 100% 100% 100%
src/operations/materializedViews/renameMaterializedView.ts 100% 100% 100% 100%
src/operations/materializedViews/renameMaterializedViewColumn.ts 100% 100% 100% 100%
src/operations/materializedViews/shared.ts 100% 87.5% 100% 100%
src/operations/operators/addToOperatorFamily.ts 100% 100% 100% 100%
src/operations/operators/createOperator.ts 100% 88.88% 100% 100%
src/operations/operators/createOperatorClass.ts 100% 83.33% 100% 100%
src/operations/operators/createOperatorFamily.ts 100% 100% 100% 100%
src/operations/operators/dropOperator.ts 100% 87.5% 100% 100%
src/operations/operators/dropOperatorClass.ts 100% 100% 100% 100%
src/operations/operators/dropOperatorFamily.ts 100% 100% 100% 100%
src/operations/operators/index.ts 100% 100% 100% 100%
src/operations/operators/removeFromOperatorFamily.ts 100% 100% 100% 100%
src/operations/operators/renameOperatorClass.ts 100% 100% 100% 100%
src/operations/operators/renameOperatorFamily.ts 100% 100% 100% 100%
src/operations/operators/shared.ts 90% 75% 100% 90% 24-25, 37-38
src/operations/policies/alterPolicy.ts 100% 100% 100% 100%
src/operations/policies/createPolicy.ts 100% 100% 100% 100%
src/operations/policies/dropPolicy.ts 100% 100% 100% 100%
src/operations/policies/index.ts 100% 100% 100% 100%
src/operations/policies/renamePolicy.ts 100% 100% 100% 100%
src/operations/policies/shared.ts 100% 80% 100% 100%
src/operations/roles/alterRole.ts 100% 100% 100% 100%
src/operations/roles/createRole.ts 100% 75% 100% 100%
src/operations/roles/dropRole.ts 100% 100% 100% 100%
src/operations/roles/index.ts 100% 100% 100% 100%
src/operations/roles/renameRole.ts 100% 100% 100% 100%
src/operations/roles/shared.ts 96.15% 68.96% 100% 96.15% 78, 84, 91, 98
src/operations/schemas/createSchema.ts 100% 100% 100% 100%
src/operations/schemas/dropSchema.ts 100% 100% 100% 100%
src/operations/schemas/index.ts 100% 100% 100% 100%
src/operations/schemas/renameSchema.ts 100% 100% 100% 100%
src/operations/sequences/alterSequence.ts 96.87% 75% 100% 96.87% 23
src/operations/sequences/createSequence.ts 100% 100% 100% 100%
src/operations/sequences/dropSequence.ts 100% 100% 100% 100%
src/operations/sequences/index.ts 100% 100% 100% 100%
src/operations/sequences/renameSequence.ts 100% 100% 100% 100%
src/operations/sequences/shared.ts 87.67% 68.75% 100% 87.67% 41, 43-44, 49-50, 63-64, 69-70
src/operations/tables/addColumns.ts 100% 80% 100% 100%
src/operations/tables/addConstraint.ts 100% 100% 100% 100%
src/operations/tables/alterColumn.ts 91.66% 76.47% 100% 91.66% 75, 84-92
src/operations/tables/alterTable.ts 100% 100% 100% 100%
src/operations/tables/createTable.ts 90.12% 66.66% 100% 90.12% 43-47, 62, 72-73
src/operations/tables/dropColumns.ts 100% 100% 100% 100%
src/operations/tables/dropConstraint.ts 100% 100% 100% 100%
src/operations/tables/dropTable.ts 100% 100% 100% 100%
src/operations/tables/index.ts 100% 100% 100% 100%
src/operations/tables/renameColumn.ts 100% 100% 100% 100%
src/operations/tables/renameConstraint.ts 100% 100% 100% 100%
src/operations/tables/renameTable.ts 100% 100% 100% 100%
src/operations/tables/shared.ts 88.57% 80% 80% 88.57% 137-138, 141-142, 194-198, 223, 227-228, 247-248, 273-274, 277-284, 287-288, 430-455
src/operations/triggers/createTrigger.ts 90.98% 70.83% 100% 90.98% 55-56, 68-69, 72-73, 76-79, 115
src/operations/triggers/dropTrigger.ts 100% 100% 100% 100%
src/operations/triggers/index.ts 100% 100% 100% 100%
src/operations/triggers/renameTrigger.ts 100% 100% 100% 100%
src/operations/triggers/shared.ts 100% 100% 100% 100%
src/operations/types/addTypeAttribute.ts 100% 100% 100% 100%
src/operations/types/addTypeValue.ts 100% 100% 100% 100%
src/operations/types/createType.ts 100% 100% 100% 100%
src/operations/types/dropType.ts 100% 100% 100% 100%
src/operations/types/dropTypeAttribute.ts 100% 100% 100% 100%
src/operations/types/index.ts 100% 100% 100% 100%
src/operations/types/renameType.ts 100% 100% 100% 100%
src/operations/types/renameTypeAttribute.ts 100% 100% 100% 100%
src/operations/types/renameTypeValue.ts 100% 100% 100% 100%
src/operations/types/setTypeAttribute.ts 100% 100% 100% 100%
src/operations/views/alterView.ts 100% 100% 100% 100%
src/operations/views/alterViewColumn.ts 100% 100% 100% 100%
src/operations/views/createView.ts 100% 93.33% 100% 100%
src/operations/views/dropView.ts 100% 100% 100% 100%
src/operations/views/index.ts 100% 100% 100% 100%
src/operations/views/renameView.ts 100% 100% 100% 100%
src/operations/views/shared.ts 100% 66.66% 100% 100%
src/utils/PgLiteral.ts 96.49% 100% 66.66% 96.49% 37-38
src/utils/StringIdGenerator.ts 100% 100% 100% 100%
src/utils/createSchemalize.ts 100% 100% 100% 100%
src/utils/createTransformer.ts 100% 100% 100% 100%
src/utils/decamelize.ts 100% 100% 100% 100%
src/utils/escapeValue.ts 100% 100% 100% 100%
src/utils/formatLines.ts 100% 100% 100% 100%
src/utils/formatParams.ts 100% 100% 100% 100%
src/utils/getMigrationTableSchema.ts 100% 100% 100% 100%
src/utils/getSchemas.ts 100% 100% 100% 100%
src/utils/identity.ts 100% 100% 100% 100%
src/utils/index.ts 100% 100% 100% 100%
src/utils/intersection.ts 100% 100% 100% 100%
src/utils/makeComment.ts 100% 100% 100% 100%
src/utils/quote.ts 100% 100% 100% 100%
src/utils/types.ts 100% 100% 100% 100%
Generated in workflow #595

@Shinigami92
Copy link
Collaborator

I merged the state into the new project structure

Open TODOs:

@Shinigami92 Shinigami92 changed the title gh-761: Add base support for grant/revoke feat(grant): support grant/revoke Apr 23, 2024
@Shinigami92 Shinigami92 changed the title feat(grant): support grant/revoke feat(grants): support grant/revoke Apr 23, 2024
@Shinigami92 Shinigami92 removed the needs rebase There is a merge conflict label Apr 23, 2024
@Shinigami92 Shinigami92 changed the title feat(grants): support grant/revoke feat(grants): support grant and revoke for roles, tables and schemas Apr 23, 2024
@Shinigami92 Shinigami92 marked this pull request as ready for review April 23, 2024 13:26
Copy link
Collaborator

@Shinigami92 Shinigami92 left a comment

Choose a reason for hiding this comment

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

I will merge the current state for now and do a v7.1.0 release, so users can use this feature now
If there needs to be fixed or added some things, we can do that in later PRs
I would also like to extract some utility functions like the array and join into higher order utils, so it can be used not only for grant/revoke

@Shinigami92 Shinigami92 merged commit 658d46b into main Apr 23, 2024
33 checks passed
@Shinigami92 Shinigami92 deleted the gh-761-grants branch April 23, 2024 13:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: feature Request for new feature p: 1-normal Nothing urgent
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature request: implement grant helpers
4 participants