This repository has been archived by the owner on Apr 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Wired the primary key system in further. Found out my array support h…
…ad major bugs in it.
- Loading branch information
Showing
8 changed files
with
159 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
use super::Index; | ||
use std::{ | ||
fmt::{self, Display, Formatter}, | ||
sync::Arc, | ||
}; | ||
|
||
mod parse_constraint; | ||
|
||
#[derive(Clone, Debug, PartialEq)] | ||
pub enum Constraint { | ||
PrimaryKey(PrimaryKeyConstraint), | ||
} | ||
|
||
/// ConstraintMapper exists to map to SqlType without imposing the cost of an empty version | ||
/// | ||
/// This will exist until this RFC is brought back: https://github.com/rust-lang/rfcs/pull/2593 | ||
#[derive(Clone, Debug, PartialEq)] | ||
pub enum ConstraintMapper { | ||
PrimaryKey, | ||
} | ||
|
||
impl Display for ConstraintMapper { | ||
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { | ||
match self { | ||
PrimaryKey => { | ||
write!(f, "PrimaryKey") | ||
} | ||
} | ||
} | ||
} | ||
|
||
#[derive(Clone, Debug, PartialEq)] | ||
pub struct PrimaryKeyConstraint { | ||
pub name: String, | ||
pub index: Arc<Index>, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
use nom::{ | ||
bytes::complete::tag_no_case, | ||
error::{make_error, ContextError, ErrorKind, ParseError}, | ||
IResult, | ||
}; | ||
|
||
use super::ConstraintMapper; | ||
|
||
pub fn parse_constraint<'a, E: ParseError<&'a str> + ContextError<&'a str>>( | ||
input: &'a str, | ||
) -> IResult<&'a str, ConstraintMapper, E> { | ||
let (input, matched) = tag_no_case("PrimaryKey")(input)?; | ||
|
||
let constraint_type = match matched { | ||
"PrimaryKey" => ConstraintMapper::PrimaryKey, | ||
_ => { | ||
return Err(nom::Err::Failure(make_error(input, ErrorKind::Fix))); | ||
} | ||
}; | ||
Ok((input, constraint_type)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters