Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add contextAttrs api for SqlEntity #343

Merged
merged 1 commit into from
Oct 28, 2024
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 @@ -555,6 +555,16 @@ public T where(final CharSequence rawString, final Map<String, Object> paramMap)
return (T) this;
}

/**
* {@inheritDoc}
*
* @see jp.co.future.uroborosql.fluent.ExtractionCondition#contextAttrs()
*/
@Override
public Map<String, Object> contextAttrs() {
return context().contextAttrs();
}

/**
* 条件指定用のラップクラス
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,4 +307,10 @@ public interface ExtractionCondition<T> {
*/
T where(CharSequence rawString, Map<String, Object> paramMap);

/**
* ExecutionContextが保持する属性を取得する
* @return ExecutionContext属性情報
*/
Map<String, Object> contextAttrs();

}
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,11 @@ void testDeleteThrowException() {
});
}

@Test
void testContextAttrs() {
var delete = agent.delete(Product.class);
delete.contextAttrs().put("dummyValue", Integer.MAX_VALUE);
assertThat(delete.contextAttrs().get("dummyValue"), is(Integer.MAX_VALUE));
}

}
7 changes: 7 additions & 0 deletions src/test/java/jp/co/future/uroborosql/SqlEntityQueryTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -481,4 +481,11 @@ void testOptimizerHints() {
assertThat(products.size(), is(2));
}

@Test
void testContextAttrs() {
var query = agent.query(Product.class);
query.contextAttrs().put("dummyValue", Integer.MAX_VALUE);
assertThat(query.contextAttrs().get("dummyValue"), is(Integer.MAX_VALUE));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,13 @@ void testEntityUpdateWithId() throws Exception {
});
}

@Test
void testContextAttrs() {
var update = agent.update(TestEntity.class);
update.contextAttrs().put("dummyValue", Integer.MAX_VALUE);
assertThat(update.contextAttrs().get("dummyValue"), is(Integer.MAX_VALUE));
}

@Table(name = "test_entity")
public static class TestEntity {
@Id
Expand Down
Loading