use of org.springframework.data.relational.core.sql.SqlIdentifier in project spring-data-jdbc by spring-projects.
the class DerivedSqlIdentifierUnitTests method quotedSimpleObjectIdentifierWithAdjustableLetterCasing.
// DATAJDBC-386
@Test
public void quotedSimpleObjectIdentifierWithAdjustableLetterCasing() {
SqlIdentifier identifier = new DerivedSqlIdentifier("someName", true);
assertThat(identifier.toSql(BRACKETS_LOWER_CASE)).isEqualTo("[somename]");
assertThat(identifier.getReference(BRACKETS_LOWER_CASE)).isEqualTo("someName");
}
use of org.springframework.data.relational.core.sql.SqlIdentifier in project spring-data-jdbc by spring-projects.
the class ColumnVisitor method leaveMatched.
/*
* (non-Javadoc)
* @see org.springframework.data.relational.core.sql.render.TypedSubtreeVisitor#leaveMatched(org.springframework.data.relational.core.sql.Visitable)
*/
@Override
Delegation leaveMatched(Column segment) {
SqlIdentifier column = context.getNamingStrategy().getName(segment);
CharSequence name = considerTablePrefix && tableName != null ? NameRenderer.render(context, SqlIdentifier.from(tableName, column)) : NameRenderer.render(context, segment);
target.onRendered(name);
return super.leaveMatched(segment);
}
use of org.springframework.data.relational.core.sql.SqlIdentifier in project spring-data-jdbc by spring-projects.
the class IdentifierUnitTests method parametersWithStringKeysUseObjectAsTypeForNull.
// DATAJDBC-326
@Test
public void parametersWithStringKeysUseObjectAsTypeForNull() {
HashMap<SqlIdentifier, Object> parameters = new HashMap<>();
parameters.put(unquoted("one"), null);
Identifier identifier = Identifier.from(parameters);
//
assertThat(identifier.getParts()).extracting("name", "value", //
"targetType").containsExactly(//
Assertions.tuple(unquoted("one"), null, Object.class));
}
use of org.springframework.data.relational.core.sql.SqlIdentifier in project spring-data-jdbc by spring-projects.
the class JdbcRepositoryEmbeddedNotInAggregateRootIntegrationTests method countRowsInTable.
private int countRowsInTable(String name, long idValue) {
SqlIdentifier id = SqlIdentifier.quoted("ID");
String whereClause = id.toSql(dialect.getIdentifierProcessing()) + " = " + idValue;
return JdbcTestUtils.countRowsInTableWhere((JdbcTemplate) template.getJdbcOperations(), name, whereClause);
}
use of org.springframework.data.relational.core.sql.SqlIdentifier in project spring-data-jdbc by spring-projects.
the class PersistentPropertyPathExtension method assembleTableAlias.
private SqlIdentifier assembleTableAlias() {
Assert.state(path != null, "Path is null");
RelationalPersistentProperty leafProperty = path.getRequiredLeafProperty();
String prefix = isEmbedded() ? leafProperty.getEmbeddedPrefix() : leafProperty.getName();
if (path.getLength() == 1) {
Assert.notNull(prefix, "Prefix mus not be null.");
return SqlIdentifier.quoted(prefix);
}
PersistentPropertyPathExtension parentPath = getParentPath();
SqlIdentifier sqlIdentifier = parentPath.assembleTableAlias();
return parentPath.isEmbedded() ? sqlIdentifier.transform(name -> name.concat(prefix)) : sqlIdentifier.transform(name -> name + "_" + prefix);
}
Aggregations