A SQL and Arel Editor

An error occurred.

Join Tables

Scuttle doesn't know anything about your Rails models, so it can't correctly identify join tables (i.e. tables that have no corresponding Ruby class). You'll need to replace these by hand. Usually this can be resolved by creating an Arel::Table object and referencing its columns. For example, create a table: pc ="posts_comments"), then use it like so: pc[:post_id].

Qualified Columns

Scuttle doesn't always know which table a referenced column belongs to. This isn't usually a problem, except when that column is the left-hand side of an expression. If you see something like where(:id.eq(1)) in the conversion result, chances are you didn't fully qualify the column with a table. Try WHERE = 1 instead of WHERE id = 1.

Why Does Scuttle Exist?

I gave a talk at RailsConf in 2014 about constructing advanced queries with Arel. This project is a direct result of working on the talk. Plus it was fun :)

Double Quotes

The SQL parser Scuttle uses does not allow double quotes around column or table names, and it even prefers literal strings to be wrapped in single quotes. This could pose a problem if you're trying to convert a PostgresSQL query, since all column and table names use double quotes.

Why Can't Scuttle Interpret my Query?

It's pretty difficult to anticipate every kind of query, but Scuttle should be able to handle nearly all of the queries you might find in a Rails log. Currently, Scuttle only supports SELECT queries, but more types are coming soon. If you'd like to request a feature or submit a bug report, let me know on Github.

Why is the Project Called Scuttle?

Initially I wanted to call it "Ariel" (i.e. from The Little Mermaid), but that's too linguistically similar to "Arel". Instead I chose to name it after the seagull in that movie, one of Ariel's best friends.