Oyelowo / surreal-orm

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
93 stars 3 forks source link

9 Enhancement of Data Type Definitions in SurrealDB: Implementation of Comprehensive Data Types and Parse Functions #10

Closed Oyelowo closed 1 year ago

Oyelowo commented 1 year ago

Description:

This Pull Request aims to enhance the data type definitions in SurrealDB. It provides extensive support for a variety of data types and implements parsing functionalities to ensure smooth and efficient data handling, making Surreal-orm more versatile and robust.

Main Features:

  1. Extended Data Types: Surreal-orm now supports a plethora of more explicit/specific data types including but not limited to Geometry Types, Array Types, Set Types, and more.

  2. Parsing Functionality: Implemented parsing functions for various data types ensuring seamless integration and interaction with SurrealDB.

  3. Explicit Data Type Definitions: Enhanced the definition of data types, allowing users to explicitly set the data type of a field in SurrealDB.

  4. Comprehensive Testing: The implementation is thoroughly tested ensuring that each data type and parse function works as intended.

Detailed Overview:

New Data Types:

Parsing and Display:

Utility Functions:

Testing:

Example:

use surrealdb::{FieldTypee, parse_db_field_type};
assert_eq!(parse_db_field_type("any"), Ok(("", FieldTypee::Any)));
assert_eq!(parse_db_field_type("null"), Ok(("", FieldTypee::Null)));
assert_eq!(parse_db_field_type("int | option<float> | array<option<string>|int|null, 10> | set<option<number>|float|null, 10> | option<array> | option<set<option<int>>>"),
        FieldTypee::Union(vec![
            FieldTypee::Int,
            FieldTypee::Option(Box::new(FieldTypee::Float)),
            FieldTypee::Array(
                Box::new(FieldTypee::Union(vec![
                    FieldTypee::Option(Box::new(FieldTypee::String)),
                    FieldTypee::Int,
                    FieldTypee::Null
                ])),
                Some(10)
            ),
            FieldTypee::Set(
                Box::new(FieldTypee::Union(vec![
                    FieldTypee::Option(Box::new(FieldTypee::Number)),
                    FieldTypee::Float,
                    FieldTypee::Null
                ])),
                Some(10)
            ),
            FieldTypee::Option(Box::new(FieldTypee::Array(
                Box::new(FieldTypee::Any),
                None
            ))),
            FieldTypee::Option(Box::new(FieldTypee::Set(
                Box::new(FieldTypee::Option(Box::new(FieldTypee::Int))),
                None
            )))
        ])
    );

Impact:

This enhancement will significantly impact the versatility of surreal-orm, allowing users to handle various data types efficiently, and ensuring more robust and flexible data management.

Future Work:

How to Test:

Reviewers:

Notes to Reviewers:


Changes:

Files Changed:

Checklist:

Acknowledgements:

-

Screenshots: