[#6839] The Role type for GRANT statement

This commit is contained in:
Timur Shaidullin 2017-11-26 22:58:55 +03:00
parent 41d4a78eb1
commit 8d0a0c617b
4 changed files with 147 additions and 0 deletions

View File

@ -47,6 +47,7 @@ public enum Clause {
// -------------------------------------------------------------------------
USER,
ROLE,
// -------------------------------------------------------------------------
// Clauses used in a any type of statement to model constraint references

View File

@ -0,0 +1,48 @@
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Other licenses:
* -----------------------------------------------------------------------------
* Commercial licenses for this work are available. These replace the above
* ASL 2.0 and offer limited warranties, support, maintenance, and commercial
* database integrations.
*
* For more information, please visit: http://www.jooq.org/licenses
*
*
*
*
*
*
*
*
*
*
*
*
*
*/
package org.jooq;
/**
* The Role to be used by GRANT statement
*
* @author Timur Shaidullin
*/
public interface Role extends QueryPart {
/**
* The name of role
*/
public String getName();
}

View File

@ -251,6 +251,7 @@ import org.jooq.RecordHandler;
import org.jooq.RecordType;
import org.jooq.Result;
import org.jooq.ResultQuery;
import org.jooq.Role;
import org.jooq.Row1;
import org.jooq.Row10;
import org.jooq.Row11;
@ -7873,6 +7874,22 @@ public class DSL {
return new UserImpl(name);
}
/**
* Create a new role reference
*
* @see #role(Name)
*/
public static Role role(String name) {
return role(name(name));
}
/**
* Create a new role reference
*/
public static Role role(Name name) {
return new RoleImpl(name);
}
// -------------------------------------------------------------------------
// XXX Conversion of objects into tables
// -------------------------------------------------------------------------

View File

@ -0,0 +1,81 @@
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Other licenses:
* -----------------------------------------------------------------------------
* Commercial licenses for this work are available. These replace the above
* ASL 2.0 and offer limited warranties, support, maintenance, and commercial
* database integrations.
*
* For more information, please visit: http://www.jooq.org/licenses
*
*
*
*
*
*
*
*
*
*
*
*
*
*/
package org.jooq.impl;
import org.jooq.*;
import static org.jooq.Clause.ROLE;
/**
* A common implementation of the Role type
*
* @author Timur Shaidullin
*/
final class RoleImpl extends AbstractQueryPart implements Role {
/**
* Generated UID
*/
private static final long serialVersionUID = -1169436492818811877L;
private static final Clause[] CLAUSES = { ROLE };
private final Name name;
RoleImpl(Name name) {
this.name = name;
}
// ------------------------------------------------------------------------
// XXX: QueryPart API
// ------------------------------------------------------------------------
@Override
public final void accept(Context<?> ctx) {
ctx.visit(name);
}
@Override
public final Clause[] clauses(Context<?> ctx) {
return CLAUSES;
}
// ------------------------------------------------------------------------
// XXX: Role API
// ------------------------------------------------------------------------
@Override
public final String getName() {
return name.last();
}
}