Search in sources :

Example 6 with SqlIdentifier

use of org.springframework.data.relational.core.sql.SqlIdentifier in project spring-data-jdbc by spring-projects.

the class SqlIdentifierUnitTests method quotedSimpleObjectIdentifier.

// DATAJDBC-386
@Test
public void quotedSimpleObjectIdentifier() {
    SqlIdentifier identifier = quoted("someName");
    assertThat(identifier.toSql(BRACKETS_LOWER_CASE)).isEqualTo("[someName]");
    assertThat(identifier.getReference(BRACKETS_LOWER_CASE)).isEqualTo("someName");
}
Also used : SqlIdentifier(org.springframework.data.relational.core.sql.SqlIdentifier) Test(org.junit.jupiter.api.Test)

Example 7 with SqlIdentifier

use of org.springframework.data.relational.core.sql.SqlIdentifier in project spring-data-jdbc by spring-projects.

the class RelationalPersistentEntityImplUnitTests method testRelationalPersistentEntitySchemaNameChoice.

// GH-1099
@Test
void testRelationalPersistentEntitySchemaNameChoice() {
    mappingContext = new RelationalMappingContext(NamingStrategyWithSchema.INSTANCE);
    RelationalPersistentEntity<?> persistentEntity = mappingContext.getPersistentEntity(EntityWithSchemaAndName.class);
    SqlIdentifier tableName = persistentEntity.getTableName();
    assertThat(tableName).isEqualTo(SqlIdentifier.from(SqlIdentifier.quoted("DART_VADER"), quoted("I_AM_THE_SENATE")));
}
Also used : SqlIdentifier(org.springframework.data.relational.core.sql.SqlIdentifier) Test(org.junit.jupiter.api.Test)

Example 8 with SqlIdentifier

use of org.springframework.data.relational.core.sql.SqlIdentifier in project spring-data-jdbc by spring-projects.

the class RelationalPersistentEntityImplUnitTests method specifiedSchemaGetsCombinedWithNameFromNamingStrategy.

// GH-1099
@Test
void specifiedSchemaGetsCombinedWithNameFromNamingStrategy() {
    RelationalPersistentEntity<?> persistentEntity = mappingContext.getPersistentEntity(EntityWithSchema.class);
    SqlIdentifier tableName = persistentEntity.getTableName();
    assertThat(tableName).isEqualTo(SqlIdentifier.from(quoted("ANAKYN_SKYWALKER"), quoted("ENTITY_WITH_SCHEMA")));
}
Also used : SqlIdentifier(org.springframework.data.relational.core.sql.SqlIdentifier) Test(org.junit.jupiter.api.Test)

Example 9 with SqlIdentifier

use of org.springframework.data.relational.core.sql.SqlIdentifier in project spring-data-jdbc by spring-projects.

the class DerivedSqlIdentifierUnitTests method unquotedSimpleObjectIdentifierWithAdjustableLetterCasing.

// DATAJDBC-386
@Test
public void unquotedSimpleObjectIdentifierWithAdjustableLetterCasing() {
    SqlIdentifier identifier = new DerivedSqlIdentifier("someName", false);
    String sql = identifier.toSql(BRACKETS_LOWER_CASE);
    assertThat(sql).isEqualTo("somename");
    assertThat(identifier.getReference(BRACKETS_LOWER_CASE)).isEqualTo("someName");
}
Also used : SqlIdentifier(org.springframework.data.relational.core.sql.SqlIdentifier) Test(org.junit.jupiter.api.Test)

Example 10 with SqlIdentifier

use of org.springframework.data.relational.core.sql.SqlIdentifier in project spring-data-jdbc by spring-projects.

the class DerivedSqlIdentifierUnitTests method quotedMultipartObjectIdentifierWithAdjustableLetterCase.

// DATAJDBC-386
@Test
public void quotedMultipartObjectIdentifierWithAdjustableLetterCase() {
    SqlIdentifier identifier = SqlIdentifier.from(new DerivedSqlIdentifier("some", true), new DerivedSqlIdentifier("name", true));
    String sql = identifier.toSql(IdentifierProcessing.ANSI);
    assertThat(sql).isEqualTo("\"SOME\".\"NAME\"");
}
Also used : SqlIdentifier(org.springframework.data.relational.core.sql.SqlIdentifier) Test(org.junit.jupiter.api.Test)

Aggregations

SqlIdentifier (org.springframework.data.relational.core.sql.SqlIdentifier)27 Test (org.junit.jupiter.api.Test)13 Nullable (org.springframework.lang.Nullable)4 HashMap (java.util.HashMap)2 Table (org.springframework.data.relational.core.sql.Table)2 Lazy (org.springframework.data.util.Lazy)2 Objects (java.util.Objects)1 Optional (java.util.Optional)1 PersistentProperty (org.springframework.data.mapping.PersistentProperty)1 PersistentPropertyPath (org.springframework.data.mapping.PersistentPropertyPath)1 MappingContext (org.springframework.data.mapping.context.MappingContext)1 BasicPersistentEntity (org.springframework.data.mapping.model.BasicPersistentEntity)1 IdentifierProcessing (org.springframework.data.relational.core.sql.IdentifierProcessing)1 TypeInformation (org.springframework.data.util.TypeInformation)1 Assert (org.springframework.util.Assert)1 StringUtils (org.springframework.util.StringUtils)1