Scuttle can more accurately identify joins in your SQL statements if it knows about the associations between your application's models.
Exports an archive from Github and automatically extracts and imports associations from
Depending on the size of the repo, this process could take a while.
Please login in with your github account.
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 = Arel::Table.new("posts_comments"), then use it like so:
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 post.id = 1 instead of
WHERE id = 1.
I'll be giving a talk at RailsConf this year about constructing advanced queries with Arel. This project is a direct result of working on the talk. Plus it's fun :)
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.
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.
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.