phase 4
This commit is contained in:
@@ -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]}"""',
|
||||
|
||||
Reference in New Issue
Block a user