feat: add defaultable field support with companion struct generation

Introduces support for `#[georm(defaultable)]` attribute on entity
fields. When fields are marked as defaultable, generates companion
`<Entity>Default` structs where defaultable fields become `Option<T>`,
enabling easier entity creation when some fields have database defaults
or are auto-generated.

Key features:
- Generates `<Entity>Default` structs with optional defaultable fields
- Implements `Defaultable<Id, Entity>` trait with async `create` method
- Validates that `Option<T>` fields cannot be marked as defaultable
- Preserves field visibility in generated companion structs
- Only generates companion struct when defaultable fields are present
This commit is contained in:
2025-06-04 22:15:38 +02:00
parent aafbfb7964
commit a38b8e873d
10 changed files with 998 additions and 101 deletions

View File

@@ -4,9 +4,9 @@ services:
restart: unless-stopped
container_name: georm-backend-db
environment:
POSTGRES_PASSWORD: ${DB_PASSWORD}
POSTGRES_USER: ${DB_USER}
POSTGRES_DB: ${DB_NAME}
POSTGRES_PASSWORD: georm
POSTGRES_USER: georm
POSTGRES_DB: georm
ports:
- 127.0.0.1:5432:5432
volumes: