[#303658] Remove Parts of a String — Dan __ <major_general_joe@...>

Alright, this is probably a really simple question to answer, but I just

15 messages 2008/06/01

[#303876] deleting first line from a file — suresh <suresh.amritapuri@...>

Hi

16 messages 2008/06/03

[#303934] Module philosophy — "Leslie Viljoen" <leslieviljoen@...>

Sorry to beat a dead horse, but to confirm: the only way to mix a

12 messages 2008/06/04

[#303941] A complete guide for Ruby Progammers — Mc Mohd <mcmohd@...>

This tutorial gives you complete knowledge starting from basic to

23 messages 2008/06/04
[#303943] Re: A complete guide for Ruby Progammers — Davi Vidal <davividal@...> 2008/06/04

Em Wednesday 04 June 2008, Mc Mohd escreveu:

[#303945] Re: A complete guide for Ruby Progammers — Mc Mohd <mcmohd@...> 2008/06/04

Sorry pal missed to send URL. Its here:

[#303947] Re: A complete guide for Ruby Progammers — "Oscar Del Ben" <thehcdreamer@...> 2008/06/04

Thanks for your work ;)

[#303948] Re: A complete guide for Ruby Progammers — "Leslie Viljoen" <leslieviljoen@...> 2008/06/04

This tutorial looks strangely familiar!

[#303957] A crosspost from the Perl Community — Star Cross <starx@...>

All,

55 messages 2008/06/04
[#303983] Re: A crosspost from the Perl Community — David Masover <ninja@...> 2008/06/04

On Wednesday 04 June 2008 12:20:37 Star Cross wrote:

[#304212] Re: A crosspost from the Perl Community — Jenda Krynicky <jenda@...> 2008/06/06

David Masover wrote:

[#304303] Re: A crosspost from the Perl Community — David Masover <ninja@...> 2008/06/07

On Friday 06 June 2008 12:02:19 Jenda Krynicky wrote:

[#305043] Re: A crosspost from the Perl Community — Jenda Krynicky <jenda@...> 2008/06/13

David Masover wrote:

[#304075] Re: A crosspost from the Perl Community — Dave Bass <davebass@...> 2008/06/05

Coming to Ruby recently from Perl, these are my comments.

[#304084] Re: A crosspost from the Perl Community — "Eric Mahurin" <eric.mahurin@...> 2008/06/05

On Thu, Jun 5, 2008 at 10:00 AM, Dave Bass <davebass@musician.org> wrote:

[#304175] Re: A crosspost from the Perl Community — Dave Bass <davebass@...> 2008/06/06

Eric Mahurin wrote:

[#304217] Preferable Pairs (#165) — "Matthew Moss" <matthew.moss@...>

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

17 messages 2008/06/06

[#304230] Desktop multi-plataform ruby app — "Israel Guerra" <israel.guerra@...>

Hail everyone!

60 messages 2008/06/06
[#304237] Re: Desktop multi-plataform ruby app — Charles Oliver Nutter <charles.nutter@...> 2008/06/06

Israel Guerra wrote:

[#304241] Re: Desktop multi-plataform ruby app — James Britt <james.britt@...> 2008/06/06

Charles Oliver Nutter wrote:

[#304242] Re: Desktop multi-plataform ruby app — "Israel Guerra" <israel.guerra@...> 2008/06/06

But guys, maybe im wrong about jruby, but its a ruby interpreter running in

[#304271] Re: Desktop multi-plataform ruby app — "Victor Reyes" <victor.reyes@...> 2008/06/07

On Fri, Jun 6, 2008 at 4:15 PM, Charles Oliver Nutter <

[#304240] Re: Desktop multi-plataform ruby app — James Britt <james.britt@...> 2008/06/06

Israel Guerra wrote:

[#304309] Re: Desktop multi-plataform ruby app — Tom Cloyd <tomcloyd@...> 2008/06/07

James Britt wrote:

[#304284] using portions of other methods in a new method — Jason Lillywhite <jason.lillywhite@...>

How do you take a piece of a method and use it in another? Here is my

10 messages 2008/06/07

[#304353] Ruby wishlist — jzakiya <jzakiya@...>

You can do this:

23 messages 2008/06/08

[#304443] my first program just shuttin' down — Ruby Noob <john_@...>

Why? I tryin' to open the "hello.rb" program, but it just shuttin' down

12 messages 2008/06/08

[#304541] Ruby vs JRuby Performance — "Victor Reyes" <victor.reyes@...>

I knew that there was a penalty to be paid when running JRuby, but I did not

20 messages 2008/06/09

[#304623] Random Number Stuff — David Stanislaus <stanislaus_d@...>

How would you create a random number generator thats limited to a

17 messages 2008/06/10

[#304640] accessing class variables from the outside (beginner question) — progcat@...

I am still learning Ruby and I am trying to get something

12 messages 2008/06/10

[#304662] webby, ubuntu and gems — "Martin DeMello" <martindemello@...>

I've recently switched distributions to ubuntu, and I'm having

15 messages 2008/06/10

[#304728] Basic Tree Data Structure — Justin To <tekmc@...>

class Tree

14 messages 2008/06/10
[#304738] Re: Basic Tree Data Structure — Justin To <tekmc@...> 2008/06/10

class Tree

[#304790] Trie data structure — Justin To <tekmc@...>

I'm trying to implement a trie data structure for my parsing program

17 messages 2008/06/10
[#304826] Re: Trie data structure — Dave Bass <davebass@...> 2008/06/11

Justin To wrote:

[#304825] each with else — Thorsten Mler <thorsten@80beans.com>

Hi all,

11 messages 2008/06/11

[#304875] write byte array to file — "Rajesh Olafson" <rolafson@...>

Helo

16 messages 2008/06/11

[#304960] Help with Ruby under cygwin — James Byrne <byrnejb@...>

In order to use git on my laptop (MS XPproSP3) I ended up installing the

23 messages 2008/06/12

[#304992] a simple patch for the ri utility — Daniel Choi <dhchoi@...>

Hi everyone

15 messages 2008/06/12

[#305021] array to string conversion — Clement Ow <clement.ow@...>

Hi, I have 2 arrays(which is part of the hash):

13 messages 2008/06/13

[#305058] Circle Drawing (#166) — "Matthew Moss" <matthew.moss@...>

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

19 messages 2008/06/13

[#305100] Documenting Networking in Ruby. Any volunteer — "Victor Reyes" <victor.reyes@...>

Team,

10 messages 2008/06/13

[#305104] raise and rescue — Misiek Sz <nicpon@...>

Is is possible to raise an exception then rescue it and then go back to

13 messages 2008/06/13

[#305160] What was YOUR first Ruby Project — Eric Hegwer <ehegwer@...>

I though it be cool to hear what your first experience with Ruby was.

26 messages 2008/06/14

[#305227] why can't an instance instantiated within a class method access a protected instance method? — "Greg Hauptmann" <greg.hauptmann.ruby@...>

Hi,

10 messages 2008/06/15
[#305228] Re: why can't an instance instantiated within a class method access a protected instance method? — "Greg Hauptmann" <greg.hauptmann.ruby@...> 2008/06/15

(complete email)Hi,

[#305230] How !isset in Ruby — Alexey Tafintsev <alexey@...>

Hello people!

21 messages 2008/06/15
[#305238] Re: How !isset in Ruby — Martin Boese <boesemar@...> 2008/06/15

[#305241] Re: How !isset in Ruby — Robert Klemme <shortcutter@...> 2008/06/15

On 15.06.2008 14:37, Martin Boese wrote:

[#305268] little problem (google hiring puzzle) — ex <exeQtor@...>

Hi guys, I wonder if someone can find a pure ruby solution instead of

43 messages 2008/06/15

[#305334] How to Authenticate against the Windows NT Domain via Ruby — ChessMess <chessmess@...>

We are running a Rails application on Linux RedHat with a requirement

12 messages 2008/06/16

[#305377] print(true and true) #=> the parenthesis issue — hakunin <madfancier@...>

The parenthesis have been discussed before, but maybe this is another

31 messages 2008/06/17

[#305398] Can I find out the memory used by an object? — "Robert Hulme" <robert.hulme@...>

I'm 99% sure the answer to that question is no, but I thought I'd ask anyway :-)

15 messages 2008/06/17

[#305446] parsing text into usablle numerical data — Cthulhu __ <weedmasterp@...>

Hey total ruby n00b here...

13 messages 2008/06/17

[#305467] quick question about how array objects are handled — Chance Dinkins <chanceusc@...>

Btw, thanks in advance for any help - this community seems great!

11 messages 2008/06/17

[#305557] Rather validate values or use exceptions? — Joshua Muheim <forum@...>

Hi all

12 messages 2008/06/18

[#305605] Presentation on Ruby, require suggestions — "Srijayanth Sridhar" <srijayanth@...>

Hello,

14 messages 2008/06/19

[#305635] Why metaclasses? — "James Coglan" <jcoglan@...>

Hello all,

15 messages 2008/06/19

[#305727] Ruby 1.9.0/1.8.7/1.8.6/1.8.5 new releases (Security Fix) — Urabe Shyouhei <shyouhei@...>

Hi all.

91 messages 2008/06/20
[#305893] Re: Ruby 1.9.0/1.8.7/1.8.6/1.8.5 new releases (Security Fix) — Igal Koshevoy <igal@...> 2008/06/23

All versions of MRI Ruby that claim to fix the vulnerabilities are

[#305934] Re: Ruby 1.9.0/1.8.7/1.8.6/1.8.5 new releases (Security Fix) — Hongli Lai <hongli@...> 2008/06/23

Hi guys. Igal invited me to join this discussion.

[#305936] Re: Ruby 1.9.0/1.8.7/1.8.6/1.8.5 new releases (Security Fix) — Igal Koshevoy <igal@...> 2008/06/23

Hongli Lai wrote:

[#305943] Re: Ruby 1.9.0/1.8.7/1.8.6/1.8.5 new releases (Security Fix) — Hongli Lai <hongli@...> 2008/06/23

Igal Koshevoy wrote:

[#305956] Re: Ruby 1.9.0/1.8.7/1.8.6/1.8.5 new releases (Security Fix) — Igal Koshevoy <igal@...> 2008/06/23

Hongli Lai wrote:

[#306045] Re: Ruby 1.9.0/1.8.7/1.8.6/1.8.5 new releases (Security Fix) — Igal Koshevoy <igal@...> 2008/06/24

We have another potential winning solution!

[#306072] Re: Ruby 1.9.0/1.8.7/1.8.6/1.8.5 new releases (Security Fix) — Robert Thau <rst@...> 2008/06/24

Igal Koshevoy wrote:

[#306135] Re: Ruby 1.9.0/1.8.7/1.8.6/1.8.5 new releases (Security Fix) — Igal Koshevoy <igal@...> 2008/06/24

Robert Thau wrote:

[#306137] Re: Ruby 1.9.0/1.8.7/1.8.6/1.8.5 new releases (Security Fix) — "Dominic Sisneros" <dsisnero@...> 2008/06/25

Maybe you should try posting a issue on the new redmine bug tracker

[#306139] Re: Ruby 1.9.0/1.8.7/1.8.6/1.8.5 new releases (Security Fix) — Igal Koshevoy <igal@...> 2008/06/25

Dominic Sisneros wrote:

[#306214] Re: Ruby 1.9.0/1.8.7/1.8.6/1.8.5 new releases (Security Fix) — Jason Crystal <jcrystal@...> 2008/06/25

Just wanted to say that we all appreciate those fixes you guys have been

[#306516] Re: Ruby 1.9.0/1.8.7/1.8.6/1.8.5 new releases (Security Fix) — Cheri Anaclerio <canaclerio@...> 2008/06/29

Could somebody please explain how to apply the Smartleaf Stanislav and

[#307002] Re: Ruby 1.9.0/1.8.7/1.8.6/1.8.5 new releases (Security Fix) — Doug Alcorn <dougalcorn@...> 2008/07/02

Igal Koshevoy wrote:

[#305751] Regular expressions and long text — Guillermo.Acilu@...

Hello guys,

15 messages 2008/06/20

[#305810] Where does ruby excel? — Dolazy <francis.rammeloo@...>

I have only used ruby for writing little scripts. Things that are

14 messages 2008/06/21

[#305844] Initial release of amalgalite - v0.1.0 — Jeremy Hinegardner <jeremy@...>

Amalgalite embeds the SQLite database engine in a ruby extension.

13 messages 2008/06/21

[#305854] KABLAME! 0.2.1 Released — "Jacob Dunphy" <jacob.dunphy@...>

This is the first "announced release" of KABLAME!

13 messages 2008/06/22

[#305855] RubyGems 1.2.0 — Eric Hodel <drbrain@...7.net>

= Announce: RubyGems Release 1.2.0

49 messages 2008/06/22

[#305882] Is it ellegant to use a global variable to store a Logger object? — Iñaki Baz Castillo <ibc@...>

Hi, I use Logger class in a programm and since I need to log in lot of=20

49 messages 2008/06/22
[#305884] Re: Is it ellegant to use a global variable to store a Logger object? — Suraj Kurapati <snk@...> 2008/06/22

I単aki Baz Castillo wrote:

[#305885] Re: Is it ellegant to use a global variable to store a Logger object? — Iñaki Baz Castillo <ibc@...> 2008/06/22

El Lunes, 23 de Junio de 2008, Suraj Kurapati escribi=C3=B3:

[#305886] Re: Is it ellegant to use a global variable to store a Logger object? — Suraj Kurapati <snk@...> 2008/06/23

I単aki Baz Castillo wrote:

[#305888] Re: Is it ellegant to use a global variable to store a Logger object? — Iñaki Baz Castillo <ibc@...> 2008/06/23

El Lunes, 23 de Junio de 2008, Suraj Kurapati escribi=C3=B3:

[#306058] Re: Is it ellegant to use a global variable to store a Logger object? — Andrea Fazzi <andrea.fazzi@...> 2008/06/24

I単aki Baz Castillo ha scritto:

[#306066] Re: Is it ellegant to use a global variable to store a Logger object? — Iñaki Baz Castillo <ibc@...> 2008/06/24

El Martes, 24 de Junio de 2008, Andrea Fazzi escribi=C3=B3:

[#306161] Re: Is it ellegant to use a global variable to store a Logger object? — "Robert Klemme" <shortcutter@...> 2008/06/25

2008/6/24 I=F1aki Baz Castillo <ibc@aliax.net>:

[#306168] Re: Is it ellegant to use a global variable to store a Logger object? — "Robert Dober" <robert.dober@...> 2008/06/25

On Wed, Jun 25, 2008 at 11:22 AM, Robert Klemme

[#306176] Re: Is it ellegant to use a global variable to store a Logger object? — Andrea Fazzi <andrea.fazzi@...> 2008/06/25

Robert Dober ha scritto:

[#306180] Re: Is it ellegant to use a global variable to store a Logger object? — "Robert Dober" <robert.dober@...> 2008/06/25

On Wed, Jun 25, 2008 at 3:36 PM, Andrea Fazzi <andrea.fazzi@alca.le.it> wro=

[#306288] Re: Is it ellegant to use a global variable to store a Logger object? — "Shot (Piotr Szotkowski)" <shot@...> 2008/06/26

I=C3=B1aki Baz Castillo:

[#306351] Re: Is it ellegant to use a global variable to store a Logger object? — Iñaki Baz Castillo <ibc@...> 2008/06/26

El Jueves, 26 de Junio de 2008, Shot (Piotr Szotkowski) escribi=C3=B3:

[#306387] Re: Is it ellegant to use a global variable to store a Logger object? — "Shot (Piotr Szotkowski)" <shot@...> 2008/06/27

I=C3=B1aki Baz Castillo:

[#306416] Re: Is it ellegant to use a global variable to store a Logger object? — Iñaki Baz Castillo <ibc@...> 2008/06/27

El Viernes, 27 de Junio de 2008, Shot (Piotr Szotkowski) escribi=C3=B3:

[#306499] Re: Is it ellegant to use a global variable to store a Logger object? — "Shot (Piotr Szotkowski)" <shot@...> 2008/06/28

I=C3=B1aki Baz Castillo:

[#306501] Re: Is it ellegant to use a global variable to store a Logger object? — "ara.t.howard" <ara.t.howard@...> 2008/06/28

[#306085] Sequel primary keys — "Glen Holcomb" <damnbigman@...>

I posted to the Sequel Google Group but it's horribly slow, assuming it took

16 messages 2008/06/24

[#306088] Performance improvement possible? — Philip Rhoades <phil@...>

People,

35 messages 2008/06/24
[#306095] Re: Performance improvement possible? — Rob Biedenharn <Rob@...> 2008/06/24

On Jun 24, 2008, at 12:23 PM, Philip Rhoades wrote:

[#306225] Re: Performance improvement possible? — Philip Rhoades <phil@...> 2008/06/25

Rob,

[#306237] Re: Performance improvement possible? — Chuck Remes <cremes.devlist@...> 2008/06/26

[#306243] Re: Performance improvement possible? — Philip Rhoades <phil@...> 2008/06/26

Chuck,

[#306255] Re: Performance improvement possible? — Rob Biedenharn <Rob@...> 2008/06/26

On Jun 25, 2008, at 8:44 PM, Philip Rhoades wrote:

[#306333] Re: Performance improvement possible? — Eleanor McHugh <eleanor@...> 2008/06/26

On 26 Jun 2008, at 04:24, Rob Biedenharn wrote:

[#306345] Re: Performance improvement possible? — Philip Rhoades <phil@...> 2008/06/26

Eleanor,

[#306350] Re: Performance improvement possible? — Eleanor McHugh <eleanor@...> 2008/06/26

On 26 Jun 2008, at 20:47, Philip Rhoades wrote:

[#306357] Re: Performance improvement possible? — Philip Rhoades <phil@...> 2008/06/26

Ellie,

[#306368] Re: Performance improvement possible? — Eleanor McHugh <eleanor@...> 2008/06/27

On 26 Jun 2008, at 22:51, Philip Rhoades wrote:

[#306234] A cleaner way to pass a block or proc — "Tristin Davis" <tristin.colby@...>

Is there a cleaner way to implement my add_notifier method?

15 messages 2008/06/25
[#306236] Re: A cleaner way to pass a block or proc — Ben Bleything <ben@...> 2008/06/26

On Thu, Jun 26, 2008, Tristin Davis wrote:

[#306245] Re: A cleaner way to pass a block or proc — "Tristin Davis" <tristin.colby@...> 2008/06/26

Thanks Ben. That worked perfect. No other changes required in the class. :)

[#306331] question about defined? and y — Ruby Freak <twscannell@...>

The defined? keyword seems to have some funky behaviors.

19 messages 2008/06/26

[#306420] Statistician I (#167) — "Matthew Moss" <matthew.moss@...>

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

13 messages 2008/06/27

[#306448] changing the shebang of ruby files best way ? — unbewusst.sein@... (Une B騅ue)

I've a lot of ruby files (grabed from net) having a wrong shebang for my

18 messages 2008/06/27
[#306505] Re: changing the shebang of ruby files best way ? — Ryan Davis <ryand-ruby@...> 2008/06/28

[#306524] Random Generation of Characters — Tj Superfly <nonstickglue@...>

How could you generate a list of all possible combination's of lowercase

12 messages 2008/06/29

[#306533] mysterious memory corruption, very confused — Seebs <usenet-nospam@...>

ruby 1.8.7-p22, OS X 10.4.mumble, PostgreSQL 8.3.1, ruby-pg 2008-03-18.

11 messages 2008/06/29

[#306547] Recursive Logic - Examples and Resources? — Dan __ <major_general_joe@...>

Hey all,

13 messages 2008/06/29

[#306620] Threads and Ruby — barjunk <barjunk@...>

I've been hunting around for information regarding threads, and to me,

35 messages 2008/06/30
[#306621] Re: Threads and Ruby — "ara.t.howard" <ara.t.howard@...> 2008/06/30

[#306701] nested methods good or bad design — John Maclean <jayeola@...>

=begin

15 messages 2008/06/30

[#306728] how to - quickly make permutations? — Max Williams <toastkid.williams@...>

can anyone provide an elegant implementation for this method?

18 messages 2008/06/30
[#306761] Re: how to - quickly make permutations? — Frederick Cheung <frederick.cheung@...> 2008/06/30

[#306778] Re: how to - quickly make permutations? — "jim finucane" <jimrails@...> 2008/07/01

each new element tries to double the size of the list

ANN: Sequel 2.0.0 Released

From: Jeremy Evans <code@...>
Date: 2008-06-01 22:27:33 UTC
List: ruby-talk #303681
Sequel is a lightweight database access toolkit for Ruby.

* Sequel provides thread safety, connection pooling and a concise DSL
  for constructing database queries and table schemas.
* Sequel also includes a lightweight but comprehensive ORM layer for
  mapping records to Ruby objects and handling associated records.
* Sequel makes it easy to deal with multiple records without having
  to break your teeth on SQL.
* Sequel currently has adapters for ADO, DB2, DBI, Informix, JDBC,
  MySQL, ODBC, OpenBase, Oracle, PostgreSQL and SQLite3.

Sequel 2.0.0 has been released and should be available on the gem
mirrors.  2.0.0 has the following exciting new features:

Blockless Filter Expressions
----------------------------

Before 2.0.0, in order to specify complex SQL expressions, you
either had to resort to writing the SQL yourself in a string or
using an expression inside a block that was parsed by ParseTree.
Because ParseTree was required, only ruby 1.8.* was supported, and
supporting other ruby versions (ruby 1.9, JRuby, Rubinius) would
never be possible.

With 2.0.0, you no longer need to use a block to write complex SQL
expressions. The basics of the blockless filters are the usual
arithmetic, inequality, and binary operators:

  + = addition
  - = subtraction
  * = multiplication
  / = division
  > = greater than
  < = less than
  >= = greater than or equal to
  <= = less than or equal to
  ~ = negation
  & = AND
  | = OR

You can use these operators on Symbols, LiteralStrings, and other
Sequel::SQL::Expressions.  Note that there is no equal operator or
not equal operator, to specify those, you use a Hash.

Here are some examples:

  # Ruby code => SQL WHERE clause
  :active => active
  ~:active => NOT active
  ~~:active => active
  ~~~:active => NOT active
  :is_true[] => is_true()
  ~:is_true[] => NOT is_true()
  :x > 100 => (x > 100)
  :x < 100.01 => (x < 100.01)
  :x <= 0 => (x <= 0)
  :x >= 1 => (x >= 1)
  ~(:x > 100) => (x <= 100)
  {:x => 100} => (x = 100)
  {:x => 'a'} => (x = 'a')
  {:x => nil} => (x IS NULL)
  ~{:x => 100} => (x != 100)
  ~{:x => 'a'} => (x != 'a')
  ~{:x => nil} => (x IS NOT NULL)
  {:x => /a/} => (x ~ 'blah') # Default, MySQL different
  ~{:x => /a/} => (x !~ 'blah') # Default, MySQL different
  :x.like('a') =>  (x LIKE 'a')
  ~:x.like('a') =>  (x NOT LIKE 'a')
  :x.like(/a/) => (x ~ 'a') # Default, MySQL different
  ~:x.like('a', /b/) => ((x NOT LIKE 'a') AND (x !~ 'b')) # Default
  ~{:x => 1..5} => ((x < 1) OR (x > 5))
  ~{:x => DB[:items].select(:i)} => (x NOT IN (SELECT i FROM items))
  ~{:x => [1,2,3]} => (x NOT IN (1, 2, 3))
  :x + 1 > 100 => ((x + 1) > 100)
  (:x * :y) < 100.01 => ((x * y) < 100.01)
  (:x - :y/2) >= 100 => ((x - (y / 2)) >= 100)
  (((:x - :y)/(:x + :y))*:z) <= 100 => ((((x - y) / (x + y)) * z) <=
100)
  ~((((:x - :y)/(:x + :y))*:z) <= 100) => ((((x - y) / (x + y)) * z) >
100)
  :x & :y => (x AND y)
  :x & :y & :z => ((x AND y) AND z)
  :x & {:y => :z} => (x AND (y = z))
  {:y => :z} & :x => ((y = z) AND x)
  {:x => :a} & {:y => :z} => ((x = a) AND (y = z))
  (:x > 200) & (:y < 200) => ((x > 200) AND (y < 200))
  :x | :y => (x OR y)
  :x | :y | :z => ((x OR y) OR z)
  :x | {:y => :z} => (x OR (y = z))
  {:y => :z} | :x => ((y = z) OR x)
  {:x => :a} | {:y => :z} => ((x = a) OR (y = z))
  (:x > 200) | (:y < 200) => ((x > 200) OR (y < 200))
  (:x | :y) & :z => ((x OR y) AND z)
  :x | (:y & :z) => (x OR (y AND z))
  (:x & :w) | (:y & :z) => ((x AND w) OR (y AND z))
  ~((:x | :y) & :z) => ((NOT x AND NOT y) OR NOT z)
  ~((:x & :w) | (:y & :z)) => ((NOT x OR NOT w) AND (NOT y OR NOT z))
  ~((:x > 200) | (:y & :z)) => ((x <= 200) AND (NOT y OR NOT z))
  ~('x'.lit + 1 > 100) => ((x + 1) <= 100)
  'x'.lit.like(/a/) => (x ~ 'a') # (x ~ \'a\')

None of these require blocks, you can use any directly in a call to
filter:

  DB[:items].filter((:price * :tax) - :discount > 100)
  # => SELECT * FROM items WHERE (((price * tax) - discount) > 100)
  DB[:items].filter(:active & ~:archived)
  # => SELECT * FROM items WHERE (active AND NOT archived)

SQL String Concatenation
------------------------

Sequel now has support for expressing SQL string concatenation in an
easy way:

  [:name, :title].sql_string_join(" - ")
  # SQL:  name || ' - ' || title

You can use this in selecting columns, creating filters, ordering
datasets, and possibly elsewhere.

Schema Reflection Support/Typecasting on Assignment
---------------------------------------------------

When used with PostgreSQL, MySQL, or SQLite, Sequel now has the
ability to get information from the database's schema in regards
to column types:

  DB.schema(:artist)
  => [[:id, {:type=>:integer, :db_type=>"integer", :max_chars=>0
     :numeric_precision=>32, :allow_null=>false,
     :default=>"nextval('artist_id_seq'::regclass)"}], [:name,
     {:type=>:string, :default=>nil, :db_type=>"text",
     :numeric_precision=>0, :allow_null=>true, :max_chars=>0}]]

Models now use this information to typecast values on attribute
assignment. For example, if you have an integer column named number
and a text (e.g. varchar) column named title:

  1.5.1:
    model.number = '1'
    model.number # => '1'
    model.title = 1
    model.title # => 1
  2.0.0:
    model.number = '1'
    model.number # => 1
    model.title = 1
    model.title # => '1'

Typecasting can be turned off on a global, per class, and per object
basis:

  Sequel::Model.typecast_on_assignment = false # Global
  Album.typecast_on_assignment = false # Per Class
  Album.new.typecast_on_assignment = false # Per Object

Typecasting is somewhat strict, it does not allow obviously bogus
data to be used:

  model.number = 'a' # Raises error

This is in contrast to how some other ORMs handle the situation:

  model.number = 'a'
  model.number # => 0

If Sequel is being used with a web framework and you want to display
friendly error messages to the user, you should probably turn
typecasting off and set up the necessary validations in your models.

Model Association Improvements
------------------------------

Associations can now be eagerly loaded even if they have a block,
though the block should not rely on being evaluated in the context
of an instance. This allows you filter on associations when eagerly
loading:

  Artist.one_to_many :albums_with_10_tracks, :class=>:Album do |ds|
    ds.filter(:num_tracks => 10)
  end
  Artist.filter(:name.like('A%)).eager(:albums_with_10_tracks).all
  # SELECT * FROM artists WHERE (name LIKE 'A%')
  # SELECT albums.* FROM albums WHERE ((artist_id IN (...)) AND
  #   (num_tracks = 10))

Associations now have a remove_all_ method for removing all
associated objects in a single query:

  Artist.many_to_many :albums
  Artist[1].remove_all_albums
  # DELETE FROM albums_artists WHERE artist_id = 1

  Artist.one_to_many :albums
  Artist[1].remove_all_albums
  # UPDATE albums SET artist_id = NULL WHERE artist_id = 1

All associations can specify a :select option to change which columns
are selected.  Previously only many to many associations suppported
this.

The SQL used when eagerly loading through eager_graph can be
modified via the :graph_join_type, :graph_conditions, and
:graph_join_conditions options.

:graph_join_type changes the join type from the default of
:left_outer.  This can be useful if you do not want any
albums that don't have an artist in the result set:

  Album.many_to_one :artist, :graph_join_type=>:inner
  Album.eager_graph(:artist).sql
  # SELECT ... FROM albums INNER JOIN artists ...

:graph_conditions adds conditions on the join to the table you are
joining, the eager_graph equivalent of an association block argument
in eager. It takes either a hash or an array where all elements
are arrays of length two, similar to join_table, where key symbols
specify columns in the joined table and value symbols specify
columns in the last joined or primary table:

  Album.many_to_one :artist, :graph_conditions=>{:active=>true}
  Album.eager_graph(:artist).sql
  # SELECT ... FROM albums LEFT OUTER JOIN artists ON ((artists.id =
  #   albums.artist_id) AND (artists.active = 't'))

:graph_join_table_conditions exists for many to many associations only,
and operates the same as :graph_conditions, except it specifies a
condition on the many to many join table instead of the associated
model's table. This is necessary if the join table is also model
table with other columns on which you may want to filter:

  Album.many_to_many :genres, :join_table=>:ag, \
    :graph_join_table_conditions=>{:active=>true}
  Album.eager_graph(:genres).sql
  # SELECT ... FROM albums LEFT OUTER JOIN ag ON ((ag.album_id =
      albums.id) AND (ag.active = 't')) LEFT OUTER JOIN genres ON
      (genres.id = ag.genre_id)

Other Small Improvements
------------------------

* Dataset#invert returns a dataset that matches all records not
  matching the current filter.
* Dataset#unfiltered returns a dataset that has any filters removed.
* Dataset#last_page? and Dataset#first_page? for paginated datasets.
* The sequel command line tool now support an -E or --echo argument
  that logs all SQL to the standard output.  It also can take a path
  to a yaml file with database connection options, in addition to a
  database URL.
* Databases can now have multiple SQL loggers, so you can log to the
  standard output as well as a file.
* SQL identifiers (columns and tables) are now quoted by default (you
  can turn this off via Sequel.quote_identifiers = false if need be).
* Sequel.connect now takes an optional block that will disconnect the
  database when the block finishes.
* AlterTableGenerator now has add_primary_key and add_foreign_key
  methods.
* Running the specs without ParseTree installed skips the specs that
  require ParseTree.
* You can use an array of arrays instead of a hash when specifying
  conditions, which may be necessary in certain situations where
  you would be using the same hash key more than once.
* Almost all documentation for Sequel was updated for 2.0.0, so if you
  found Sequel documentation lacking before, check out the new RDoc
  pages.
* There have been many minor refactoring improvements, the code
  should now be easier to read and follow.
* Sequel now has no external dependencies.
* Sequel::Models now have before_validation and after_validation
  hooks.
* Sequel::Model hooks that return false cause the methods that call
  them (such as save) to return false.
* Sequel::Models can now load their schema on first instantiation,
  instead of when they are created, via
  Sequel::Model.lazy_load_schema=.  This is helpful for certain
  web frameworks that reload all models on every request.
* Hook methods that use blocks can now include an optional tag,
  which allows them to work well with web frameworks that load source
  files every time they are modified.

The PostgreSQL adapter has been rewritten and now supports ruby-pg.
There have also been improvements in the following adapters: DBI,
MySQL, SQLite, Oracle, and MSSQL.

All of the methods that have been deprecated in 1.5.0 have now been
removed.  If you are want to upgrade to Sequel 2.0.0 from version 1.4.0
or previous, upgrade to 1.5.1 first, fix all of the deprecation
warnings that show up, and then upgrade to 2.0.0.

There were some backwards incompatible changes made in 2.0.0 beyond the
removal of deprecated methods.  These are:

* Inflector is no longer used, the inflection methods were moved
  directly into String (where they belong because inflections only
  make sense for strings).  So to override singularization
  or pluralization rules, use String.inflections instead of
  Inflector.inflections.
* MySQL tinyints are now returned as boolean values instead of
  integers.  MySQL doesn't have a boolean type, and usually it
  is recommended to use tinyint for a boolean column.
* You can no longer pass an array to Dataset#order or Dataset#select,
  you need to pass each argument separately (the * operator is your
  friend).
* You must use '?' instead of '(?)' when interpolating an array
  argument into a string (e.g. filter('x IN ?', [1,2,3]))
* You must pass an explicit table alias argument to join_table and
  related methods, you can no longer include the table alias
  inside the table argument.
* sqlite:// URLs now operate the same as file:// URLs (2 slashes
  for a relative path, 3 for an absolute path).

If you have any questions, please post on the Google Group.

Thanks,
Jeremy

* {Source code}[http://github.com/jeremyevans/sequel]
* {Bug tracking}[http://code.google.com/p/ruby-sequel/issues/list]
* {Google group}[http://groups.google.com/group/sequel-talk]
* {RDoc}[http://sequel.rubyforge.org]
-- 
Posted via http://www.ruby-forum.com/.

In This Thread

Prev Next