Georm 0.2.0 - Major Feature Release
We're excited to announce Georm 0.2.0, a major release packed with new features, performance improvements, and comprehensive documentation updates! 🚀
What's New
🆕 Major Features
Composite Primary Key Support
- Multi-field primary keys: Use multiple
#[georm(id)]fields to create composite primary keys - Auto-generated ID structs: Automatically creates
{EntityName}Idstructs for type-safe composite key handling - Full CRUD support: All operations (
find,create,update,delete,create_or_update) work seamlessly with composite keys
#[derive(Georm)]
#[georm(table = "user_roles")]
pub struct UserRole {
#[georm(id)]
pub user_id: i32,
#[georm(id)]
pub role_id: i32,
pub assigned_at: chrono::DateTime<chrono::Utc>,
}
// Auto-generated ID struct
let id = UserRoleId { user_id: 1, role_id: 2 };
let user_role = UserRole::find(pool, &id).await?;Defaultable Fields with Companion Structs
- Database defaults support: Mark fields with
#[georm(defaultable)]for auto-generated or default values - Companion struct generation: Creates
{Entity}Defaultstructs where defaultable fields becomeOption<T> - Easier entity creation: Simplifies creating entities when some fields have database defaults
#[derive(Georm)]
#[georm(table = "posts")]
pub struct Post {
#[georm(id, defaultable)]
pub id: i32, // Auto-generated serial
pub title: String,
#[georm(defaultable)]
pub published: bool, // Database default (false)
#[georm(defaultable)]
pub created_at: chrono::DateTime<chrono::Utc>, // DEFAULT NOW()
}
// Use the generated companion struct
let post_default = PostDefault {
id: None, // Let database auto-generate
title: "My Post".to_string(),
published: None, // Use database default
created_at: None, // Use database default
};
let created_post = post_default.create(pool).await?;Foreign One-to-One Relationships
- Enhanced relationship support: Complete support for one-to-one relationships with foreign keys
- Automatic method generation: Generates getter methods for related entities
🚀 Performance & Reliability
Atomic Upsert Operations
- Race condition elimination: Replaced two-query create_or_update with single atomic PostgreSQL upsert
- Performance improvement: Reduced database round trips from 2-3 queries to 1
- PostgreSQL ON CONFLICT: Uses native PostgreSQL
INSERT ... ON CONFLICT ... DO UPDATE SETfor reliability
Modern Rust Support
- Rust 1.86 & Edition 2024: Updated to the latest Rust version and edition
- Dependency updates: Updated SQLx to 0.8.6 and other dependencies
- Security fixes: Updated tokio to address RUSTSEC-2025-0023
📚 Documentation & Examples
Comprehensive Documentation Rewrite
- Complete README overhaul: Comprehensive guide covering all features with examples
- Enhanced API documentation: Detailed method documentation with usage patterns
- Performance characteristics: Documentation of zero-cost abstractions and compile-time guarantees
Real-World Example
- PostgreSQL example: Full-featured example with user management, comments, and follower relationships
- Interactive CLI: Demonstrates CRUD operations and relationship handling
- Database migrations: Complete schema setup and migration examples
🛠️ Developer Experience
Improved Development Environment
- Devenv migration: Switched from Nix flakes to devenv for better developer experience
- Modular code organization: Split trait implementations into separate modules by operation type
- Enhanced tooling: Better IDE support and development workflow
Breaking Changes
create_or_update method implementation. The method signature remains the same, but the implementation now uses atomic upserts instead of separate find/create/update operations.
Migration Guide
From 0.1.x to 0.2.0
- Update your Cargo.toml:
[dependencies]
georm = "0.2.0"
sqlx = { version = "0.8.6", features = ["runtime-tokio-rustls", "postgres", "macros"] }-
Review create_or_update usage: The method now uses atomic upserts, which may have different error handling characteristics.
-
Consider using defaultable fields: If you have entities with database defaults, consider marking fields with
#[georm(defaultable)]for easier creation.
What's Next?
Looking ahead to future releases:
- Transaction Support (high priority)
- Composite Key Relationships: Relationship support for entities with composite primary keys
- Multi-Database Support: MySQL and SQLite support
- Field-Based Queries: Generate
find_by_{field}methods
Acknowledgments
This release represents a significant step forward in Georm's capabilities. Special thanks to the SQLx team for their excellent foundation that makes Georm's compile-time safety possible.
Full Changelog: 0.1.1...0.2.0