Skip to content

Commit

Permalink
issure isapir#12 Add dont_change option for "table_transform" and "co…
Browse files Browse the repository at this point in the history
…lumn_transform"

This commit add option "dont_change" for parametres "table_transform" and "column_transform". With that option case of table names and column names does not changed via migration.
  • Loading branch information
AlekseyKapustyanenko committed Mar 21, 2019
1 parent 4cdabab commit d9b7096
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 2 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,9 @@ Values that are wrapped in `%` symbols are treated as varaibles and evaluated at
|
+-- column_mapping struct - maps column names if needed, e.g. "group" -> "group_name"
|
+-- table_transform string - ([""], "lower_case", "upper_case", "camel_to_snake_case")
+-- table_transform string - ([""], "lower_case", "upper_case", "camel_to_snake_case", "dont_change")
|
+-- column_transform string - ([""], "lower_case", "upper_case", "camel_to_snake_case")
+-- column_transform string - ([""], "lower_case", "upper_case", "camel_to_snake_case", "dont_change")
|
+-- ddl
|
Expand Down
8 changes: 8 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,14 @@
</archive>
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<fork>true</fork>
<executable>C:\Program Files\Java\jdk1.8.0_202\bin\javac.exe</executable>
</configuration>
</plugin>
</plugins>
</build>

Expand Down
3 changes: 3 additions & 0 deletions src/main/java/net/twentyonesolutions/m2pg/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,9 @@ public static String transform(String input, String type){

if (type.equalsIgnoreCase("camel_to_snake_case"))
return Util.convertCamelToSnakeCase(input);

if (type.equalsIgnoreCase("dont_change"))
return Util.convertDontChangeCase(input);
}

return input;
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/net/twentyonesolutions/m2pg/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,16 @@ public static String convertCamelToSnakeCase(String camelCaseString){
.replaceAll("([^_A-Z0-9])([A-Z0-9])", "$1_$2")
.toLowerCase();
}

/**
* If it is necessary to do not change case, add quote to input string;
*
* @param anyCaseString
* @return
*/
public static String convertDontChangeCase(String anyCaseString){
return "\""+anyCaseString+"\"";
}


public static Map<String, Object> flattenKeys(Map<String, Object> map){
Expand Down

1 comment on commit d9b7096

@AlekseyKapustyanenko
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit add option "dont_change" for parametres "table_transform" and "column_transform". With that option case of table names and column names does not changed via migration.

Please sign in to comment.