Correctly Style of SQL Formatting in Ruby Cude

R

rilindo foster

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: (e-mail address removed)
Web Site: http://www.monzell.com
Primary: (e-mail address removed)
Secondary: (e-mail address removed)
"Rich bachelors should be heavily taxed. It is not fair that some men
should be happier than others. -- Oscar Wilde
 
P

Phlip

rilindo said:
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...
 
R

rilindo foster

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". :|

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

B> this:

=A0 =A0SELECT FROM users
=A0 =A0 WHERE is_premier =3D 1
=A0 =A0 =A0 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...



--=20
Rilindo Foster
AOL Instant Messenger: rilindo
Google Talk: (e-mail address removed)
Web Site: http://www.monzell.com
Primary: (e-mail address removed)
Secondary: (e-mail address removed)
"Rich bachelors should be heavily taxed. It is not fair that some men
should be happier than others. -- Oscar Wilde
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,173
Messages
2,570,937
Members
47,481
Latest member
ElviraDoug

Latest Threads

Top