[jOOQ/jOOQ#10422] Let User and Role extend Named to give access to
quoted / unquoted and qualified / unqualified names
This commit is contained in:
parent
a4b54b2436
commit
0bf32a4458
@ -58,10 +58,4 @@ import org.jooq.impl.DSL;
|
||||
*
|
||||
* @author Timur Shaidullin
|
||||
*/
|
||||
public interface Role extends QueryPart {
|
||||
|
||||
/**
|
||||
* The name of the role.
|
||||
*/
|
||||
String getName();
|
||||
}
|
||||
public interface Role extends Named {}
|
||||
|
||||
@ -58,10 +58,4 @@ import org.jooq.impl.DSL;
|
||||
*
|
||||
* @author Timur Shaidullin
|
||||
*/
|
||||
public interface User extends QueryPart {
|
||||
|
||||
/**
|
||||
* The name of the user.
|
||||
*/
|
||||
String getName();
|
||||
}
|
||||
public interface User extends Named {}
|
||||
|
||||
@ -130,7 +130,7 @@ implements
|
||||
|
||||
@Override
|
||||
public final GrantImpl to(User to) {
|
||||
return to(DSL.role(to.getName()));
|
||||
return to(DSL.role(to.getQualifiedName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -37,27 +37,17 @@
|
||||
*/
|
||||
package org.jooq.impl;
|
||||
|
||||
import static org.jooq.SQLDialect.HSQLDB;
|
||||
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.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.Name;
|
||||
import org.jooq.Privilege;
|
||||
import org.jooq.RevokeFinalStep;
|
||||
import org.jooq.RevokeFromStep;
|
||||
import org.jooq.RevokeOnStep;
|
||||
import org.jooq.Role;
|
||||
import org.jooq.Table;
|
||||
import org.jooq.User;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* The <code>REVOKE GRANT OPTION FOR</code> statement.
|
||||
@ -79,7 +69,7 @@ implements
|
||||
private Table<?> on;
|
||||
private Role from;
|
||||
private Boolean fromPublic;
|
||||
|
||||
|
||||
RevokeImpl(
|
||||
Configuration configuration,
|
||||
Collection privileges,
|
||||
@ -121,7 +111,7 @@ implements
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX: DSL API
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
|
||||
@Override
|
||||
public final RevokeImpl on(String on) {
|
||||
return on(DSL.table(DSL.name(on)));
|
||||
@ -140,7 +130,7 @@ implements
|
||||
|
||||
@Override
|
||||
public final RevokeImpl from(User from) {
|
||||
return from(DSL.role(from.getName()));
|
||||
return from(DSL.role(from.getQualifiedName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -38,6 +38,7 @@
|
||||
package org.jooq.impl;
|
||||
|
||||
import static org.jooq.Clause.ROLE;
|
||||
import static org.jooq.impl.CommentImpl.NO_COMMENT;
|
||||
|
||||
import org.jooq.Clause;
|
||||
import org.jooq.Context;
|
||||
@ -49,17 +50,16 @@ import org.jooq.Role;
|
||||
*
|
||||
* @author Timur Shaidullin
|
||||
*/
|
||||
final class RoleImpl extends AbstractQueryPart implements Role {
|
||||
final class RoleImpl extends AbstractNamed 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;
|
||||
super(name, NO_COMMENT);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
@ -68,20 +68,11 @@ final class RoleImpl extends AbstractQueryPart implements Role {
|
||||
|
||||
@Override
|
||||
public final void accept(Context<?> ctx) {
|
||||
ctx.visit(name);
|
||||
ctx.visit(getQualifiedName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Clause[] clauses(Context<?> ctx) {
|
||||
return CLAUSES;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// XXX: Role API
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public final String getName() {
|
||||
return name.last();
|
||||
}
|
||||
}
|
||||
|
||||
@ -38,6 +38,7 @@
|
||||
package org.jooq.impl;
|
||||
|
||||
import static org.jooq.Clause.USER;
|
||||
import static org.jooq.impl.CommentImpl.NO_COMMENT;
|
||||
|
||||
import org.jooq.Clause;
|
||||
import org.jooq.Context;
|
||||
@ -49,17 +50,16 @@ import org.jooq.User;
|
||||
*
|
||||
* @author Timur Shaidullin
|
||||
*/
|
||||
final class UserImpl extends AbstractQueryPart implements User {
|
||||
final class UserImpl extends AbstractNamed implements User {
|
||||
|
||||
/**
|
||||
* Generated UID
|
||||
*/
|
||||
private static final long serialVersionUID = 1169948119720063466L;
|
||||
private static final Clause[] CLAUSES = { USER };
|
||||
private final Name name;
|
||||
|
||||
UserImpl(Name name) {
|
||||
this.name = name;
|
||||
super(name, NO_COMMENT);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
@ -68,20 +68,11 @@ final class UserImpl extends AbstractQueryPart implements User {
|
||||
|
||||
@Override
|
||||
public final void accept(Context<?> ctx) {
|
||||
ctx.visit(name);
|
||||
ctx.visit(getQualifiedName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Clause[] clauses(Context<?> ctx) {
|
||||
return CLAUSES;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// XXX: User API
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public final String getName() {
|
||||
return name.last();
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user