Powerful & expressive ORM/query-builder/static checker for raw queries/Fully Automated migration tooling , designed to offer an intuitive API, strict type-checking, novel features, & full specification support. It provides a fresh perspective in data management. Currently supports SurrealDB engine. RDMSs(PG, MYSQL etc) and others coming soon
85
stars
2
forks
source link
47 support optional and complex vector type autoinferences #48
This update is all about smarter type inference, stronger compile-time checks, and cleaner, more maintainable code structures. These advancements will streamline your development workflow and improve the robustness of your applications. Changes include:
Type Inference Enhancements: can now infer optional field types, array content types, and complex nested vector types, streamlining the development process by reducing the need for explicit type annotations.
Compile-Time Assertions: New compile-time validators have been implemented to assert the presence of options and vectors, enhancing type safety and reducing the risk of runtime errors.
Static Assertions for Vec Fields: Static assertions have been added for Vec field inner types, providing an additional layer of type checking at compile time.
Support for Nested Vectors: The macro now supports multiple nested vectors of surreal objects, allowing for more complex data structures to be easily handled within queries.
Path Clarification: The full path for the convert-From trait has been specified, ensuring clarity and avoiding any potential conflicts or ambiguities in the codebase.
Refactoring and Cleanup: The code has undergone significant refactoring and cleanup, improving readability and maintainability. This includes better heuristics for checking field types and removing unnecessary code.
Test Updates: Geometry collection tests have been updated to reflect the new changes, ensuring that all features work as expected.
Examples and Demonstrations: Additional examples of auto-inferred types have been provided, showcasing the macro's enhanced capabilities.
#[derive(Node, Serialize, Deserialize, Debug, Clone, Default)]
#[serde(rename_all = "camelCase")]
#[surreal_orm(table_name = "test_stuff")]
pub struct TestStuff {
pub id: SurrealSimpleId<Self>,
#[surreal_orm(type_ = "option<string>")]
pub amt: Option<Strength>,
// Would be throw a compile-time error since we cannot directly guess the 'Strength' type from the AST. Use explicit type if you want. You can use `#[surreal_orm(type_ = "int")]` to fix this. You can also use the type - "any"
pub amt2: Option<Strength>,
// Would be autoinferred as option<int>
pub amt3: Option<u64>,
// Inner type is now autoinferred as vec<int>
pub amt4: Vec<u64>,
pub count: u64,
}
#[derive(Node, Debug, Serialize, Deserialize, Clone)]
#[serde(rename_all = "camelCase")]
#[surreal_orm(table_name = "company")]
struct Company {
id: SurrealId<Self, i32>,
// Now works
#[surreal_orm(nest_array = "Person")]
founders: Vec<Person>,
// Now works
#[surreal_orm(nest_array = "Person")]
founders_multiple_nesting: Vec<Vec<Person>>,
#[surreal_orm(nest_array = "Person")]
founders: Vec<Person>,
#[surreal_orm(nest_array = "Person")]
founders_multiple_nesting: Vec<Vec<Person>>,
#[surreal_orm(nest_array = "Person")]
founders_10: Vec<Vec<Vec<Vec<Vec<Vec<Vec<Vec<Vec<Vec<Person>>>>>>>>>>,
}
This update is all about smarter type inference, stronger compile-time checks, and cleaner, more maintainable code structures. These advancements will streamline your development workflow and improve the robustness of your applications. Changes include:
Type Inference Enhancements: can now infer optional field types, array content types, and complex nested vector types, streamlining the development process by reducing the need for explicit type annotations.
Compile-Time Assertions: New compile-time validators have been implemented to assert the presence of options and vectors, enhancing type safety and reducing the risk of runtime errors.
Static Assertions for Vec Fields: Static assertions have been added for Vec field inner types, providing an additional layer of type checking at compile time.
Support for Nested Vectors: The macro now supports multiple nested vectors of surreal objects, allowing for more complex data structures to be easily handled within queries.
Path Clarification: The full path for the
convert-From
trait has been specified, ensuring clarity and avoiding any potential conflicts or ambiguities in the codebase.Refactoring and Cleanup: The code has undergone significant refactoring and cleanup, improving readability and maintainability. This includes better heuristics for checking field types and removing unnecessary code.
Test Updates: Geometry collection tests have been updated to reflect the new changes, ensuring that all features work as expected.
Examples and Demonstrations: Additional examples of auto-inferred types have been provided, showcasing the macro's enhanced capabilities.