/// Supported SQL keywords for the Alopex dialect.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum Keyword {
    // DML
    SELECT,
    FROM,
    WHERE,
    DISTINCT,
    AS,
    INSERT,
    INTO,
    VALUES,
    UPDATE,
    SET,
    DELETE,

    // DDL
    CREATE,
    DROP,
    TABLE,
    INDEX,
    IF,
    NOT,
    EXISTS,
    USING,
    WITH,
    CONSTRAINT,
    ON,
    PRIMARY,
    KEY,
    DEFAULT,
    UNIQUE,

    // Clauses
    ORDER,
    BY,
    ASC,
    DESC,
    NULLS,
    FIRST,
    LAST,
    LIMIT,
    OFFSET,
    ESCAPE,

    // Expressions / operators
    TRUE,
    FALSE,
    NULL,
    AND,
    OR,
    LIKE,
    BETWEEN,
    IN,
    IS,

    // Types / extensions
    INTEGER,
    INT,
    BIGINT,
    FLOAT,
    DOUBLE,
    TEXT,
    BLOB,
    BOOLEAN,
    BOOL,
    TIMESTAMP,
    VECTOR,
    COSINE,
    L2,
    INNER,
    BTREE,
    HNSW,

    // Reserved / functions
    CAST,
    CASE,
    WHEN,
    THEN,
    ELSE,
    END,
    NOW,

    /// Not a recognized keyword.
    NoKeyword,
}

impl Keyword {
    /// Case-insensitive lookup.
    #[allow(clippy::should_implement_trait)]
    pub fn from_str(input: &str) -> Self {
        match input.to_ascii_uppercase().as_str() {
            "SELECT" => Self::SELECT,
            "FROM" => Self::FROM,
            "WHERE" => Self::WHERE,
            "DISTINCT" => Self::DISTINCT,
            "AS" => Self::AS,
            "INSERT" => Self::INSERT,
            "INTO" => Self::INTO,
            "VALUES" => Self::VALUES,
            "UPDATE" => Self::UPDATE,
            "SET" => Self::SET,
            "DELETE" => Self::DELETE,

            "CREATE" => Self::CREATE,
            "DROP" => Self::DROP,
            "TABLE" => Self::TABLE,
            "INDEX" => Self::INDEX,
            "IF" => Self::IF,
            "NOT" => Self::NOT,
            "EXISTS" => Self::EXISTS,
            "USING" => Self::USING,
            "WITH" => Self::WITH,
            "CONSTRAINT" => Self::CONSTRAINT,
            "ON" => Self::ON,
            "PRIMARY" => Self::PRIMARY,
            "KEY" => Self::KEY,
            "DEFAULT" => Self::DEFAULT,
            "UNIQUE" => Self::UNIQUE,

            "ORDER" => Self::ORDER,
            "BY" => Self::BY,
            "ASC" => Self::ASC,
            "DESC" => Self::DESC,
            "NULLS" => Self::NULLS,
            "FIRST" => Self::FIRST,
            "LAST" => Self::LAST,
            "LIMIT" => Self::LIMIT,
            "OFFSET" => Self::OFFSET,
            "ESCAPE" => Self::ESCAPE,

            "TRUE" => Self::TRUE,
            "FALSE" => Self::FALSE,
            "NULL" => Self::NULL,
            "AND" => Self::AND,
            "OR" => Self::OR,
            "LIKE" => Self::LIKE,
            "BETWEEN" => Self::BETWEEN,
            "IN" => Self::IN,
            "IS" => Self::IS,

            "INTEGER" => Self::INTEGER,
            "INT" => Self::INT,
            "BIGINT" => Self::BIGINT,
            "FLOAT" => Self::FLOAT,
            "DOUBLE" => Self::DOUBLE,
            "TEXT" => Self::TEXT,
            "BLOB" => Self::BLOB,
            "BOOLEAN" => Self::BOOLEAN,
            "BOOL" => Self::BOOL,
            "TIMESTAMP" => Self::TIMESTAMP,
            "VECTOR" => Self::VECTOR,
            "COSINE" => Self::COSINE,
            "L2" => Self::L2,
            "INNER" => Self::INNER,
            "BTREE" => Self::BTREE,
            "HNSW" => Self::HNSW,

            "CAST" => Self::CAST,
            "CASE" => Self::CASE,
            "WHEN" => Self::WHEN,
            "THEN" => Self::THEN,
            "ELSE" => Self::ELSE,
            "END" => Self::END,
            "NOW" => Self::NOW,
            _ => Self::NoKeyword,
        }
    }
}
