Documentation
¶
Overview ¶
Package r3utils provides shared utility functions used across r3 packages.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsRelationType ¶
IsRelationType returns true if the Go type represents a relation field (slice, map, pointer-to-struct, or struct — except time.Time and types that round-trip as a single column via database/sql).
A struct/slice/map that implements driver.Valuer or sql.Scanner (checked on the type and its pointer, since Scan's receiver is conventionally a pointer) is a scalar-like column, not a relation — this is what makes r3.JSONColumn persist as a JSON column instead of being silently dropped.
This is the SQL-shaped classification: what cannot be one SQL column without serialisation. It gates engine/sql and r3.SchemaOf, where an untagged slice or struct field is therefore not persisted at all. The document-store engines (engine/mongo, engine/file) classify by declaration instead - see r3tag.DeclaresRelation - because there an array or a subdocument is the native representation of such a field.
func ResolveElementType ¶
ResolveElementType unwraps slice and pointer types to get the underlying struct type. E.g. []CityTranslation -> CityTranslation, *City -> City.
func ToSnakeCase ¶
ToSnakeCase converts a name (PascalCase, camelCase, etc.) to snake_case. It correctly handles acronyms like "CityID" → "city_id".
func ToSnakeCasePlural ¶
ToSnakeCasePlural converts a name to snake_case and applies naive pluralization.
Types ¶
This section is empty.