1 unstable release

0.1.0 Feb 4, 2026

#2671 in Database interfaces


Used in ormdb-cli

MIT license

215KB
5K SLoC

ormdb-lang

Crates.io Documentation License: MIT

ORM-style query language parser and compiler for ORMDB.

Overview

ormdb-lang provides a human-readable query language that compiles to ORMDB's typed protocol IR. It offers:

  • Lexer - Fast tokenization with logos
  • Parser - Recursive descent parser for query syntax
  • Compiler - Transforms AST to protocol IR
  • Error Reporting - Clear, actionable error messages

Query Syntax

// Fetch users with their posts
FETCH User
WHERE id = 1
INCLUDE posts {
    INCLUDE comments
}

// Create a new user
CREATE User {
    name: "Alice",
    email: "alice@example.com"
}

// Update with filter
UPDATE User
WHERE active = false
SET { archived: true }

// Delete with cascade
DELETE Post
WHERE author.id = 1

Usage

use ormdb_lang::{Parser, Compiler};
use ormdb_proto::Query;

// Parse query text
let ast = Parser::parse("FETCH User WHERE id = 1")?;

// Compile to protocol IR
let query: Query = Compiler::compile(ast)?;

Architecture

ormdb-lang/
├── src/
│   ├── lexer.rs      # Token definitions (logos)
│   ├── parser.rs     # Recursive descent parser
│   ├── ast.rs        # Abstract syntax tree
│   ├── compiler.rs   # AST to IR compilation
│   └── error.rs      # Error types and reporting

License

MIT License - see LICENSE for details.

Part of the ORMDB project.

Dependencies

~1.9–2.9MB
~62K SLoC