[jOOQ/jOOQ#10418] GrantOnStep.on(String) and RevokeOnStep.on(String) should wrap String argument in Name
This commit is contained in:
parent
75579d6080
commit
9ffd882d2f
@ -9758,6 +9758,87 @@ public interface DSLContext extends Scope , AutoCloseable {
|
||||
@Support({ CUBRID, FIREBIRD, H2, HSQLDB, MARIADB, POSTGRES })
|
||||
DropSequenceFinalStep dropSequenceIfExists(Sequence<?> sequence);
|
||||
|
||||
/**
|
||||
* The <code>GRANT</code> statement.
|
||||
*
|
||||
* @see DSL#grant(Privilege)
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ DERBY, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
|
||||
GrantOnStep grant(Privilege privileges);
|
||||
|
||||
/**
|
||||
* The <code>GRANT</code> statement.
|
||||
*
|
||||
* @see DSL#grant(Privilege...)
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ DERBY, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
|
||||
GrantOnStep grant(Privilege... privileges);
|
||||
|
||||
/**
|
||||
* The <code>GRANT</code> statement.
|
||||
*
|
||||
* @see DSL#grant(Collection)
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ DERBY, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
|
||||
GrantOnStep grant(Collection<? extends Privilege> privileges);
|
||||
|
||||
/**
|
||||
* The <code>REVOKE</code> statement.
|
||||
*
|
||||
* @see DSL#revoke(Privilege)
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ DERBY, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
|
||||
RevokeOnStep revoke(Privilege privileges);
|
||||
|
||||
/**
|
||||
* The <code>REVOKE</code> statement.
|
||||
*
|
||||
* @see DSL#revoke(Privilege...)
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ DERBY, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
|
||||
RevokeOnStep revoke(Privilege... privileges);
|
||||
|
||||
/**
|
||||
* The <code>REVOKE</code> statement.
|
||||
*
|
||||
* @see DSL#revoke(Collection)
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ DERBY, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
|
||||
RevokeOnStep revoke(Collection<? extends Privilege> privileges);
|
||||
|
||||
/**
|
||||
* The <code>REVOKE GRANT OPTION FOR</code> statement.
|
||||
*
|
||||
* @see DSL#revokeGrantOptionFor(Privilege)
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ HSQLDB, POSTGRES })
|
||||
RevokeOnStep revokeGrantOptionFor(Privilege privileges);
|
||||
|
||||
/**
|
||||
* The <code>REVOKE GRANT OPTION FOR</code> statement.
|
||||
*
|
||||
* @see DSL#revokeGrantOptionFor(Privilege...)
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ HSQLDB, POSTGRES })
|
||||
RevokeOnStep revokeGrantOptionFor(Privilege... privileges);
|
||||
|
||||
/**
|
||||
* The <code>REVOKE GRANT OPTION FOR</code> statement.
|
||||
*
|
||||
* @see DSL#revokeGrantOptionFor(Collection)
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ HSQLDB, POSTGRES })
|
||||
RevokeOnStep revokeGrantOptionFor(Collection<? extends Privilege> privileges);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
@ -11264,73 +11345,6 @@ public interface DSLContext extends Scope , AutoCloseable {
|
||||
@Support
|
||||
<R extends Record> TruncateIdentityStep<R> truncateTable(Table<R> table);
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX Access control
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Grant a privilege on a table to user or role.
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ DERBY, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
|
||||
GrantOnStep grant(Privilege privilege);
|
||||
|
||||
/**
|
||||
* Grant privileges on a table to user or role.
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ DERBY, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
|
||||
GrantOnStep grant(Privilege... privileges);
|
||||
|
||||
/**
|
||||
* Grant privileges on a table to user or role.
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ DERBY, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
|
||||
GrantOnStep grant(Collection<? extends Privilege> privileges);
|
||||
|
||||
/**
|
||||
* Revoke a privilege on table from user or role.
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ DERBY, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
|
||||
RevokeOnStep revoke(Privilege privilege);
|
||||
|
||||
/**
|
||||
* Revoke privileges on table from user or role.
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ DERBY, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
|
||||
RevokeOnStep revoke(Privilege... privileges);
|
||||
|
||||
/**
|
||||
* Revoke privileges on table from user or role.
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ DERBY, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
|
||||
RevokeOnStep revoke(Collection<? extends Privilege> privileges);
|
||||
|
||||
/**
|
||||
* Revoke grant option for a privilege on a table from user or role.
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ HSQLDB, POSTGRES })
|
||||
RevokeOnStep revokeGrantOptionFor(Privilege privilege);
|
||||
|
||||
/**
|
||||
* Revoke grant option for some privileges on a table from user or role.
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ HSQLDB, POSTGRES })
|
||||
RevokeOnStep revokeGrantOptionFor(Privilege... privileges);
|
||||
|
||||
/**
|
||||
* Revoke grant option for some privileges on a table from user or role.
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ HSQLDB, POSTGRES })
|
||||
RevokeOnStep revokeGrantOptionFor(Collection<? extends Privilege> privileges);
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX Other queries for identites and sequences
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@ -37,12 +37,33 @@
|
||||
*/
|
||||
package org.jooq;
|
||||
|
||||
import static org.jooq.SQLDialect.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import org.jetbrains.annotations.*;
|
||||
|
||||
/**
|
||||
* The final step in the creation of a <code>REVOKE</code> statement.
|
||||
*
|
||||
* @author Timur Shaidullin
|
||||
* @author Lukas Eder
|
||||
* A step in the construction of the <code>GRANT</code> statement.
|
||||
* <p>
|
||||
* <h3>Referencing <code>XYZ*Step</code> types directly from client code</h3>
|
||||
* <p>
|
||||
* It is usually not recommended to reference any <code>XYZ*Step</code> types
|
||||
* directly from client code, or assign them to local variables. When writing
|
||||
* dynamic SQL, creating a statement's components dynamically, and passing them
|
||||
* to the DSL API statically is usually a better choice. See the manual's
|
||||
* section about dynamic SQL for details: <a href=
|
||||
* "https://www.jooq.org/doc/latest/manual/sql-building/dynamic-sql">https://www.jooq.org/doc/latest/manual/sql-building/dynamic-sql</a>.
|
||||
* <p>
|
||||
* Drawbacks of referencing the <code>XYZ*Step</code> types directly:
|
||||
* <ul>
|
||||
* <li>They're operating on mutable implementations (as of jOOQ 3.x)</li>
|
||||
* <li>They're less composable and not easy to get right when dynamic SQL gets
|
||||
* complex</li>
|
||||
* <li>They're less readable</li>
|
||||
* <li>They might have binary incompatible changes between minor releases</li>
|
||||
* </ul>
|
||||
*/
|
||||
@SuppressWarnings({ "unused" })
|
||||
public interface GrantFinalStep extends DDLQuery {
|
||||
}
|
||||
|
||||
@ -37,55 +37,54 @@
|
||||
*/
|
||||
package org.jooq;
|
||||
|
||||
import static org.jooq.SQLDialect.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import org.jetbrains.annotations.*;
|
||||
|
||||
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.DERBY;
|
||||
import static org.jooq.SQLDialect.H2;
|
||||
import static org.jooq.SQLDialect.HSQLDB;
|
||||
import static org.jooq.SQLDialect.MARIADB;
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.MYSQL;
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.POSTGRES;
|
||||
// ...
|
||||
|
||||
/**
|
||||
* The step in the creation of a <code>GRANT</code> statement where the
|
||||
* <code>ON</code> clause can be added.
|
||||
*
|
||||
* @author Timur Shaidullin
|
||||
* @author Lukas Eder
|
||||
* A step in the construction of the <code>GRANT</code> statement.
|
||||
* <p>
|
||||
* <h3>Referencing <code>XYZ*Step</code> types directly from client code</h3>
|
||||
* <p>
|
||||
* It is usually not recommended to reference any <code>XYZ*Step</code> types
|
||||
* directly from client code, or assign them to local variables. When writing
|
||||
* dynamic SQL, creating a statement's components dynamically, and passing them
|
||||
* to the DSL API statically is usually a better choice. See the manual's
|
||||
* section about dynamic SQL for details: <a href=
|
||||
* "https://www.jooq.org/doc/latest/manual/sql-building/dynamic-sql">https://www.jooq.org/doc/latest/manual/sql-building/dynamic-sql</a>.
|
||||
* <p>
|
||||
* Drawbacks of referencing the <code>XYZ*Step</code> types directly:
|
||||
* <ul>
|
||||
* <li>They're operating on mutable implementations (as of jOOQ 3.x)</li>
|
||||
* <li>They're less composable and not easy to get right when dynamic SQL gets
|
||||
* complex</li>
|
||||
* <li>They're less readable</li>
|
||||
* <li>They might have binary incompatible changes between minor releases</li>
|
||||
* </ul>
|
||||
*/
|
||||
@SuppressWarnings({ "unused" })
|
||||
public interface GrantOnStep {
|
||||
|
||||
/**
|
||||
* Grant a privilege on a table.
|
||||
* Add the <code>ON</code> clause to the <code>GRANT</code> statement.
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ DERBY, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
|
||||
GrantToStep on(Table<?> table);
|
||||
@NotNull
|
||||
GrantToStep on(String on);
|
||||
|
||||
/**
|
||||
* Grant a privilege on a table.
|
||||
* Add the <code>ON</code> clause to the <code>GRANT</code> statement.
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ DERBY, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
|
||||
GrantToStep on(Name table);
|
||||
@NotNull
|
||||
GrantToStep on(Name on);
|
||||
|
||||
/**
|
||||
* Grant a privilege on a table.
|
||||
* <p>
|
||||
* <b>NOTE</b>: When inserting plain SQL into jOOQ objects, you must
|
||||
* guarantee syntax integrity. You may also create the possibility of
|
||||
* malicious SQL injection. Be sure to properly use bind variables and/or
|
||||
* escape literals when concatenated into SQL clauses!
|
||||
* Add the <code>ON</code> clause to the <code>GRANT</code> statement.
|
||||
*/
|
||||
@PlainSQL
|
||||
@NotNull
|
||||
@Support({ DERBY, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
|
||||
GrantToStep on(String table);
|
||||
@NotNull
|
||||
GrantToStep on(Table<?> on);
|
||||
}
|
||||
|
||||
@ -37,49 +37,54 @@
|
||||
*/
|
||||
package org.jooq;
|
||||
|
||||
import static org.jooq.SQLDialect.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import org.jetbrains.annotations.*;
|
||||
|
||||
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.DERBY;
|
||||
import static org.jooq.SQLDialect.H2;
|
||||
import static org.jooq.SQLDialect.HSQLDB;
|
||||
import static org.jooq.SQLDialect.MARIADB;
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.MYSQL;
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.POSTGRES;
|
||||
// ...
|
||||
|
||||
/**
|
||||
* The step in the creation of a <code>GRANT</code> statement where the
|
||||
* <code>TO</code> clause can be added.
|
||||
*
|
||||
* @author Timur Shaidullin
|
||||
* @author Lukas Eder
|
||||
* A step in the construction of the <code>GRANT</code> statement.
|
||||
* <p>
|
||||
* <h3>Referencing <code>XYZ*Step</code> types directly from client code</h3>
|
||||
* <p>
|
||||
* It is usually not recommended to reference any <code>XYZ*Step</code> types
|
||||
* directly from client code, or assign them to local variables. When writing
|
||||
* dynamic SQL, creating a statement's components dynamically, and passing them
|
||||
* to the DSL API statically is usually a better choice. See the manual's
|
||||
* section about dynamic SQL for details: <a href=
|
||||
* "https://www.jooq.org/doc/latest/manual/sql-building/dynamic-sql">https://www.jooq.org/doc/latest/manual/sql-building/dynamic-sql</a>.
|
||||
* <p>
|
||||
* Drawbacks of referencing the <code>XYZ*Step</code> types directly:
|
||||
* <ul>
|
||||
* <li>They're operating on mutable implementations (as of jOOQ 3.x)</li>
|
||||
* <li>They're less composable and not easy to get right when dynamic SQL gets
|
||||
* complex</li>
|
||||
* <li>They're less readable</li>
|
||||
* <li>They might have binary incompatible changes between minor releases</li>
|
||||
* </ul>
|
||||
*/
|
||||
@SuppressWarnings({ "unused" })
|
||||
public interface GrantToStep {
|
||||
|
||||
/**
|
||||
* Grant a privilege to a user.
|
||||
* Add the <code>TO</code> clause to the <code>GRANT</code> statement.
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ DERBY, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
|
||||
GrantWithGrantOptionStep to(User user);
|
||||
@NotNull
|
||||
GrantWithGrantOptionStep to(User to);
|
||||
|
||||
/**
|
||||
* Grant a privilege to a role.
|
||||
* Add the <code>TO</code> clause to the <code>GRANT</code> statement.
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ DERBY, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
|
||||
GrantWithGrantOptionStep to(Role role);
|
||||
@NotNull
|
||||
GrantWithGrantOptionStep to(Role to);
|
||||
|
||||
/**
|
||||
* Grant a privilege to <code>PUBLIC</code>.
|
||||
* Add the <code>TO PUBLIC</code> clause to the <code>GRANT</code> statement.
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ DERBY, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
|
||||
@NotNull
|
||||
GrantWithGrantOptionStep toPublic();
|
||||
}
|
||||
|
||||
@ -37,31 +37,40 @@
|
||||
*/
|
||||
package org.jooq;
|
||||
|
||||
import static org.jooq.SQLDialect.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import org.jetbrains.annotations.*;
|
||||
|
||||
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.HSQLDB;
|
||||
import static org.jooq.SQLDialect.MARIADB;
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.MYSQL;
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.POSTGRES;
|
||||
// ...
|
||||
|
||||
/**
|
||||
* The step of creation <code>GRANT</code> statement that assign user
|
||||
* or role a grant option.
|
||||
*
|
||||
* @author Timur Shaidullin
|
||||
* A step in the construction of the <code>GRANT</code> statement.
|
||||
* <p>
|
||||
* <h3>Referencing <code>XYZ*Step</code> types directly from client code</h3>
|
||||
* <p>
|
||||
* It is usually not recommended to reference any <code>XYZ*Step</code> types
|
||||
* directly from client code, or assign them to local variables. When writing
|
||||
* dynamic SQL, creating a statement's components dynamically, and passing them
|
||||
* to the DSL API statically is usually a better choice. See the manual's
|
||||
* section about dynamic SQL for details: <a href=
|
||||
* "https://www.jooq.org/doc/latest/manual/sql-building/dynamic-sql">https://www.jooq.org/doc/latest/manual/sql-building/dynamic-sql</a>.
|
||||
* <p>
|
||||
* Drawbacks of referencing the <code>XYZ*Step</code> types directly:
|
||||
* <ul>
|
||||
* <li>They're operating on mutable implementations (as of jOOQ 3.x)</li>
|
||||
* <li>They're less composable and not easy to get right when dynamic SQL gets
|
||||
* complex</li>
|
||||
* <li>They're less readable</li>
|
||||
* <li>They might have binary incompatible changes between minor releases</li>
|
||||
* </ul>
|
||||
*/
|
||||
public interface GrantWithGrantOptionStep extends GrantFinalStep{
|
||||
@SuppressWarnings({ "unused" })
|
||||
public interface GrantWithGrantOptionStep extends GrantFinalStep {
|
||||
|
||||
/**
|
||||
* Add the <code>WITH GRANT OPTION</code> clause.
|
||||
* Add the <code>WITH GRANT OPTION</code> clause to the <code>GRANT</code> statement.
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ HSQLDB, MARIADB, MYSQL, POSTGRES })
|
||||
@NotNull
|
||||
GrantFinalStep withGrantOption();
|
||||
}
|
||||
|
||||
@ -37,12 +37,33 @@
|
||||
*/
|
||||
package org.jooq;
|
||||
|
||||
import static org.jooq.SQLDialect.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import org.jetbrains.annotations.*;
|
||||
|
||||
/**
|
||||
* The final step in the creation of a <code>REVOKE</code> statement.
|
||||
*
|
||||
* @author Timur Shaidullin
|
||||
* @author Lukas Eder
|
||||
* A step in the construction of the <code>REVOKE</code> statement.
|
||||
* <p>
|
||||
* <h3>Referencing <code>XYZ*Step</code> types directly from client code</h3>
|
||||
* <p>
|
||||
* It is usually not recommended to reference any <code>XYZ*Step</code> types
|
||||
* directly from client code, or assign them to local variables. When writing
|
||||
* dynamic SQL, creating a statement's components dynamically, and passing them
|
||||
* to the DSL API statically is usually a better choice. See the manual's
|
||||
* section about dynamic SQL for details: <a href=
|
||||
* "https://www.jooq.org/doc/latest/manual/sql-building/dynamic-sql">https://www.jooq.org/doc/latest/manual/sql-building/dynamic-sql</a>.
|
||||
* <p>
|
||||
* Drawbacks of referencing the <code>XYZ*Step</code> types directly:
|
||||
* <ul>
|
||||
* <li>They're operating on mutable implementations (as of jOOQ 3.x)</li>
|
||||
* <li>They're less composable and not easy to get right when dynamic SQL gets
|
||||
* complex</li>
|
||||
* <li>They're less readable</li>
|
||||
* <li>They might have binary incompatible changes between minor releases</li>
|
||||
* </ul>
|
||||
*/
|
||||
@SuppressWarnings({ "unused" })
|
||||
public interface RevokeFinalStep extends DDLQuery {
|
||||
}
|
||||
|
||||
@ -37,49 +37,54 @@
|
||||
*/
|
||||
package org.jooq;
|
||||
|
||||
import static org.jooq.SQLDialect.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import org.jetbrains.annotations.*;
|
||||
|
||||
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.DERBY;
|
||||
import static org.jooq.SQLDialect.H2;
|
||||
import static org.jooq.SQLDialect.HSQLDB;
|
||||
import static org.jooq.SQLDialect.MARIADB;
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.MYSQL;
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.POSTGRES;
|
||||
// ...
|
||||
|
||||
/**
|
||||
* The step in the creation of a <code>REVOKE</code> statement where the
|
||||
* <code>FROM</code> clause can be added.
|
||||
*
|
||||
* @author Timur Shaidullin
|
||||
* @author Lukas Eder
|
||||
* A step in the construction of the <code>REVOKE</code> statement.
|
||||
* <p>
|
||||
* <h3>Referencing <code>XYZ*Step</code> types directly from client code</h3>
|
||||
* <p>
|
||||
* It is usually not recommended to reference any <code>XYZ*Step</code> types
|
||||
* directly from client code, or assign them to local variables. When writing
|
||||
* dynamic SQL, creating a statement's components dynamically, and passing them
|
||||
* to the DSL API statically is usually a better choice. See the manual's
|
||||
* section about dynamic SQL for details: <a href=
|
||||
* "https://www.jooq.org/doc/latest/manual/sql-building/dynamic-sql">https://www.jooq.org/doc/latest/manual/sql-building/dynamic-sql</a>.
|
||||
* <p>
|
||||
* Drawbacks of referencing the <code>XYZ*Step</code> types directly:
|
||||
* <ul>
|
||||
* <li>They're operating on mutable implementations (as of jOOQ 3.x)</li>
|
||||
* <li>They're less composable and not easy to get right when dynamic SQL gets
|
||||
* complex</li>
|
||||
* <li>They're less readable</li>
|
||||
* <li>They might have binary incompatible changes between minor releases</li>
|
||||
* </ul>
|
||||
*/
|
||||
@SuppressWarnings({ "unused" })
|
||||
public interface RevokeFromStep {
|
||||
|
||||
/**
|
||||
* Revoke a privilege from a user.
|
||||
* Add the <code>FROM</code> clause to the <code>REVOKE</code> statement.
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ DERBY, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
|
||||
RevokeFinalStep from(User user);
|
||||
@NotNull
|
||||
RevokeFinalStep from(User from);
|
||||
|
||||
/**
|
||||
* Revoke a privilege from a role.
|
||||
* Add the <code>FROM</code> clause to the <code>REVOKE</code> statement.
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ DERBY, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
|
||||
RevokeFinalStep from(Role role);
|
||||
@NotNull
|
||||
RevokeFinalStep from(Role from);
|
||||
|
||||
/**
|
||||
* Revoke a privilege from <code>PUBLIC</code>.
|
||||
* Add the <code>FROM PUBLIC</code> clause to the <code>REVOKE</code> statement.
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ DERBY, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
|
||||
@NotNull
|
||||
RevokeFinalStep fromPublic();
|
||||
}
|
||||
|
||||
@ -37,55 +37,54 @@
|
||||
*/
|
||||
package org.jooq;
|
||||
|
||||
import static org.jooq.SQLDialect.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import org.jetbrains.annotations.*;
|
||||
|
||||
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.DERBY;
|
||||
import static org.jooq.SQLDialect.H2;
|
||||
import static org.jooq.SQLDialect.HSQLDB;
|
||||
import static org.jooq.SQLDialect.MARIADB;
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.MYSQL;
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.POSTGRES;
|
||||
// ...
|
||||
|
||||
/**
|
||||
* The step in the creation of a <code>REVOKE</code> statement where the
|
||||
* <code>ON</code> clause can be added.
|
||||
*
|
||||
* @author Timur Shaidullin
|
||||
* @author Lukas Eder
|
||||
* A step in the construction of the <code>REVOKE</code> statement.
|
||||
* <p>
|
||||
* <h3>Referencing <code>XYZ*Step</code> types directly from client code</h3>
|
||||
* <p>
|
||||
* It is usually not recommended to reference any <code>XYZ*Step</code> types
|
||||
* directly from client code, or assign them to local variables. When writing
|
||||
* dynamic SQL, creating a statement's components dynamically, and passing them
|
||||
* to the DSL API statically is usually a better choice. See the manual's
|
||||
* section about dynamic SQL for details: <a href=
|
||||
* "https://www.jooq.org/doc/latest/manual/sql-building/dynamic-sql">https://www.jooq.org/doc/latest/manual/sql-building/dynamic-sql</a>.
|
||||
* <p>
|
||||
* Drawbacks of referencing the <code>XYZ*Step</code> types directly:
|
||||
* <ul>
|
||||
* <li>They're operating on mutable implementations (as of jOOQ 3.x)</li>
|
||||
* <li>They're less composable and not easy to get right when dynamic SQL gets
|
||||
* complex</li>
|
||||
* <li>They're less readable</li>
|
||||
* <li>They might have binary incompatible changes between minor releases</li>
|
||||
* </ul>
|
||||
*/
|
||||
@SuppressWarnings({ "unused" })
|
||||
public interface RevokeOnStep {
|
||||
|
||||
/**
|
||||
* Revoke a privilege on a table.
|
||||
* Add the <code>ON</code> clause to the <code>REVOKE</code> statement.
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ DERBY, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
|
||||
RevokeFromStep on(Table<?> table);
|
||||
@NotNull
|
||||
RevokeFromStep on(String on);
|
||||
|
||||
/**
|
||||
* Revoke a privilege on a table.
|
||||
* Add the <code>ON</code> clause to the <code>REVOKE</code> statement.
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ DERBY, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
|
||||
RevokeFromStep on(Name table);
|
||||
@NotNull
|
||||
RevokeFromStep on(Name on);
|
||||
|
||||
/**
|
||||
* Revoke a privilege on a table.
|
||||
* <p>
|
||||
* <b>NOTE</b>: When inserting plain SQL into jOOQ objects, you must
|
||||
* guarantee syntax integrity. You may also create the possibility of
|
||||
* malicious SQL injection. Be sure to properly use bind variables and/or
|
||||
* escape literals when concatenated into SQL clauses!
|
||||
* Add the <code>ON</code> clause to the <code>REVOKE</code> statement.
|
||||
*/
|
||||
@PlainSQL
|
||||
@NotNull
|
||||
@Support({ DERBY, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
|
||||
RevokeFromStep on(String table);
|
||||
@NotNull
|
||||
RevokeFromStep on(Table<?> on);
|
||||
}
|
||||
|
||||
@ -205,7 +205,6 @@ import org.jooq.False;
|
||||
import org.jooq.Field;
|
||||
import org.jooq.FieldOrRow;
|
||||
// ...
|
||||
import org.jooq.GrantOnStep;
|
||||
import org.jooq.GroupConcatOrderByStep;
|
||||
import org.jooq.GroupConcatSeparatorStep;
|
||||
import org.jooq.GroupField;
|
||||
@ -318,7 +317,6 @@ import org.jooq.RecordType;
|
||||
// ...
|
||||
import org.jooq.Result;
|
||||
import org.jooq.ResultQuery;
|
||||
import org.jooq.RevokeOnStep;
|
||||
import org.jooq.Role;
|
||||
import org.jooq.Row;
|
||||
import org.jooq.Row1;
|
||||
@ -7871,6 +7869,105 @@ public class DSL {
|
||||
return dsl().dropSequenceIfExists(sequence);
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>GRANT</code> statement.
|
||||
*
|
||||
* @see DSLContext#grant(Privilege)
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ DERBY, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
|
||||
public static org.jooq.GrantOnStep grant(Privilege privileges) {
|
||||
return dsl().grant(privileges);
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>GRANT</code> statement.
|
||||
*
|
||||
* @see DSLContext#grant(Privilege...)
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ DERBY, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
|
||||
public static org.jooq.GrantOnStep grant(Privilege... privileges) {
|
||||
return dsl().grant(privileges);
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>GRANT</code> statement.
|
||||
*
|
||||
* @see DSLContext#grant(Collection)
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ DERBY, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
|
||||
public static org.jooq.GrantOnStep grant(Collection<? extends Privilege> privileges) {
|
||||
return dsl().grant(privileges);
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>REVOKE</code> statement.
|
||||
*
|
||||
* @see DSLContext#revoke(Privilege)
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ DERBY, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
|
||||
public static org.jooq.RevokeOnStep revoke(Privilege privileges) {
|
||||
return dsl().revoke(privileges);
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>REVOKE</code> statement.
|
||||
*
|
||||
* @see DSLContext#revoke(Privilege...)
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ DERBY, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
|
||||
public static org.jooq.RevokeOnStep revoke(Privilege... privileges) {
|
||||
return dsl().revoke(privileges);
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>REVOKE</code> statement.
|
||||
*
|
||||
* @see DSLContext#revoke(Collection)
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ DERBY, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
|
||||
public static org.jooq.RevokeOnStep revoke(Collection<? extends Privilege> privileges) {
|
||||
return dsl().revoke(privileges);
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>REVOKE GRANT OPTION FOR</code> statement.
|
||||
*
|
||||
* @see DSLContext#revokeGrantOptionFor(Privilege)
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ HSQLDB, POSTGRES })
|
||||
public static org.jooq.RevokeOnStep revokeGrantOptionFor(Privilege privileges) {
|
||||
return dsl().revokeGrantOptionFor(privileges);
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>REVOKE GRANT OPTION FOR</code> statement.
|
||||
*
|
||||
* @see DSLContext#revokeGrantOptionFor(Privilege...)
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ HSQLDB, POSTGRES })
|
||||
public static org.jooq.RevokeOnStep revokeGrantOptionFor(Privilege... privileges) {
|
||||
return dsl().revokeGrantOptionFor(privileges);
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>REVOKE GRANT OPTION FOR</code> statement.
|
||||
*
|
||||
* @see DSLContext#revokeGrantOptionFor(Collection)
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ HSQLDB, POSTGRES })
|
||||
public static org.jooq.RevokeOnStep revokeGrantOptionFor(Collection<? extends Privilege> privileges) {
|
||||
return dsl().revokeGrantOptionFor(privileges);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
@ -9544,199 +9641,6 @@ public class DSL {
|
||||
return new QuantifiedSelectImpl<>(Quantifier.ANY, fields);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX Access control
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Grant a privilege on table to user or role.
|
||||
*
|
||||
* <p>
|
||||
* Example: <code><pre>
|
||||
* import static org.jooq.impl.DSL.*;
|
||||
*
|
||||
* grant(privilege)
|
||||
* .on(table)
|
||||
* .to(user)
|
||||
* .execute();
|
||||
*
|
||||
* grant(privilege)
|
||||
* .on(table)
|
||||
* .to(role)
|
||||
* .execute();
|
||||
* </pre></code>
|
||||
*
|
||||
*
|
||||
* @see #grant(Collection)
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ DERBY, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
|
||||
public static GrantOnStep grant(Privilege privilege) {
|
||||
return dsl().grant(privilege);
|
||||
}
|
||||
|
||||
/**
|
||||
* Grant privileges on table to user or role.
|
||||
*
|
||||
* <p>
|
||||
* Example: <code><pre>
|
||||
* import static org.jooq.impl.DSL.*;
|
||||
*
|
||||
* grant(privilege)
|
||||
* .on(table)
|
||||
* .to(user)
|
||||
* .execute();
|
||||
*
|
||||
* grant(privilege)
|
||||
* .on(table)
|
||||
* .to(role)
|
||||
* .execute();
|
||||
* </pre></code>
|
||||
*
|
||||
*
|
||||
* @see #grant(Collection)
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ DERBY, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
|
||||
public static GrantOnStep grant(Privilege... privileges) {
|
||||
return dsl().grant(privileges);
|
||||
}
|
||||
|
||||
/**
|
||||
* Grant privileges on table to user or role.
|
||||
*
|
||||
* <p>
|
||||
* Example: <code><pre>
|
||||
* import static org.jooq.impl.DSL.*;
|
||||
*
|
||||
* grant(privileges)
|
||||
* .on(table)
|
||||
* .to(user)
|
||||
* .execute();
|
||||
*
|
||||
* grant(privileges)
|
||||
* .on(table)
|
||||
* .to(role)
|
||||
* .execute();
|
||||
* </pre></code>
|
||||
* <p>
|
||||
*
|
||||
* @see #grant(Privilege...)
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ DERBY, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
|
||||
public static GrantOnStep grant(Collection<? extends Privilege> privileges) {
|
||||
return dsl().grant(privileges);
|
||||
}
|
||||
|
||||
/**
|
||||
* Revoke a privilege on table from user or role.
|
||||
*
|
||||
* <p>
|
||||
* Example: <code><pre>
|
||||
* import static org.jooq.impl.DSL.*;
|
||||
*
|
||||
* revoke(privilege)
|
||||
* .on(table)
|
||||
* .from(user)
|
||||
* .execute();
|
||||
*
|
||||
* revoke(privilege)
|
||||
* .on(table)
|
||||
* .from(role)
|
||||
* .execute();
|
||||
* </pre></code>
|
||||
* <p>
|
||||
*
|
||||
* @see #revoke(Collection)
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ DERBY, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
|
||||
public static RevokeOnStep revoke(Privilege privilege) {
|
||||
return dsl().revoke(privilege);
|
||||
}
|
||||
|
||||
/**
|
||||
* Revoke privileges on table from user or role.
|
||||
*
|
||||
* <p>
|
||||
* Example: <code><pre>
|
||||
* import static org.jooq.impl.DSL.*;
|
||||
*
|
||||
* revoke(privilege)
|
||||
* .on(table)
|
||||
* .from(user)
|
||||
* .execute();
|
||||
*
|
||||
* revoke(privilege)
|
||||
* .on(table)
|
||||
* .from(role)
|
||||
* .execute();
|
||||
* </pre></code>
|
||||
* <p>
|
||||
*
|
||||
* @see #revoke(Collection)
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ DERBY, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
|
||||
public static RevokeOnStep revoke(Privilege... privileges) {
|
||||
return dsl().revoke(privileges);
|
||||
}
|
||||
|
||||
/**
|
||||
* Revoke privileges on table from user or role.
|
||||
*
|
||||
* <p>
|
||||
* Example: <code><pre>
|
||||
* import static org.jooq.impl.DSL.*;
|
||||
*
|
||||
* revoke(privileges)
|
||||
* .on(table)
|
||||
* .from(user)
|
||||
* .execute();
|
||||
*
|
||||
* revoke(privileges)
|
||||
* .on(table)
|
||||
* .from(role)
|
||||
* .execute();
|
||||
* </pre></code>
|
||||
* <p>
|
||||
*
|
||||
* @see #revoke(Privilege...)
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ DERBY, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
|
||||
public static RevokeOnStep revoke(Collection<? extends Privilege> privileges) {
|
||||
return dsl().revoke(privileges);
|
||||
}
|
||||
|
||||
/**
|
||||
* Revoke grant option for a privilege on a table from user or role.
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ HSQLDB, POSTGRES })
|
||||
public static RevokeOnStep revokeGrantOptionFor(Privilege privilege) {
|
||||
return dsl().revoke(privilege);
|
||||
}
|
||||
|
||||
/**
|
||||
* Revoke grant option for some privileges on a table from user or role.
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ HSQLDB, POSTGRES })
|
||||
public static RevokeOnStep revokeGrantOptionFor(Privilege... privileges) {
|
||||
return dsl().revoke(privileges);
|
||||
}
|
||||
|
||||
/**
|
||||
* Revoke grant option for some privileges on a table from user or role.
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ HSQLDB, POSTGRES })
|
||||
public static RevokeOnStep revokeGrantOptionFor(Collection<? extends Privilege> privileges) {
|
||||
return dsl().revoke(privileges);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX Other objects
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@ -133,7 +133,6 @@ import org.jooq.ExecuteContext;
|
||||
import org.jooq.ExecuteListener;
|
||||
import org.jooq.Explain;
|
||||
import org.jooq.Field;
|
||||
import org.jooq.GrantOnStep;
|
||||
import org.jooq.Index;
|
||||
import org.jooq.InsertQuery;
|
||||
import org.jooq.InsertSetStep;
|
||||
@ -222,7 +221,6 @@ import org.jooq.RenderContext;
|
||||
import org.jooq.Result;
|
||||
import org.jooq.ResultQuery;
|
||||
import org.jooq.Results;
|
||||
import org.jooq.RevokeOnStep;
|
||||
import org.jooq.RowCountQuery;
|
||||
import org.jooq.SQL;
|
||||
import org.jooq.SQLDialect;
|
||||
@ -3244,6 +3242,51 @@ public class DefaultDSLContext extends AbstractScope implements DSLContext, Seri
|
||||
return new DropSequenceImpl(configuration(), sequence, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.jooq.GrantOnStep grant(Privilege privileges) {
|
||||
return new GrantImpl(configuration(), Arrays.asList(privileges));
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.jooq.GrantOnStep grant(Privilege... privileges) {
|
||||
return new GrantImpl(configuration(), Arrays.asList(privileges));
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.jooq.GrantOnStep grant(Collection<? extends Privilege> privileges) {
|
||||
return new GrantImpl(configuration(), privileges);
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.jooq.RevokeOnStep revoke(Privilege privileges) {
|
||||
return new RevokeImpl(configuration(), Arrays.asList(privileges), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.jooq.RevokeOnStep revoke(Privilege... privileges) {
|
||||
return new RevokeImpl(configuration(), Arrays.asList(privileges), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.jooq.RevokeOnStep revoke(Collection<? extends Privilege> privileges) {
|
||||
return new RevokeImpl(configuration(), privileges, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.jooq.RevokeOnStep revokeGrantOptionFor(Privilege privileges) {
|
||||
return new RevokeImpl(configuration(), Arrays.asList(privileges), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.jooq.RevokeOnStep revokeGrantOptionFor(Privilege... privileges) {
|
||||
return new RevokeImpl(configuration(), Arrays.asList(privileges), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.jooq.RevokeOnStep revokeGrantOptionFor(Collection<? extends Privilege> privileges) {
|
||||
return new RevokeImpl(configuration(), privileges, true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
@ -4026,55 +4069,6 @@ public class DefaultDSLContext extends AbstractScope implements DSLContext, Seri
|
||||
return new TruncateImpl<>(configuration(), table);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX Access control
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public GrantOnStep grant(Privilege privilege) {
|
||||
return grant(Arrays.asList(privilege));
|
||||
}
|
||||
|
||||
@Override
|
||||
public GrantOnStep grant(Privilege... privileges) {
|
||||
return grant(Arrays.asList(privileges));
|
||||
}
|
||||
|
||||
@Override
|
||||
public GrantOnStep grant(Collection<? extends Privilege> privileges) {
|
||||
return new GrantImpl(configuration(), privileges);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RevokeOnStep revoke(Privilege privilege) {
|
||||
return revoke(Arrays.asList(privilege));
|
||||
}
|
||||
|
||||
@Override
|
||||
public RevokeOnStep revoke(Privilege... privileges) {
|
||||
return revoke(Arrays.asList(privileges));
|
||||
}
|
||||
|
||||
@Override
|
||||
public RevokeOnStep revoke(Collection<? extends Privilege> privileges) {
|
||||
return new RevokeImpl(configuration(), privileges);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RevokeOnStep revokeGrantOptionFor(Privilege privilege) {
|
||||
return revokeGrantOptionFor(Arrays.asList(privilege));
|
||||
}
|
||||
|
||||
@Override
|
||||
public RevokeOnStep revokeGrantOptionFor(Privilege... privileges) {
|
||||
return revokeGrantOptionFor(Arrays.asList(privileges));
|
||||
}
|
||||
|
||||
@Override
|
||||
public RevokeOnStep revokeGrantOptionFor(Collection<? extends Privilege> privileges) {
|
||||
return new RevokeImpl(configuration(), privileges, true);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX Other queries for identites and sequences
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@ -37,90 +37,151 @@
|
||||
*/
|
||||
package org.jooq.impl;
|
||||
|
||||
import static org.jooq.Clause.GRANT;
|
||||
import static org.jooq.Clause.GRANT_ON;
|
||||
import static org.jooq.Clause.GRANT_PRIVILEGE;
|
||||
import static org.jooq.Clause.GRANT_TO;
|
||||
import static org.jooq.impl.DSL.table;
|
||||
import static org.jooq.impl.Keywords.K_GRANT;
|
||||
import static org.jooq.impl.Keywords.K_ON;
|
||||
import static org.jooq.impl.Keywords.K_PUBLIC;
|
||||
import static org.jooq.impl.Keywords.K_TO;
|
||||
import static org.jooq.impl.Keywords.K_WITH_GRANT_OPTION;
|
||||
import static org.jooq.impl.QueryPartCollectionView.wrap;
|
||||
import static org.jooq.impl.DSL.*;
|
||||
import static org.jooq.impl.Keywords.*;
|
||||
import static org.jooq.impl.Names.*;
|
||||
import static org.jooq.impl.SQLDataType.*;
|
||||
import static org.jooq.impl.Tools.BooleanDataKey.*;
|
||||
import static org.jooq.SQLDialect.*;
|
||||
|
||||
import java.util.Collection;
|
||||
import org.jooq.*;
|
||||
import org.jooq.impl.*;
|
||||
|
||||
import org.jooq.Clause;
|
||||
import org.jooq.Configuration;
|
||||
import org.jooq.Context;
|
||||
import org.jooq.GrantOnStep;
|
||||
import org.jooq.GrantToStep;
|
||||
import org.jooq.GrantWithGrantOptionStep;
|
||||
import org.jooq.Name;
|
||||
import org.jooq.Privilege;
|
||||
import org.jooq.Role;
|
||||
import org.jooq.Table;
|
||||
import org.jooq.User;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Grant privilege or privileges on a table to user or role.
|
||||
*
|
||||
* @author Timur Shaidullin
|
||||
* The <code>GRANT</code> statement.
|
||||
*/
|
||||
final class GrantImpl extends AbstractRowCountQuery implements
|
||||
|
||||
// Cascading interface implementations for Select behaviour
|
||||
@SuppressWarnings({ "hiding", "rawtypes", "unchecked", "unused" })
|
||||
final class GrantImpl
|
||||
extends
|
||||
AbstractRowCountQuery
|
||||
implements
|
||||
GrantOnStep,
|
||||
GrantToStep,
|
||||
GrantWithGrantOptionStep {
|
||||
GrantWithGrantOptionStep,
|
||||
GrantFinalStep
|
||||
{
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Generated UID
|
||||
*/
|
||||
private static final long serialVersionUID = -6509384254822040545L;
|
||||
private static final Clause[] CLAUSE = { GRANT };
|
||||
private final Collection<? extends Privilege> privileges;
|
||||
private Role role;
|
||||
private Table<?> table;
|
||||
private User user;
|
||||
private boolean withGrantOption;
|
||||
private Table<?> on;
|
||||
private Role to;
|
||||
private Boolean toPublic;
|
||||
private Boolean withGrantOption;
|
||||
|
||||
GrantImpl(
|
||||
Configuration configuration,
|
||||
Collection privileges
|
||||
) {
|
||||
this(
|
||||
configuration,
|
||||
privileges,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null
|
||||
);
|
||||
}
|
||||
|
||||
GrantImpl(Configuration configuration, Collection<? extends Privilege> privileges) {
|
||||
GrantImpl(
|
||||
Configuration configuration,
|
||||
Collection privileges,
|
||||
Table on,
|
||||
Role to,
|
||||
Boolean toPublic,
|
||||
Boolean withGrantOption
|
||||
) {
|
||||
super(configuration);
|
||||
|
||||
this.privileges = privileges;
|
||||
this.on = on;
|
||||
this.to = to;
|
||||
this.toPublic = toPublic;
|
||||
this.withGrantOption = withGrantOption;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
final Collection<? extends Privilege> $privileges() { return privileges; }
|
||||
final Table<?> $on() { return on; }
|
||||
final Role $to() { return to; }
|
||||
final Boolean $toPublic() { return toPublic; }
|
||||
final Boolean $withGrantOption() { return withGrantOption; }
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX: DSL API
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public final GrantImpl on(String on) {
|
||||
return on(DSL.table(DSL.name(on)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final GrantImpl on(Name on) {
|
||||
return on(DSL.table(on));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final GrantImpl on(Table<?> on) {
|
||||
this.on = on;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final GrantImpl to(User to) {
|
||||
return to(DSL.role(to.getName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final GrantImpl to(Role to) {
|
||||
this.to = to;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final GrantImpl toPublic() {
|
||||
this.toPublic = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final GrantImpl withGrantOption() {
|
||||
this.withGrantOption = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX: QueryPart API
|
||||
// ------------------------------------------------------------------------
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
private static final Clause[] CLAUSE = { Clause.GRANT };
|
||||
|
||||
@Override
|
||||
public final void accept(Context<?> ctx) {
|
||||
ctx.start(GRANT_PRIVILEGE)
|
||||
ctx.start(Clause.GRANT_PRIVILEGE)
|
||||
.visit(K_GRANT).sql(' ')
|
||||
.visit(wrap(privileges).indentSize(0))
|
||||
.end(GRANT_PRIVILEGE).sql(' ')
|
||||
.start(GRANT_ON)
|
||||
.visit(QueryPartCollectionView.wrap(privileges).indentSize(0))
|
||||
.end(Clause.GRANT_PRIVILEGE).sql(' ')
|
||||
.start(Clause.GRANT_ON)
|
||||
.visit(K_ON).sql(' ')
|
||||
.visit(table)
|
||||
.end(GRANT_ON).sql(' ')
|
||||
.start(GRANT_TO)
|
||||
.visit(on)
|
||||
.end(Clause.GRANT_ON).sql(' ')
|
||||
.start(Clause.GRANT_TO)
|
||||
.visit(K_TO).sql(' ');
|
||||
|
||||
if (user != null)
|
||||
ctx.visit(user);
|
||||
else if (role != null)
|
||||
ctx.visit(role);
|
||||
else
|
||||
if (to != null)
|
||||
ctx.visit(to);
|
||||
else if (Boolean.TRUE.equals(toPublic))
|
||||
ctx.visit(K_PUBLIC);
|
||||
|
||||
if (withGrantOption)
|
||||
if (Boolean.TRUE.equals(withGrantOption))
|
||||
ctx.sql(' ')
|
||||
.visit(K_WITH_GRANT_OPTION);
|
||||
|
||||
ctx.end(GRANT_TO);
|
||||
ctx.end(Clause.GRANT_TO);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -128,46 +189,5 @@ final class GrantImpl extends AbstractRowCountQuery implements
|
||||
return CLAUSE;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// XXX: GrantImpl API
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public final GrantImpl on(Table<?> t) {
|
||||
this.table = t;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final GrantImpl on(Name t) {
|
||||
return on(table(t));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final GrantImpl on(String t) {
|
||||
return on(table(t));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final GrantImpl to(User u) {
|
||||
this.user = u;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final GrantImpl to(Role r) {
|
||||
this.role = r;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final GrantImpl toPublic() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final GrantImpl withGrantOption() {
|
||||
withGrantOption = true;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@ -37,19 +37,13 @@
|
||||
*/
|
||||
package org.jooq.impl;
|
||||
|
||||
import static org.jooq.Clause.REVOKE;
|
||||
import static org.jooq.Clause.REVOKE_FROM;
|
||||
import static org.jooq.Clause.REVOKE_ON;
|
||||
import static org.jooq.Clause.REVOKE_PRIVILEGE;
|
||||
import static org.jooq.SQLDialect.HSQLDB;
|
||||
import static org.jooq.impl.DSL.table;
|
||||
import static org.jooq.impl.Keywords.K_FROM;
|
||||
import static org.jooq.impl.Keywords.K_GRANT_OPTION_FOR;
|
||||
import static org.jooq.impl.Keywords.K_ON;
|
||||
import static org.jooq.impl.Keywords.K_PUBLIC;
|
||||
import static org.jooq.impl.Keywords.K_RESTRICT;
|
||||
import static org.jooq.impl.Keywords.K_REVOKE;
|
||||
import static org.jooq.impl.QueryPartCollectionView.wrap;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
@ -66,71 +60,136 @@ import org.jooq.Table;
|
||||
import org.jooq.User;
|
||||
|
||||
/**
|
||||
* Revoke privilege or privileges on a table from user or role.
|
||||
*
|
||||
* @author Timur Shaidullin
|
||||
* The <code>REVOKE GRANT OPTION FOR</code> statement.
|
||||
*/
|
||||
final class RevokeImpl extends AbstractRowCountQuery implements
|
||||
|
||||
// Cascading interface implementations for Select behaviour
|
||||
@SuppressWarnings({ "hiding", "rawtypes", "unchecked", "unused" })
|
||||
final class RevokeImpl
|
||||
extends
|
||||
AbstractRowCountQuery
|
||||
implements
|
||||
RevokeOnStep,
|
||||
RevokeFromStep,
|
||||
RevokeFinalStep {
|
||||
RevokeFinalStep
|
||||
{
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Generated UID
|
||||
*/
|
||||
private static final long serialVersionUID = -5777612075774539326L;
|
||||
private static final Clause[] CLAUSE = { REVOKE };
|
||||
private final Collection<? extends Privilege> privileges;
|
||||
private Role role;
|
||||
private Table<?> table;
|
||||
private User user;
|
||||
private final boolean grantOptionFor;
|
||||
private final boolean revokeGrantOptionFor;
|
||||
private Table<?> on;
|
||||
private Role from;
|
||||
private Boolean fromPublic;
|
||||
|
||||
RevokeImpl(Configuration configuration, Collection<? extends Privilege> privileges, boolean grantOptionFor) {
|
||||
RevokeImpl(
|
||||
Configuration configuration,
|
||||
Collection privileges,
|
||||
boolean revokeGrantOptionFor
|
||||
) {
|
||||
this(
|
||||
configuration,
|
||||
privileges,
|
||||
revokeGrantOptionFor,
|
||||
null,
|
||||
null,
|
||||
null
|
||||
);
|
||||
}
|
||||
|
||||
RevokeImpl(
|
||||
Configuration configuration,
|
||||
Collection privileges,
|
||||
boolean revokeGrantOptionFor,
|
||||
Table on,
|
||||
Role from,
|
||||
Boolean fromPublic
|
||||
) {
|
||||
super(configuration);
|
||||
|
||||
this.privileges = privileges;
|
||||
this.grantOptionFor = grantOptionFor;
|
||||
this.revokeGrantOptionFor = revokeGrantOptionFor;
|
||||
this.on = on;
|
||||
this.from = from;
|
||||
this.fromPublic = fromPublic;
|
||||
}
|
||||
|
||||
RevokeImpl(Configuration configuration, Collection<? extends Privilege> privileges) {
|
||||
this(configuration, privileges, false);
|
||||
final Collection<? extends Privilege> $privileges() { return privileges; }
|
||||
final boolean $revokeGrantOptionFor() { return revokeGrantOptionFor; }
|
||||
final Table<?> $on() { return on; }
|
||||
final Role $from() { return from; }
|
||||
final Boolean $fromPublic() { return fromPublic; }
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX: DSL API
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public final RevokeImpl on(String on) {
|
||||
return on(DSL.table(DSL.name(on)));
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
@Override
|
||||
public final RevokeImpl on(Name on) {
|
||||
return on(DSL.table(on));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final RevokeImpl on(Table<?> on) {
|
||||
this.on = on;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final RevokeImpl from(User from) {
|
||||
return from(DSL.role(from.getName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final RevokeImpl from(Role from) {
|
||||
this.from = from;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final RevokeImpl fromPublic() {
|
||||
this.fromPublic = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX: QueryPart API
|
||||
// ------------------------------------------------------------------------
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
private static final Clause[] CLAUSE = { Clause.REVOKE };
|
||||
|
||||
@Override
|
||||
public final void accept(Context<?> ctx) {
|
||||
ctx.start(REVOKE_PRIVILEGE)
|
||||
ctx.start(Clause.REVOKE_PRIVILEGE)
|
||||
.visit(K_REVOKE).sql(' ');
|
||||
|
||||
if (grantOptionFor)
|
||||
if (revokeGrantOptionFor)
|
||||
ctx.visit(K_GRANT_OPTION_FOR)
|
||||
.sql(' ');
|
||||
|
||||
ctx.visit(wrap(privileges).indentSize(0))
|
||||
.end(REVOKE_PRIVILEGE).sql(' ')
|
||||
.start(REVOKE_ON)
|
||||
ctx.visit(QueryPartCollectionView.wrap(privileges).indentSize(0))
|
||||
.end(Clause.REVOKE_PRIVILEGE).sql(' ')
|
||||
.start(Clause.REVOKE_ON)
|
||||
.visit(K_ON).sql(' ')
|
||||
.visit(table)
|
||||
.end(REVOKE_ON).sql(' ')
|
||||
.start(REVOKE_FROM)
|
||||
.visit(on)
|
||||
.end(Clause.REVOKE_ON).sql(' ')
|
||||
.start(Clause.REVOKE_FROM)
|
||||
.visit(K_FROM).sql(' ');
|
||||
|
||||
if (user != null)
|
||||
ctx.visit(user);
|
||||
else if (role != null)
|
||||
ctx.visit(role);
|
||||
else
|
||||
if (from != null)
|
||||
ctx.visit(from);
|
||||
else if (Boolean.TRUE.equals(fromPublic))
|
||||
ctx.visit(K_PUBLIC);
|
||||
|
||||
if (ctx.family() == HSQLDB)
|
||||
ctx.sql(' ').visit(K_RESTRICT);
|
||||
|
||||
ctx.end(REVOKE_FROM);
|
||||
ctx.end(Clause.REVOKE_FROM);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -138,40 +197,5 @@ final class RevokeImpl extends AbstractRowCountQuery implements
|
||||
return CLAUSE;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// XXX: RevokeImpl API
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public final RevokeImpl on(Table<?> t) {
|
||||
this.table = t;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final RevokeImpl on(Name t) {
|
||||
return on(table(t));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final RevokeImpl on(String t) {
|
||||
return on(table(t));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final RevokeImpl from(User u) {
|
||||
this.user = u;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final RevokeImpl from(Role r) {
|
||||
this.role = r;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final RevokeImpl fromPublic() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user