fix: parse uuid with 'u' prefix
This commit is contained in:
parent
cf76cc4d10
commit
464c0b6698
1 changed files with 10 additions and 5 deletions
|
|
@ -100,17 +100,17 @@ pub fn parse_string(input: &str) -> IResult<&str, Value> {
|
||||||
Ok((input, Value::Indexable(IndexableValue::String(value))))
|
Ok((input, Value::Indexable(IndexableValue::String(value))))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_uuid(input: &str) -> IResult<&str, Value> {
|
pub fn parse_uuid(input: &str) -> IResult<&str, Value> {
|
||||||
// TODO: make it actually uuid
|
let (input, value) = pair(char('u'), u64)(input).map(|(input, (_, v))| {
|
||||||
u64(input).map(|(input, v)| {
|
|
||||||
(input, Value::Indexable(IndexableValue::Uuid(v)))
|
(input, Value::Indexable(IndexableValue::Uuid(v)))
|
||||||
})
|
})?;
|
||||||
|
Ok((input, value))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use minisql::type_system::{IndexableValue, Value};
|
use minisql::type_system::{IndexableValue, Value};
|
||||||
use crate::parsing::literal::{parse_db_value, parse_string};
|
use crate::parsing::literal::{parse_db_value, parse_string, parse_uuid};
|
||||||
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
@ -161,4 +161,9 @@ mod tests {
|
||||||
fn test_parse_int() {
|
fn test_parse_int() {
|
||||||
assert_eq!(parse_db_value("5134616"), Ok(("", Value::Indexable(IndexableValue::Int(5134616)))));
|
assert_eq!(parse_db_value("5134616"), Ok(("", Value::Indexable(IndexableValue::Int(5134616)))));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_parse_uuid() {
|
||||||
|
assert_eq!(parse_uuid("u131515"), Ok(("", Value::Indexable(IndexableValue::Uuid(131515)))))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue