← Graph

Ruby Hash as SQL AST

concept 1 connections

Yippee design idea demonstrated by Stephen Margheim: represent SQL queries as Ruby hashes whose keys and values (constants, nested hashes, arrays, booleans, method calls) map directly to SQL concepts, with no additional DSL vocabulary — it is 'just SQL, structured'. Turing-complete for SQL. Adds SQL's one missing feature: composability. Fragments (e.g. an EXISTS sub-tree) can be stored in variables or constants and recombined dynamically as plain Ruby data. Enabled by Plume, Stephen's SQLite SQL parser in Ruby.

category
pattern
about
Ruby Hash as SQL AST concept
Code sample demonstrates representing SQL queries as composable Ruby hashes.

Provenance

Read by
4 extractions