diff --git a/singer_sdk/sinks/sql.py b/singer_sdk/sinks/sql.py index 1b991c7f0..e4cdc6571 100644 --- a/singer_sdk/sinks/sql.py +++ b/singer_sdk/sinks/sql.py @@ -13,7 +13,7 @@ from singer_sdk.connectors import SQLConnector from singer_sdk.exceptions import ConformedNameClashException -from singer_sdk.helpers._conformers import replace_leading_digit, snakecase +from singer_sdk.helpers._conformers import replace_leading_digit from singer_sdk.plugin_base import PluginBase from singer_sdk.sinks.batch import BatchSink @@ -150,10 +150,18 @@ def conform_name(self, name: str, object_type: Optional[str] = None) -> str: Returns: The name transformed to snake case. """ - # strip non-alphanumeric characters, keeping - . _ and spaces + # strip non-alphanumeric characters name = re.sub(r"[^a-zA-Z0-9_\-\.\s]", "", name) - # convert to snakecase - name = snakecase(name) + # strip leading/trailing whitespace, + # transform to lowercase and replace - . and spaces to _ + name = ( + name.lower() + .lstrip() + .rstrip() + .replace(".", "_") + .replace("-", "_") + .replace(" ", "_") + ) # replace leading digit return replace_leading_digit(name) diff --git a/tests/samples/test_target_sqlite.py b/tests/samples/test_target_sqlite.py index 4897a0bdf..348ee053b 100644 --- a/tests/samples/test_target_sqlite.py +++ b/tests/samples/test_target_sqlite.py @@ -458,11 +458,11 @@ def test_hostile_to_sqlite( columns = {res[0] for res in cursor.fetchall()} assert columns == { "name_with_spaces", - "name_is_camel_case", + "nameiscamelcase", "name_with_dashes", "name_with_dashes_and_mixed_cases", "gname_starts_with_number", "fname_starts_with_number", "hname_starts_with_number", - "name_with_emoji", + "name_with_emoji_", }