Skip to content

adds support for alter table in policy #423

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions contracts/TablelandPolicy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ struct TablelandPolicy {
bool allowUpdate;
// Whether or not the table should allow SQL DELETE statements.
bool allowDelete;
// Whether or not the table should allow SQL ALTER TABLE statements.
bool allowAlter;
// A conditional clause used with SQL UPDATE and DELETE statements.
// For example, a value of "foo > 0" will concatenate all SQL UPDATE
// and/or DELETE statements with "WHERE foo > 0".
Expand Down
1 change: 1 addition & 0 deletions contracts/TablelandTables.sol
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ contract TablelandTables is

return
TablelandPolicy({
allowAlter: true,
allowInsert: true,
allowUpdate: true,
allowDelete: true,
Expand Down
1 change: 1 addition & 0 deletions contracts/test/TestAllowAllTablelandController.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ contract TestAllowAllTablelandController is TablelandController {
// Return allow-all policy
return
TablelandPolicy({
allowAlter: true,
allowInsert: true,
allowUpdate: true,
allowDelete: true,
Expand Down
1 change: 1 addition & 0 deletions contracts/test/TestReentrancyMutate.sol
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ contract TestReentrancyMutate is TablelandController, ERC721, Ownable {
// Return allow-all policy
return
TablelandPolicy({
allowAlter: true,
allowInsert: true,
allowUpdate: true,
allowDelete: true,
Expand Down
1 change: 1 addition & 0 deletions contracts/test/TestReentrancyMutateOne.sol
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ contract TestReentrancyMutateOne is TablelandController, ERC721, Ownable {
// Return allow-all policy
return
TablelandPolicy({
allowAlter: true,
allowInsert: true,
allowUpdate: true,
allowDelete: true,
Expand Down
1 change: 1 addition & 0 deletions contracts/test/TestReentrancyRunSQLLegacy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ contract TestReentrancyRunSQLLegacy is TablelandController, ERC721, Ownable {
// Return allow-all policy
return
TablelandPolicy({
allowAlter: true,
allowInsert: true,
allowUpdate: true,
allowDelete: true,
Expand Down
1 change: 1 addition & 0 deletions contracts/test/TestTablelandController.sol
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ contract TestTablelandController is TablelandController, Ownable {
// Return policy
return
TablelandPolicy({
allowAlter: false,
allowInsert: false,
allowUpdate: true,
allowDelete: false,
Expand Down
1 change: 1 addition & 0 deletions contracts/test/TestTablelandTablesNoConstructor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ contract TestTablelandTablesNoConstructor is

return
TablelandPolicy({
allowAlter: true,
allowInsert: true,
allowUpdate: true,
allowDelete: true,
Expand Down
1 change: 1 addition & 0 deletions contracts/test/TestTablelandTablesUpgrade.sol
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ contract TestTablelandTablesUpgrade is

return
TablelandPolicy({
allowAlter: true,
allowInsert: true,
allowUpdate: true,
allowDelete: true,
Expand Down
1 change: 1 addition & 0 deletions test/unit/ITablelandController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,7 @@ describe("ITablelandController", function () {
expect(runEvent.args!.tableId).to.equal(tableId);
expect(runEvent.args!.statement).to.equal(runStatement);
expect(runEvent.args!.policy.allowInsert).to.equal(false);
expect(runEvent.args!.policy.allowAlter).to.equal(false);
expect(runEvent.args!.policy.allowUpdate).to.equal(true);
expect(runEvent.args!.policy.allowDelete).to.equal(false);
expect(runEvent.args!.policy.whereClause).to.equal(
Expand Down