-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
### Feature or Bugfix - Bugfix ### Detail - fix how dynamic SQL with varying table names is generated ### Relates - <URL or Ticket> By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
- Loading branch information
Showing
2 changed files
with
26 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import re | ||
|
||
|
||
class Identifier: | ||
def __init__(self, *identifiers) -> None: | ||
if not identifiers: | ||
raise TypeError("Identifier cannot be empty") | ||
|
||
for id in identifiers: | ||
if not isinstance(id, str): | ||
raise TypeError("SQL identifier parts must be strings") | ||
if re.search(r"\W", id): | ||
raise TypeError(f"SQL identifier contains invalid characters: {id}") | ||
|
||
self._identifiers = identifiers | ||
|
||
@property | ||
def identifiers(self) -> str: | ||
return self._identifiers | ||
|
||
def __repr__(self) -> str: | ||
return ".".join(self._identifiers) |