Build sql queries programmatically.
Crystal code
require "sql"
users = SQL::Table.new("users")
articles = SQL::Table.new("articles")
query = users
.where(users["name"].qualify.eq("Tom"))
.join(articles, users["id"].qualify.eq(articles["user_id"].qualify))
query.to_sql
Generated SQL
SELECT * FROM `users` INNER JOIN `articles` ON `users`.`id` = `articles`.`user_id` WHERE `users`.`name` = 'Tom'
Add this to your application's shard.yml
:
dependencies:
sql:
github: f-mer/sql