Forum: Ruby Correctly Style of SQL Formatting in Ruby Cude

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
40ba541bc54ef6e3c9e6d9e101e19e26?d=identicon&s=25 rilindo foster (Guest)
on 2009-05-20 20:08
(Received via mailing list)
Is there a correct style of putting in SQL statements in Ruby? My SQL
statements tend to go around 200-400 columns, which looks *very* ugly.
--
Rilindo Foster
AOL Instant Messenger: rilindo
Google Talk: rilindo@gmail.com
Web Site: http://www.monzell.com
Primary: rilindo@me.com
Secondary: rilindo@gmail.com
"Rich bachelors should be heavily taxed. It is not fair that some men
should be happier than others. -- Oscar Wilde
Aafa8848c4b764f080b1b31a51eab73d?d=identicon&s=25 Phlip (Guest)
on 2009-05-20 20:56
(Received via mailing list)
rilindo foster wrote:
> Is there a correct style of putting in SQL statements in Ruby? My SQL
> statements tend to go around 200-400 columns, which looks *very* ugly.

A> use ActiveRecord, or one of the other SQL generators

B> this:

     SELECT FROM users
      WHERE is_premier = 1
        AND charge_at > NOW()

Notice that all SQL keywords are in UPCASE, just for emphasis, and
there's a
vertical gutter in the 6th relative column. The SQL books advocate that
gutter,
I think.

Also, if you have 200-400 column strings, you need to get more DRY. That
leads
back to ActiveRecord...
40ba541bc54ef6e3c9e6d9e101e19e26?d=identicon&s=25 rilindo foster (Guest)
on 2009-05-21 20:15
(Received via mailing list)
Active Record looks interest. I'll need to look into that. Thanks!

In other news, this question made it to the top of Google's search
results. . . and I just noticed that I mis-spelled "code". :|

On Wed, May 20, 2009 at 2:55 PM, Phlip <phlip2005@gmail.com> wrote:
>     WHERE is_premier = 1
>       AND charge_at > NOW()
>
> Notice that all SQL keywords are in UPCASE, just for emphasis, and there's a
> vertical gutter in the 6th relative column. The SQL books advocate that
> gutter, I think.
>
> Also, if you have 200-400 column strings, you need to get more DRY. That
> leads back to ActiveRecord...
>
>



--
Rilindo Foster
AOL Instant Messenger: rilindo
Google Talk: rilindo@gmail.com
Web Site: http://www.monzell.com
Primary: rilindo@me.com
Secondary: rilindo@gmail.com
"Rich bachelors should be heavily taxed. It is not fair that some men
should be happier than others. -- Oscar Wilde
This topic is locked and can not be replied to.