Skip to content

Commit f457ed9

Browse files
committed
Rename VarChar -> Xml
1 parent 3ba9af9 commit f457ed9

File tree

15 files changed

+46
-49
lines changed

15 files changed

+46
-49
lines changed

modules/data/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ sqlite = ["assembly-fdb/sqlite"]
1515
serde-derives = ["assembly-fdb/serde-derives", "assembly-xml/serialize"]
1616

1717
[dependencies.assembly-fdb]
18-
version = "0.1.0"
18+
version = "0.2.0"
1919
path = "../fdb"
2020

2121
[dependencies.assembly-xml]

modules/data/examples/xmldb-to-fdb.rs

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -68,25 +68,22 @@ fn main() -> color_eyre::Result<()> {
6868

6969
while let Some(col) = expect_column_or_end_columns(xml, buf)? {
7070
let data_type = match col.r#type {
71-
ValueType::Bit => common::ValueType::Boolean,
72-
ValueType::Float => common::ValueType::Float,
73-
ValueType::Real => common::ValueType::Float,
74-
ValueType::Int => common::ValueType::Integer,
75-
ValueType::BigInt => common::ValueType::BigInt,
76-
ValueType::SmallInt => common::ValueType::Integer,
77-
ValueType::TinyInt => common::ValueType::Integer,
78-
ValueType::Binary => common::ValueType::Text,
79-
ValueType::VarBinary => common::ValueType::Text,
80-
ValueType::Char => common::ValueType::Text,
81-
ValueType::VarChar => common::ValueType::Text,
82-
ValueType::NChar => common::ValueType::Text,
83-
ValueType::NVarChar => common::ValueType::Text,
84-
ValueType::NText => common::ValueType::VarChar,
85-
ValueType::Text => common::ValueType::VarChar,
86-
ValueType::Image => common::ValueType::VarChar,
87-
ValueType::DateTime => common::ValueType::BigInt,
88-
ValueType::Xml => common::ValueType::VarChar,
8971
ValueType::Null => common::ValueType::Nothing,
72+
ValueType::Bit => common::ValueType::Boolean,
73+
ValueType::Float | ValueType::Real => common::ValueType::Float,
74+
ValueType::Int | ValueType::SmallInt | ValueType::TinyInt => {
75+
common::ValueType::Integer
76+
}
77+
ValueType::BigInt | ValueType::DateTime => common::ValueType::BigInt,
78+
ValueType::Binary
79+
| ValueType::VarBinary
80+
| ValueType::Char
81+
| ValueType::VarChar
82+
| ValueType::NChar
83+
| ValueType::NVarChar => common::ValueType::Text,
84+
ValueType::NText | ValueType::Text | ValueType::Image | ValueType::Xml => {
85+
common::ValueType::Xml
86+
}
9087
};
9188
if col_map.is_empty() {
9289
// first col
@@ -121,7 +118,7 @@ fn main() -> color_eyre::Result<()> {
121118
common::ValueType::Text => core::Field::Text(src_value),
122119
common::ValueType::Boolean => core::Field::Boolean(&src_value != "0"),
123120
common::ValueType::BigInt => core::Field::BigInt(src_value.parse().unwrap()),
124-
common::ValueType::VarChar => core::Field::VarChar(src_value),
121+
common::ValueType::Xml => core::Field::Xml(src_value),
125122
};
126123

127124
if col_index == 0 {
@@ -136,7 +133,7 @@ fn main() -> color_eyre::Result<()> {
136133
let lat1 = Latin1String::encode(text);
137134
pk = Some((lat1.hash() % 128) as usize);
138135
}
139-
core::Field::VarChar(var_char) => {
136+
core::Field::Xml(var_char) => {
140137
let lat1 = Latin1String::encode(var_char);
141138
pk = Some((lat1.hash() % 128) as usize);
142139
}

modules/fdb/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "assembly-fdb"
3-
version = "0.1.0"
3+
version = "0.2.0"
44
edition = "2018"
55
license = "MIT or Apache-2.0"
66

modules/fdb/examples/fdb-index.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ fn field_to_cell(field: mem::Field) -> PCell {
2828
Field::Text(v) => PCell::new(&format!("{:?}", v)),
2929
Field::Boolean(v) => PCell::new(if v { "true" } else { "false" }),
3030
Field::BigInt(v) => PCell::new(&format!("{} (i64)", v)),
31-
Field::VarChar(v) => PCell::new(&format!("{:?}", v)),
31+
Field::Xml(v) => PCell::new(&format!("{:?}", v)),
3232
}
3333
}
3434

modules/fdb/examples/fdb-stat.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ fn main() -> color_eyre::Result<()> {
6161
ValueType::Text => text_column_count += 1,
6262
ValueType::Boolean => bool_column_count += 1,
6363
ValueType::BigInt => bigint_column_count += 1,
64-
ValueType::VarChar => xml_column_count += 1,
64+
ValueType::Xml => xml_column_count += 1,
6565
}
6666
}
6767

@@ -81,7 +81,7 @@ fn main() -> color_eyre::Result<()> {
8181
Value::Text(_) => text_field_count += 1,
8282
Value::Boolean(_) => bool_field_count += 1,
8383
Value::BigInt(_) => bigint_field_count += 1,
84-
Value::VarChar(_) => xml_field_count += 1,
84+
Value::Xml(_) => xml_field_count += 1,
8585
}
8686
}
8787
}

