Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import lombok.RequiredArgsConstructor;

/**
* Dialect sql batch option.
* Dialect SQL batch option.
*/
@RequiredArgsConstructor
@Getter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ void assertProvide(final String name, final IdentifierCaseRuleProviderContext co

@Test
void assertProvideWithQuotedTableName() throws SQLException {
IdentifierCaseRule actual = provider.provide(new IdentifierCaseRuleProviderContext(DATABASE_TYPE, mockDataSource(true, 1)))
IdentifierCaseRule actual = provider.provide(new IdentifierCaseRuleProviderContext(DATABASE_TYPE, new FixtureDataSource(true, 1)))
.map(ruleSet -> ruleSet.getRule(IdentifierScope.TABLE)).orElseThrow(AssertionError::new);
assertThat(actual.getLookupMode(QuoteCharacter.BACK_QUOTE), is(LookupMode.NORMALIZED));
assertThat(actual.matches("t_mask", "T_MASK", QuoteCharacter.BACK_QUOTE), is(Boolean.TRUE));
Expand All @@ -96,20 +96,20 @@ private void assertLookupMode(final IdentifierCaseRule actual, final QuoteCharac
private static Stream<Arguments> provideArguments() throws SQLException {
return Stream.of(
Arguments.of("null_data_source", new IdentifierCaseRuleProviderContext(DATABASE_TYPE, null), null, null, null),
Arguments.of("null_connection", new IdentifierCaseRuleProviderContext(DATABASE_TYPE, mockNullConnectionDataSource()), null, null, null),
Arguments.of("lower_case_table_names_0", new IdentifierCaseRuleProviderContext(DATABASE_TYPE, mockDataSource(true, 0)),
Arguments.of("null_connection", new IdentifierCaseRuleProviderContext(DATABASE_TYPE, new NullConnectionFixtureDataSource()), null, null, null),
Arguments.of("lower_case_table_names_0", new IdentifierCaseRuleProviderContext(DATABASE_TYPE, new FixtureDataSource(true, 0)),
LookupMode.EXACT, LookupMode.EXACT, Boolean.FALSE),
Arguments.of("lower_case_table_names_1", new IdentifierCaseRuleProviderContext(DATABASE_TYPE, mockDataSource(true, 1)),
Arguments.of("lower_case_table_names_1", new IdentifierCaseRuleProviderContext(DATABASE_TYPE, new FixtureDataSource(true, 1)),
LookupMode.NORMALIZED, LookupMode.NORMALIZED, Boolean.TRUE),
Arguments.of("lower_case_table_names_2", new IdentifierCaseRuleProviderContext(DATABASE_TYPE, mockDataSource(true, 2)),
Arguments.of("lower_case_table_names_2", new IdentifierCaseRuleProviderContext(DATABASE_TYPE, new FixtureDataSource(true, 2)),
LookupMode.NORMALIZED, LookupMode.NORMALIZED, Boolean.TRUE),
Arguments.of("no_result_row", new IdentifierCaseRuleProviderContext(DATABASE_TYPE, mockDataSource(false, 0)), null, null, null),
Arguments.of("sql_exception", new IdentifierCaseRuleProviderContext(DATABASE_TYPE, mockFailingDataSource()), null, null, null));
Arguments.of("no_result_row", new IdentifierCaseRuleProviderContext(DATABASE_TYPE, new FixtureDataSource(false, 0)), null, null, null),
Arguments.of("sql_exception", new IdentifierCaseRuleProviderContext(DATABASE_TYPE, new FailingFixtureDataSource()), null, null, null));
}

@Test
void assertProvideWithLowerCaseTableNamesZeroUsesScopedRules() throws SQLException {
IdentifierCaseRuleProviderContext context = new IdentifierCaseRuleProviderContext(DATABASE_TYPE, mockDataSource(true, 0));
IdentifierCaseRuleProviderContext context = new IdentifierCaseRuleProviderContext(DATABASE_TYPE, new FixtureDataSource(true, 0));
IdentifierCaseRuleSet actual = provider.provide(context).orElseThrow(AssertionError::new);
assertThat(actual.getRule(IdentifierScope.SCHEMA).matches("foo_schema", "FOO_SCHEMA", QuoteCharacter.NONE), is(Boolean.TRUE));
assertThat(actual.getRule(IdentifierScope.TABLE).matches("foo_tbl", "FOO_TBL", QuoteCharacter.NONE), is(Boolean.FALSE));
Expand All @@ -118,18 +118,6 @@ void assertProvideWithLowerCaseTableNamesZeroUsesScopedRules() throws SQLExcepti
assertThat(actual.getRule(IdentifierScope.INDEX).matches("foo_idx", "FOO_IDX", QuoteCharacter.NONE), is(Boolean.TRUE));
}

private static DataSource mockDataSource(final boolean hasResultSetRow, final int lowerCaseTableNames) throws SQLException {
return new FixtureDataSource(hasResultSetRow, lowerCaseTableNames);
}

private static DataSource mockFailingDataSource() throws SQLException {
return new FailingFixtureDataSource();
}

private static DataSource mockNullConnectionDataSource() {
return new NullConnectionFixtureDataSource();
}

private static Object getDefaultValue(final Class<?> returnType) {
if (!returnType.isPrimitive()) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import java.text.MessageFormat;

/**
* Replacement for {@link org.postgresql.util.PSQLException}.
* PostgreSQL exception.
*/
@Getter
public final class PostgreSQLException extends SQLException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ private void parseBlobInfo(final FirebirdPacketPayload payload, final FirebirdBl
writeIntValue(payload, type, getSegmentCount());
return;
case MAX_SEGMENT:
writeIntValue(payload, type, getSegmentLength());
return;
case TOTAL_LENGTH:
writeIntValue(payload, type, getSegmentLength());
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public FirebirdAcceptPacket(final List<FirebirdProtocol> userProtocols) {
}

/**
* Set accept data packet.
* Set accepted data packet.
*
* @param salt salt value
* @param publicKey public key
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ private void parseUserInfo(final ByteBuf userInfo) {
int length = userInfo.readUnsignedByte();
ByteBuf data = userInfo.readSlice(length);
if (type == FirebirdUserDataType.CNCT_SPECIFIC_DATA) {
// specific data can be split into chunks and (i think) can be in payload in random order
// specific data can be split into chunks and (I think) can be in payload in random order
int step = data.readUnsignedByte();
pendingData.put(step, data.toString(StandardCharsets.US_ASCII));
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ public final class PostgreSQLNoDataPacket extends PostgreSQLPacket {
private static final PostgreSQLNoDataPacket INSTANCE = new PostgreSQLNoDataPacket();

/**
* Get instance of {@link PostgreSQLNoDataPacket}.
* Get instance of PostgreSQL no data packet.
*
* @return instance of {@link PostgreSQLNoDataPacket}
* @return got instance
*/
public static PostgreSQLNoDataPacket getInstance() {
return INSTANCE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ public final class PostgreSQLBindCompletePacket extends PostgreSQLPacket {
private static final PostgreSQLBindCompletePacket INSTANCE = new PostgreSQLBindCompletePacket();

/**
* Get instance of {@link PostgreSQLBindCompletePacket}.
* Get instance of PostgreSQL bind complete packet.
*
* @return instance of {@link PostgreSQLBindCompletePacket}
* @return got instance
*/
public static PostgreSQLBindCompletePacket getInstance() {
return INSTANCE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ public final class PostgreSQLCloseCompletePacket extends PostgreSQLPacket {
private static final PostgreSQLCloseCompletePacket INSTANCE = new PostgreSQLCloseCompletePacket();

/**
* Get instance of {@link PostgreSQLCloseCompletePacket}.
* Get instance of PostgreSQL close complete packet.
*
* @return instance of {@link PostgreSQLCloseCompletePacket}
* @return got instance
*/
public static PostgreSQLCloseCompletePacket getInstance() {
return INSTANCE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ public final class PostgreSQLParseCompletePacket extends PostgreSQLPacket {
private static final PostgreSQLParseCompletePacket INSTANCE = new PostgreSQLParseCompletePacket();

/**
* Get instance of {@link PostgreSQLParseCompletePacket}.
* Get instance of PostgreSQL parse complete packet.
*
* @return instance of {@link PostgreSQLParseCompletePacket}
* @return got instance
*/
public static PostgreSQLParseCompletePacket getInstance() {
return INSTANCE;
Expand Down
Loading