Started rasql-model
This commit is contained in:
parent
177490cf4d
commit
9eb02a767b
4 changed files with 99 additions and 0 deletions
7
Cargo.lock
generated
7
Cargo.lock
generated
|
|
@ -493,6 +493,13 @@ dependencies = [
|
||||||
"tokio-postgres",
|
"tokio-postgres",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rasql-model"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"sqlparser",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rasql-query"
|
name = "rasql-query"
|
||||||
version = "0.0.0"
|
version = "0.0.0"
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ resolver = "2"
|
||||||
members = [
|
members = [
|
||||||
"rasql-build",
|
"rasql-build",
|
||||||
"rasql-core",
|
"rasql-core",
|
||||||
|
"rasql-model",
|
||||||
"rasql-query",
|
"rasql-query",
|
||||||
"rasql-traits",
|
"rasql-traits",
|
||||||
]
|
]
|
||||||
|
|
|
||||||
7
rasql-model/Cargo.toml
Normal file
7
rasql-model/Cargo.toml
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
[package]
|
||||||
|
name = "rasql-model"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2024"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
sqlparser = "0.54.0"
|
||||||
84
rasql-model/src/lib.rs
Normal file
84
rasql-model/src/lib.rs
Normal file
|
|
@ -0,0 +1,84 @@
|
||||||
|
use std::{any::TypeId, borrow::Cow, num::NonZeroU32};
|
||||||
|
|
||||||
|
#[derive(Debug, Clone)]
|
||||||
|
pub enum PostgresDatatype {
|
||||||
|
Bigint,
|
||||||
|
Bigserial,
|
||||||
|
Bit(Option<NonZeroU32>),
|
||||||
|
BitVarying(Option<NonZeroU32>),
|
||||||
|
Boolean,
|
||||||
|
Box,
|
||||||
|
Bytea,
|
||||||
|
Character(Option<NonZeroU32>),
|
||||||
|
CharacterVarying(Option<NonZeroU32>),
|
||||||
|
Cidr,
|
||||||
|
Circle,
|
||||||
|
Date,
|
||||||
|
DoublePrecision,
|
||||||
|
Inet,
|
||||||
|
Integer,
|
||||||
|
Interval(Option<IntervalFields>,Option<u8>),
|
||||||
|
Json,
|
||||||
|
Jsonb,
|
||||||
|
Line,
|
||||||
|
Lseg,
|
||||||
|
Macaddr,
|
||||||
|
Macaddr8,
|
||||||
|
Money,
|
||||||
|
Numeric(Option<NumericConfig>),
|
||||||
|
Path,
|
||||||
|
PgLsn,
|
||||||
|
PgSnapshot,
|
||||||
|
Point,
|
||||||
|
Polygon,
|
||||||
|
Real,
|
||||||
|
SmallInt,
|
||||||
|
SmallSerial,
|
||||||
|
Serial,
|
||||||
|
Text,
|
||||||
|
Time(Option<u8>),
|
||||||
|
TimeTz(Option<u8>),
|
||||||
|
Timestamp(Option<u8>),
|
||||||
|
TimestampTz(Option<u8>),
|
||||||
|
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,
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue