Correctly Style of SQL Formatting in Ruby Cude


#1

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 F.
AOL Instant Messenger: rilindo
Google Talk: removed_email_address@domain.invalid
Web S.: http://www.monzell.com
Primary: removed_email_address@domain.invalid
Secondary: removed_email_address@domain.invalid
"Rich bachelors should be heavily taxed. It is not fair that some men
should be happier than others. – Oscar Wilde


#2

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…


#3

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”. :expressionless:

On Wed, May 20, 2009 at 2:55 PM, Phlip removed_email_address@domain.invalid 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 F.
AOL Instant Messenger: rilindo
Google Talk: removed_email_address@domain.invalid
Web S.: http://www.monzell.com
Primary: removed_email_address@domain.invalid
Secondary: removed_email_address@domain.invalid
"Rich bachelors should be heavily taxed. It is not fair that some men
should be happier than others. – Oscar Wilde