edgedb-python icon indicating copy to clipboard operation
edgedb-python copied to clipboard

fields with leading underscore

Open 1st1 opened this issue 5 months ago • 1 comments

Fields starting with underscore have a special meaning in Pydantic and cannot be supported out of the gate

Things to fix / take care of / ideas:

  • Generator should issue a warning when it sees a field with leading underscore or a field that's not valid in Python for some reason
  • GelModel machinery should mangle the name so that pydantic can have this field at all
  • GelModel machinery should add an alias arg to FieldInfo with the original unmangled field name. That will make pydantic accept the original field from input.
  • We can also potentially create computeds with demangled names that can write and read from mangled field. Test this.

1st1 avatar Jul 10 '25 16:07 1st1

type Spam{
  _foo: str
}
class Spam:
  p_foo: Property[str, '_foo']

or even

class Spam:
  p_foo: RenamedProperty[str, '_foo']

Instead of p we can have a long suffix or a long prefix (or some awkward and less likely to be invented by a human stuff like P_foo)

1st1 avatar Jul 15 '25 19:07 1st1