modules/fdb/examples/sqlite-to-fdb.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ fn main() -> eyre::Result<()> {
124124
ValueRef::Real(f) => Field::Float(f as f32),
125125
ValueRef::Text(t) => match target_types[index] {
126126
ValueType::Text => Field::Text(String::from(std::str::from_utf8(t)?)),
127-
ValueType::VarChar => Field::VarChar(String::from(std::str::from_utf8(t)?)),
127+
ValueType::Xml => Field::Xml(String::from(std::str::from_utf8(t)?)),
128128
_ => {
129129
return Err(eyre!(
130130
"Invalid target datatype; cannot store SQLite Text as FDB {:?}",

modules/fdb/src/common.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ pub enum Value<T: Context> {
210210
/// A 64 bit integer
211211
BigInt(T::I64),
212212
/// A (XML?) string
213-
VarChar(T::XML),
213+
Xml(T::XML),
214214
}
215215

216216
impl<T: Context> Clone for Value<T>
@@ -227,7 +227,7 @@ where
227227
Value::Text(v) => Value::Text(v.clone()),
228228
Value::Boolean(v) => Value::Boolean(*v),
229229
Value::BigInt(v) => Value::BigInt(v.clone()),
230-
Value::VarChar(v) => Value::VarChar(v.clone()),
230+
Value::Xml(v) => Value::Xml(v.clone()),
231231
}
232232
}
233233
}
@@ -254,7 +254,7 @@ impl<T: Context> Value<T> {
254254
Value::Text(v) => Value::Text(mapper.map_string(v)),
255255
Value::Boolean(v) => Value::Boolean(*v),
256256
Value::BigInt(v) => Value::BigInt(mapper.map_i64(v)),
257-
Value::VarChar(v) => Value::VarChar(mapper.map_xml(v)),
257+
Value::Xml(v) => Value::Xml(mapper.map_xml(v)),
258258
}
259259
}
260260

@@ -305,7 +305,7 @@ impl<T: Context> Value<T> {
305305

306306
/// Returns `Some` with the value if the field contains a [`Value::VarChar`].
307307
pub fn into_opt_varchar(self) -> Option<T::XML> {
308-
if let Self::VarChar(value) = self {
308+
if let Self::Xml(value) = self {
309309
Some(value)
310310
} else {
311311
None
@@ -322,7 +322,7 @@ impl<T: Context> From<&Value<T>> for ValueType {
322322
Value::Text(_) => ValueType::Text,
323323
Value::Boolean(_) => ValueType::Boolean,
324324
Value::BigInt(_) => ValueType::BigInt,
325-
Value::VarChar(_) => ValueType::VarChar,
325+
Value::Xml(_) => ValueType::Xml,
326326
}
327327
}
328328
}
@@ -344,7 +344,7 @@ pub enum ValueType {
344344
/// A 64 bit integer
345345
BigInt,
346346
/// An (XML?) string
347-
VarChar,
347+
Xml,
348348
}
349349

350350
impl ValueType {
@@ -357,7 +357,7 @@ impl ValueType {
357357
ValueType::Text => "TEXT",
358358
ValueType::Boolean => "BOOLEAN",
359359
ValueType::BigInt => "BIGINT",
360-
ValueType::VarChar => "VARCHAR",
360+
ValueType::Xml => "VARCHAR",
361361
}
362362
}
363363
}
@@ -377,7 +377,7 @@ impl From<ValueType> for u8 {
377377
ValueType::Text => 4,
378378
ValueType::Boolean => 5,
379379
ValueType::BigInt => 6,
380-
ValueType::VarChar => 8,
380+
ValueType::Xml => 8,
381381
}
382382
}
383383
}
@@ -417,7 +417,7 @@ impl TryFrom<u32> for ValueType {
417417
4 => Ok(ValueType::Text),
418418
5 => Ok(ValueType::Boolean),
419419
6 => Ok(ValueType::BigInt),
420-
8 => Ok(ValueType::VarChar),
420+
8 => Ok(ValueType::Xml),
421421
_ => Err(UnknownValueType(value_type)),
422422
}
423423
}

