Search code examples
postgresqlplayframeworkebeanplayframework-evolutions

Play evolution escaping table names


I've got Play!Framework running with jdbc and Postgresql as database. I'd like to enable evolutions for development usage.

Play doesn't seem to automatically escape table names. For instance, when creating a table called user, I can't seem to automatically create a table because user is a reserved word in SQL.

Play generates an evolution like this:

# --- Rev:1,Ups - 4fb5e22
create table user (
id                        bigserial not null,
name                      varchar(255),
constraint pk_user primary key (id));

Is there any way to automatically escape table names?

Thanks


Solution

  • I am not sure if it possible. You can try to use some of the common escaping

    like Hibernate:

    @Table(name="`user`")
    

    like JPA2:

    @Table(name="\"user\"")
    

    For myself - I never use reserved words for the naming. You always will fall with this, always. so just use different table name, even if you do not want to change the class name itself, annotate it with the different table name:

    @Table(name="user_table")