Search in sources :

Example 1 with MySQLAdapter

use of org.apache.cayenne.dba.mysql.MySQLAdapter in project cayenne by apache.

the class JdbcAdapterIT method testCreateTableQuoteSqlIdentifiers.

@Test
public void testCreateTableQuoteSqlIdentifiers() {
    if (dbAdapter instanceof MySQLAdapter) {
        DbEntity entity = new DbEntity();
        DbAttribute attr = new DbAttribute();
        attr.setName("name column");
        attr.setType(1);
        entity.addAttribute(attr);
        DbKeyGenerator id = new DbKeyGenerator();
        entity.setPrimaryKeyGenerator(id);
        DataMap dm = new DataMap();
        dm.setQuotingSQLIdentifiers(true);
        entity.setDataMap(dm);
        entity.setName("name table");
        MySQLAdapter adaptMySQL = (MySQLAdapter) dbAdapter;
        String str = "CREATE TABLE `name table` (`name column` CHAR NULL) ENGINE=InnoDB";
        assertEquals(str, adaptMySQL.createTable(entity));
    }
}
Also used : MySQLAdapter(org.apache.cayenne.dba.mysql.MySQLAdapter) DbEntity(org.apache.cayenne.map.DbEntity) DbAttribute(org.apache.cayenne.map.DbAttribute) DbKeyGenerator(org.apache.cayenne.map.DbKeyGenerator) DataMap(org.apache.cayenne.map.DataMap) Test(org.junit.Test)

Aggregations

MySQLAdapter (org.apache.cayenne.dba.mysql.MySQLAdapter)1 DataMap (org.apache.cayenne.map.DataMap)1 DbAttribute (org.apache.cayenne.map.DbAttribute)1 DbEntity (org.apache.cayenne.map.DbEntity)1 DbKeyGenerator (org.apache.cayenne.map.DbKeyGenerator)1 Test (org.junit.Test)1