-
Notifications
You must be signed in to change notification settings - Fork 27
Feature/morf 72 extra audit fields #275
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
base: main
Are you sure you want to change the base?
Changes from all commits
33978b2
4fef808
b3c408d
4009ee7
cba7d42
4323b97
5711773
511a3fd
83c483a
878cdc3
30e66bb
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 |
|---|---|---|
|
|
@@ -184,7 +184,7 @@ public SqlDialect(String schemaName) { | |
| * @return The statements required to deploy the table and its indexes. | ||
| */ | ||
| public Collection<String> tableDeploymentStatements(Table table) { | ||
| Builder<String> statements = ImmutableList.<String>builder(); | ||
| Builder<String> statements = ImmutableList.builder(); | ||
|
|
||
| statements.addAll(internalTableDeploymentStatements(table)); | ||
|
|
||
|
|
@@ -215,16 +215,15 @@ public Collection<String> viewDeploymentStatements(View view) { | |
| List<String> statements = new ArrayList<>(); | ||
|
|
||
| // Create the table deployment statement | ||
| StringBuilder createTableStatement = new StringBuilder(); | ||
| createTableStatement.append("CREATE "); | ||
| createTableStatement.append("VIEW "); | ||
| createTableStatement.append(schemaNamePrefix()); | ||
| createTableStatement.append(view.getName()); | ||
| createTableStatement.append(" AS ("); | ||
| createTableStatement.append(convertStatementToSQL(view.getSelectStatement())); | ||
| createTableStatement.append(")"); | ||
| String createTableStatement = "CREATE " + | ||
| "VIEW " + | ||
| schemaNamePrefix() + | ||
| view.getName() + | ||
| " AS (" + | ||
| convertStatementToSQL(view.getSelectStatement()) + | ||
| ")"; | ||
|
Contributor
Author
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. Remove unnecessary StringBuilder. |
||
|
|
||
| statements.add(createTableStatement.toString()); | ||
| statements.add(createTableStatement); | ||
|
|
||
| return statements; | ||
| } | ||
|
|
@@ -1195,10 +1194,7 @@ protected String getSqlForOrderByField(AliasedField currentOrderByField) { | |
| return getSqlForOrderByField((FieldReference) currentOrderByField); | ||
| } | ||
|
|
||
| StringBuilder result = new StringBuilder(getSqlFrom(currentOrderByField)); | ||
| result.append(" ").append(defaultNullOrder()); | ||
|
|
||
| return result.toString().trim(); | ||
| return (getSqlFrom(currentOrderByField) + " " + defaultNullOrder()).trim(); | ||
|
Contributor
Author
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. Remove unnecessary StringBuilder. |
||
| } | ||
|
|
||
|
|
||
|
|
@@ -1325,7 +1321,7 @@ protected void appendJoin(StringBuilder result, Join join, String innerJoinKeywo | |
| } else { | ||
| // MySql supports no ON criteria and ON TRUE, but the other platforms | ||
| // don't, so just keep things simple. | ||
| result.append(String.format(" ON 1=1")); | ||
| result.append(" ON 1=1"); | ||
|
Contributor
Author
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. Remove redundant String.format |
||
| } | ||
| } | ||
|
|
||
|
|
@@ -1568,7 +1564,7 @@ protected String getSqlFrom(Criterion criterion) { | |
| result.append(getOperatorLine(criterion, "<=")); | ||
| break; | ||
| case LIKE: | ||
| result.append(getOperatorLine(criterion, "LIKE") + likeEscapeSuffix()); | ||
| result.append(getOperatorLine(criterion, "LIKE")).append(likeEscapeSuffix()); | ||
| break; | ||
| case ISNULL: | ||
| result.append(String.format("%s IS NULL", getSqlFrom(criterion.getField()))); | ||
|
|
@@ -2078,6 +2074,18 @@ protected String getSqlFrom(Function function) { | |
| } | ||
| return getSqlForRowNumber(); | ||
|
|
||
| case CURRENT_UNIX_TIME_MILLISECONDS: | ||
| if (!function.getArguments().isEmpty()) { | ||
| throw new IllegalArgumentException("The CURRENT_UNIX_TIME_MILLISECONDS function should have zero arguments. This function has " + function.getArguments().size()); | ||
| } | ||
| return getSqlForCurrentUnixTimeMilliseconds(); | ||
|
|
||
| case CLIENT_HOST: | ||
| if (!function.getArguments().isEmpty()) { | ||
| throw new IllegalArgumentException("The CLIENT_HOST function should have zero arguments. This function has " + function.getArguments().size()); | ||
| } | ||
| return getSqlForClientHost(); | ||
|
|
||
| default: | ||
| throw new UnsupportedOperationException("This database does not currently support the [" + function.getType() + "] function"); | ||
| } | ||
|
|
@@ -2189,7 +2197,7 @@ protected String getSqlForCoalesce(Function function) { | |
| * @return a string representation of the SQL | ||
| */ | ||
| protected String getSqlForGreatest(Function function) { | ||
| return getGreatestFunctionName() + '(' + Joiner.on(", ").join(function.getArguments().stream().map(f -> getSqlFrom(f)).iterator()) + ')'; | ||
| return getGreatestFunctionName() + '(' + Joiner.on(", ").join(function.getArguments().stream().map(this::getSqlFrom).iterator()) + ')'; | ||
| } | ||
|
|
||
|
|
||
|
|
@@ -2200,7 +2208,7 @@ protected String getSqlForGreatest(Function function) { | |
| * @return a string representation of the SQL | ||
| */ | ||
| protected String getSqlForLeast(Function function) { | ||
| return getLeastFunctionName() + '(' + Joiner.on(", ").join(function.getArguments().stream().map(f -> getSqlFrom(f)).iterator()) + ')'; | ||
| return getLeastFunctionName() + '(' + Joiner.on(", ").join(function.getArguments().stream().map(this::getSqlFrom).iterator()) + ')'; | ||
| } | ||
|
|
||
|
|
||
|
|
@@ -2417,13 +2425,29 @@ protected String getLeastFunctionName() { | |
| /** | ||
| * Produce SQL for getting the row number of the row in the partition | ||
| * | ||
| * @return a string representation of the SQL for finding the last day of the month. | ||
| * @return a string representation of the SQL for getting the row number of the row in the partition. | ||
|
Contributor
Author
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. Previous change had cut and pasted the wrong JavaDocs without updating it. |
||
| */ | ||
| protected String getSqlForRowNumber(){ | ||
| return "ROW_NUMBER()"; | ||
| } | ||
|
|
||
|
|
||
| /** | ||
| * Produce SQL for getting the current unix time in milliseconds | ||
| * | ||
| * @return A string representation of the SQL for the current unix time in milliseconds | ||
| */ | ||
| protected abstract String getSqlForCurrentUnixTimeMilliseconds(); | ||
|
|
||
|
|
||
| /** | ||
| * Produce SQL for getting the client host | ||
| * | ||
| * @return A string representation of the SQL for the client host | ||
| */ | ||
| protected abstract String getSqlForClientHost(); | ||
|
|
||
|
|
||
| /** | ||
| * Gets the function name required to perform a substring command. | ||
| * <p> | ||
|
|
@@ -4192,7 +4216,7 @@ protected Iterable<AliasedField> getMergeStatementUpdateExpressions(MergeStateme | |
| .toSet(); | ||
|
|
||
| List<String> listOfKeyFieldsWithUpdateExpression = FluentIterable.from(onUpdateExpressions.keySet()) | ||
| .filter(a -> keyFields.contains(a)) | ||
| .filter(keyFields::contains) | ||
| .toList(); | ||
|
|
||
| if (!listOfKeyFieldsWithUpdateExpression.isEmpty()) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove unnecessary type