diff --git a/Cargo.lock b/Cargo.lock index a211d09..31871d9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -493,6 +493,13 @@ dependencies = [ "tokio-postgres", ] +[[package]] +name = "rasql-model" +version = "0.1.0" +dependencies = [ + "sqlparser", +] + [[package]] name = "rasql-query" version = "0.0.0" diff --git a/Cargo.toml b/Cargo.toml index 128eedc..be3c469 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,6 +4,7 @@ resolver = "2" members = [ "rasql-build", "rasql-core", + "rasql-model", "rasql-query", "rasql-traits", ] diff --git a/rasql-model/Cargo.toml b/rasql-model/Cargo.toml new file mode 100644 index 0000000..eb012fe --- /dev/null +++ b/rasql-model/Cargo.toml @@ -0,0 +1,7 @@ +[package] +name = "rasql-model" +version = "0.1.0" +edition = "2024" + +[dependencies] +sqlparser = "0.54.0" diff --git a/rasql-model/src/lib.rs b/rasql-model/src/lib.rs new file mode 100644 index 0000000..7c47532 --- /dev/null +++ b/rasql-model/src/lib.rs @@ -0,0 +1,84 @@ +use std::{any::TypeId, borrow::Cow, num::NonZeroU32}; + +#[derive(Debug, Clone)] +pub enum PostgresDatatype { + Bigint, + Bigserial, + Bit(Option), + BitVarying(Option), + Boolean, + Box, + Bytea, + Character(Option), + CharacterVarying(Option), + Cidr, + Circle, + Date, + DoublePrecision, + Inet, + Integer, + Interval(Option,Option), + Json, + Jsonb, + Line, + Lseg, + Macaddr, + Macaddr8, + Money, + Numeric(Option), + Path, + PgLsn, + PgSnapshot, + Point, + Polygon, + Real, + SmallInt, + SmallSerial, + Serial, + Text, + Time(Option), + TimeTz(Option), + Timestamp(Option), + TimestampTz(Option), + TsQuery, + TsVector, + TxidSnapshot, + Uuid, + Xml, +} + +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum IntervalFields { + Year, + Month, + Day, + Hour, + Minute, + Second, + YearToMonth, + DayToHour, + DayToMinute, + DayToSecond, + HourToMinute, + HourToSecond, + MinuteToSecond, +} + +#[derive(Debug, Clone, Copy)] +pub enum NumericConfig { + Precision(u16), + PrecisionAndScale(u16, i16), +} + +#[derive(Debug, Clone)] +pub struct Table { + pub columns: Cow<'static, [Column]>, +} + +#[derive(Debug, Clone)] +pub struct Column { + pub postgres_name: Cow<'static, str>, + pub postgres_datatype: PostgresDatatype, + pub field_name: Cow<'static, str>, + pub rust_type_id: fn() -> TypeId, +}