This commit is contained in:
2026-03-30 07:22:14 -03:00
parent d0707333fd
commit 4220b0418e
182 changed files with 3668 additions and 5231 deletions

View File

@@ -99,14 +99,9 @@ def _resolve_field(name, type_hint, default):
return ""
def _to_snake_plural(name):
"""CamelCase → snake_case_plural for table names."""
s = re.sub(r"(?<=[a-z])(?=[A-Z])", "_", name).lower()
if s.endswith("y") and not s.endswith("ey"):
return s[:-1] + "ies"
if s.endswith("s"):
return s + "es"
return s + "s"
def _to_snake(name):
"""CamelCase → snake_case for table names."""
return re.sub(r"(?<=[a-z])(?=[A-Z])", "_", name).lower()
_HEADER = [
@@ -162,7 +157,7 @@ class SQLModelGenerator(PydanticGenerator):
def _build_table(name, docstring, hints, fields, resolve_type_fn):
"""Build a SQLModel table class from field data."""
table_name = _to_snake_plural(name)
table_name = _to_snake(name)
lines = [
f"class {name}(SQLModel, table=True):",
f' """{docstring.strip().split(chr(10))[0]}"""',