modules/fdb/src/core/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ impl From<MemField<'_>> for Field {
4848
MemField::Text(v) => Field::Text(v.decode().into_owned()),
4949
MemField::Boolean(v) => Field::Boolean(v),
5050
MemField::BigInt(v) => Field::BigInt(v),
51-
MemField::VarChar(v) => Field::VarChar(v.decode().into_owned()),
51+
MemField::Xml(v) => Field::Xml(v.decode().into_owned()),
5252
}
5353
}
5454
}
@@ -62,7 +62,7 @@ impl PartialEq<MemField<'_>> for Field {
6262
Value::Text(x) => matches!(self, Self::Text(y) if x.decode().as_ref() == y),
6363
Value::Boolean(x) => matches!(self, Self::Boolean(y) if x == y),
6464
Value::BigInt(x) => matches!(self, Self::BigInt(y) if x == y),
65-
Value::VarChar(x) => matches!(self, Self::VarChar(y) if x.decode().as_ref() == y),
65+
Value::Xml(x) => matches!(self, Self::Xml(y) if x.decode().as_ref() == y),
6666
}
6767
}
6868
}
@@ -76,7 +76,7 @@ impl fmt::Display for Field {
7676
Field::Text(t) => write!(f, "{:?}", t),
7777
Field::Boolean(b) => write!(f, "{}", b),
7878
Field::BigInt(i) => write!(f, "{}", i),
79-
Field::VarChar(v) => write!(f, "{:?}", v),
79+
Field::Xml(v) => write!(f, "{:?}", v),
8080
}
8181
}
8282
}

modules/fdb/src/file/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ impl TryFrom<FDBFieldData> for FDBFieldValue {
233233
ValueType::BigInt => FDBFieldValue::BigInt(IndirectValue {
234234
addr: u32::from_le_bytes(value.value),
235235
}),
236-
ValueType::VarChar => FDBFieldValue::VarChar(IndirectValue {
236+
ValueType::Xml => FDBFieldValue::Xml(IndirectValue {
237237
addr: u32::from_le_bytes(value.value),
238238
}),
239239
})

modules/fdb/src/mem/c.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ impl Repr for FDBFieldDataC {
196196
ValueType::BigInt => FDBFieldValue::BigInt(IndirectValue {
197197
addr: u32::from_le_bytes(self.value.0),
198198
}),
199-
ValueType::VarChar => FDBFieldValue::VarChar(IndirectValue {
199+
ValueType::Xml => FDBFieldValue::Xml(IndirectValue {
200200
addr: u32::from_le_bytes(self.value.0),
201201
}),
202202
}

0 commit comments

Comments
 (0)