Skip to content

Commit 1108d34

Browse files
committed
Added more types for rorm-sql
1 parent 3be4c2c commit 1108d34

File tree

2 files changed

+85
-13
lines changed

2 files changed

+85
-13
lines changed

Cargo.toml

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "rorm-sql"
3-
version = "0.6.2"
3+
version = "0.7.0"
44
edition = "2021"
55
keywords = ["database", "abstraction-layer", "sqlite", "postgres", "mysql"]
66
categories = ["database"]
@@ -14,9 +14,22 @@ description = "The sql abstraction layer."
1414
[dependencies]
1515
# Date & time library
1616
chrono = { version = ">=0.4.20", default-features = false }
17+
time = { version = "~0.3" }
18+
19+
# Serialization library
20+
serde = { version = "~1" }
21+
serde_json = { version = "~1" }
22+
23+
# Uuid support
24+
uuid = { version = "~1" }
1725

1826
# SQlite bindings for printf
19-
libsqlite3-sys = { version = "~0.24", optional = true }
27+
libsqlite3-sys = { version = "~0.26", optional = true }
28+
29+
# Bitvec support
30+
bit-vec = { version = "~0.6", optional = true }
31+
# Ip network
32+
ip_network = { version = "~0.4", optional = true }
2033

2134
rorm-declaration = { version = "0.3.0", path = "../rorm-declaration" }
2235

@@ -31,4 +44,7 @@ sqlite = [
3144
"dep:libsqlite3-sys",
3245
]
3346
mysql = []
34-
postgres = []
47+
postgres = [
48+
"dep:bit-vec",
49+
"dep:ip_network",
50+
]

src/value.rs

Lines changed: 66 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
use chrono::{NaiveDate, NaiveDateTime, NaiveTime};
1+
use chrono::{DateTime, NaiveDate, NaiveDateTime, NaiveTime, Utc};
2+
use time::{Date, OffsetDateTime, PrimitiveDateTime, Time};
3+
use uuid::Uuid;
24

35
/// This enum represents a [Null](Value::Null)'s type
46
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
@@ -22,11 +24,38 @@ pub enum NullType {
2224
/// binary representation
2325
Binary,
2426
/// Naive Time representation
25-
NaiveTime,
27+
ChronoNaiveTime,
2628
/// Naive Date representation
27-
NaiveDate,
29+
ChronoNaiveDate,
2830
/// Naive DateTime representation
29-
NaiveDateTime,
31+
ChronoNaiveDateTime,
32+
/// Chrono timezone aware date time representation
33+
ChronoDateTime,
34+
/// time's date representation
35+
TimeDate,
36+
/// time's time representation
37+
TimeTime,
38+
/// time's offset datetime representation
39+
TimeOffsetDateTime,
40+
/// time's primitive datetime representation
41+
TimePrimitiveDateTime,
42+
/// Uuid representation
43+
Uuid,
44+
/// Uuid in hyphenated representation
45+
UuidHyphenated,
46+
/// Uuid in simple text representation
47+
UuidSimple,
48+
/// serde_json's Value representation
49+
JsonValue,
50+
/// Mac address representation
51+
#[cfg(all(feature = "postgres", not(any(feature = "mysql", feature = "sqlite"))))]
52+
MacAddress,
53+
/// IP network presentation
54+
#[cfg(all(feature = "postgres", not(any(feature = "mysql", feature = "sqlite"))))]
55+
IpNetwork,
56+
/// Bit vec representation
57+
#[cfg(all(feature = "postgres", not(any(feature = "mysql", feature = "sqlite"))))]
58+
BitVec,
3059
}
3160

3261
/**
@@ -66,10 +95,37 @@ pub enum Value<'a> {
6695
F32(f32),
6796
/// binary representation
6897
Binary(&'a [u8]),
69-
/// Naive Time representation
70-
NaiveTime(NaiveTime),
71-
/// Naive Date representation
72-
NaiveDate(NaiveDate),
73-
/// Naive DateTime representation
74-
NaiveDateTime(NaiveDateTime),
98+
/// chrono's Naive Time representation
99+
ChronoNaiveTime(NaiveTime),
100+
/// chrono's Naive Date representation
101+
ChronoNaiveDate(NaiveDate),
102+
/// chrono's Naive DateTime representation
103+
ChronoNaiveDateTime(NaiveDateTime),
104+
/// chrono's Timezone aware datetime
105+
ChronoDateTime(DateTime<Utc>),
106+
/// time's date representation
107+
TimeDate(Date),
108+
/// time's time representation
109+
TimeTime(Time),
110+
/// time's offset datetime representation
111+
TimeOffsetDateTime(OffsetDateTime),
112+
/// time's primitive datetime representation
113+
TimePrimitiveDateTime(PrimitiveDateTime),
114+
/// Uuid representation
115+
Uuid(Uuid),
116+
/// Uuid in hyphenated representation
117+
UuidHyphenated(Uuid),
118+
/// Uuid in simple text representation
119+
UuidSimple(Uuid),
120+
/// serde_json's Value representation
121+
JsonValue(&'a serde_json::Value),
122+
/// Mac address representation
123+
#[cfg(all(feature = "postgres", not(any(feature = "mysql", feature = "sqlite"))))]
124+
MacAddress([u8; 6]),
125+
/// IP network presentation
126+
#[cfg(all(feature = "postgres", not(any(feature = "mysql", feature = "sqlite"))))]
127+
IpNetwork(ip_network::IpNetwork),
128+
/// Bit vec representation
129+
#[cfg(all(feature = "postgres", not(any(feature = "mysql", feature = "sqlite"))))]
130+
BitVec(&'a bit_vec::BitVec),
75131
}

0 commit comments

Comments
 (0)