Merge pull request #623 from gwenn/index-constraint-op

Add missing IndexConstraintOp entries
This commit is contained in:
gwenn 2020-01-26 18:26:40 +01:00 committed by GitHub
commit b2c63c8224
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -244,16 +244,46 @@ pub trait CreateVTab: VTab {
} }
} }
bitflags::bitflags! { ///Index constraint operator.
#[doc = "Index constraint operator."] #[derive(Debug, PartialEq)]
#[repr(C)] #[allow(non_snake_case, non_camel_case_types)]
pub struct IndexConstraintOp: ::std::os::raw::c_uchar { pub enum IndexConstraintOp {
const SQLITE_INDEX_CONSTRAINT_EQ = 2; SQLITE_INDEX_CONSTRAINT_EQ,
const SQLITE_INDEX_CONSTRAINT_GT = 4; SQLITE_INDEX_CONSTRAINT_GT,
const SQLITE_INDEX_CONSTRAINT_LE = 8; SQLITE_INDEX_CONSTRAINT_LE,
const SQLITE_INDEX_CONSTRAINT_LT = 16; SQLITE_INDEX_CONSTRAINT_LT,
const SQLITE_INDEX_CONSTRAINT_GE = 32; SQLITE_INDEX_CONSTRAINT_GE,
const SQLITE_INDEX_CONSTRAINT_MATCH = 64; SQLITE_INDEX_CONSTRAINT_MATCH,
SQLITE_INDEX_CONSTRAINT_LIKE, // 3.10.0
SQLITE_INDEX_CONSTRAINT_GLOB, // 3.10.0
SQLITE_INDEX_CONSTRAINT_REGEXP, // 3.10.0
SQLITE_INDEX_CONSTRAINT_NE, // 3.21.0
SQLITE_INDEX_CONSTRAINT_ISNOT, // 3.21.0
SQLITE_INDEX_CONSTRAINT_ISNOTNULL, // 3.21.0
SQLITE_INDEX_CONSTRAINT_ISNULL, // 3.21.0
SQLITE_INDEX_CONSTRAINT_IS, // 3.21.0
SQLITE_INDEX_CONSTRAINT_FUNCTION(u8), // 3.25.0
}
impl From<u8> for IndexConstraintOp {
fn from(code: u8) -> IndexConstraintOp {
match code {
2 => IndexConstraintOp::SQLITE_INDEX_CONSTRAINT_EQ,
4 => IndexConstraintOp::SQLITE_INDEX_CONSTRAINT_GT,
8 => IndexConstraintOp::SQLITE_INDEX_CONSTRAINT_LE,
16 => IndexConstraintOp::SQLITE_INDEX_CONSTRAINT_LT,
32 => IndexConstraintOp::SQLITE_INDEX_CONSTRAINT_GE,
64 => IndexConstraintOp::SQLITE_INDEX_CONSTRAINT_MATCH,
65 => IndexConstraintOp::SQLITE_INDEX_CONSTRAINT_LIKE,
66 => IndexConstraintOp::SQLITE_INDEX_CONSTRAINT_GLOB,
67 => IndexConstraintOp::SQLITE_INDEX_CONSTRAINT_REGEXP,
68 => IndexConstraintOp::SQLITE_INDEX_CONSTRAINT_NE,
69 => IndexConstraintOp::SQLITE_INDEX_CONSTRAINT_ISNOT,
70 => IndexConstraintOp::SQLITE_INDEX_CONSTRAINT_ISNOTNULL,
71 => IndexConstraintOp::SQLITE_INDEX_CONSTRAINT_ISNULL,
72 => IndexConstraintOp::SQLITE_INDEX_CONSTRAINT_IS,
v => IndexConstraintOp::SQLITE_INDEX_CONSTRAINT_FUNCTION(v),
}
} }
} }
@ -356,7 +386,7 @@ impl IndexConstraint<'_> {
/// Constraint operator /// Constraint operator
pub fn operator(&self) -> IndexConstraintOp { pub fn operator(&self) -> IndexConstraintOp {
IndexConstraintOp::from_bits_truncate(self.0.op) IndexConstraintOp::from(self.0.op)
} }
/// True if this constraint is usable /// True if this constraint is usable