Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
[reserved_keyword, InvalidReservedNameError]
for reserved_keyword in INVALID_RESERVED_KEYWORDS_ATTR_UPPER
+ INVALID_RESERVED_KEYWORDS_ATTR_LOWER
],
)
def test_exception_reserved_invalid_name(self, value, expected):
with pytest.raises(expected):
validate_sqlite_attr_name(value)
[reserved_keyword, InvalidReservedNameError]
for reserved_keyword in RESERVED_KEYWORDS + ["__debug__"]
],
)
def test_exception_reserved(self, value, expected):
with pytest.raises(expected):
validate_python_var_name(value)
[[reserved_keyword, InvalidReservedNameError] for reserved_keyword in RESERVED_KEYWORDS],
)
def test_exception_reserved(self, value, expected):
with pytest.raises(expected):
validate_js_var_name(value)
[reserved_keyword, InvalidReservedNameError]
for reserved_keyword in INVALID_RESERVED_KEYWORDS_TABLE_UPPER
+ INVALID_RESERVED_KEYWORDS_TABLE_LOWER
],
)
def test_exception_reserved_invalid_name(self, value, expected):
with pytest.raises(expected):
validate_sqlite_table_name(value)
def _validate_table_name(self, table_name):
try:
validate_sqlite_table_name(table_name)
except ValidReservedNameError:
pass
except (InvalidReservedNameError, InvalidCharError) as e:
raise InvalidTableNameError(e)
def validate_attr_name(name):
"""
:param str name: Name to validate.
:raises NameValidationError: |raises_validate_attr_name|
"""
try:
validate_sqlite_attr_name(name)
except (InvalidCharError, InvalidReservedNameError) as e:
raise NameValidationError(e)
except NullNameError:
raise NameValidationError("attribute name is empty")
def to_query(self):
name = self.sanitize(self._value)
need_quote = self.__RE_NEED_QUOTE.search(name) is not None
try:
validate_sqlite_attr_name(name)
except InvalidReservedNameError:
need_quote = True
except (ValidReservedNameError, NullNameError, InvalidCharError):
pass
if need_quote:
sql_name = '"{:s}"'.format(name)
elif self.__RE_NEED_BRACKET.search(name):
sql_name = "[{:s}]".format(name)
elif name == "join":
sql_name = "[{:s}]".format(name)
else:
sql_name = name
if typepy.is_not_null_string(self.__operation):
sql_name = "{:s}({:s})".format(self.__operation, sql_name)
def _validate_table_name(self, table_name):
try:
pv.validate_sqlite_table_name(table_name)
except pv.ValidReservedNameError:
pass
except (pv.InvalidReservedNameError, pv.InvalidCharError) as e:
raise InvalidTableNameError(e)