-
Couldn't load subscription status.
- Fork 310
Allow use of table options not registered in TableOption and extend known TableOptions
#1586
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -44,6 +44,7 @@ | |
| * @author John Blum | ||
| * @author Vagif Zeynalov | ||
| * @author Mikhail Polivakha | ||
| * @author Seungho Kang | ||
| */ | ||
| public class CassandraAdminTemplate extends CassandraTemplate implements CassandraAdminOperations { | ||
|
|
||
|
|
@@ -115,8 +116,10 @@ public void createTable(boolean ifNotExists, CqlIdentifier tableName, Class<?> e | |
|
|
||
| if (!CollectionUtils.isEmpty(optionsByName)) { | ||
| optionsByName.forEach((key, value) -> { | ||
| TableOption tableOption = TableOption.valueOfIgnoreCase(key); | ||
| if (tableOption.requiresValue()) { | ||
| TableOption tableOption = TableOption.findByNameIgnoreCase(key); | ||
| if (tableOption == null) { | ||
| addRawTableOption(key, value, createTableSpecification); | ||
| } else if (tableOption.requiresValue()) { | ||
| createTableSpecification.with(tableOption, value); | ||
| } else { | ||
| createTableSpecification.with(tableOption); | ||
|
|
@@ -127,6 +130,14 @@ public void createTable(boolean ifNotExists, CqlIdentifier tableName, Class<?> e | |
| getCqlOperations().execute(CqlGenerator.toCql(createTableSpecification)); | ||
| } | ||
|
|
||
| private void addRawTableOption(String key, Object value, CreateTableSpecification createTableSpecification) { | ||
| if (value instanceof String) { | ||
| createTableSpecification.with(key, value, true, true); | ||
| return; | ||
| } | ||
| createTableSpecification.with(key, value, false, false); | ||
| } | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the current situation, if users manually apply escaping and quoting, it could result in double escaping/quoting if the option is later added to TableOption in a future version. So I considered two options:
I chose option 1, considering the potential side effects. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Providing values as strings in a map is convenient and doing so might cause a moment of surprise when an option (e.g. Having the framework doing something that you cannot disable causes more inconvenience than doing less in the framework and allowing the caller to update their inputs. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you for your feedback. |
||
|
|
||
| @Override | ||
| public void dropTable(Class<?> entityClass) { | ||
| dropTable(getTableName(entityClass)); | ||
|
|
||