Hi, When ActiveRecord gets any field from the database does it receive the field as a string regardless of the field''s type in the db? And this is why ActiveRecord must subsequently cast the data into a Ruby type? If the answers are yes, then is it correct to say that the only way databases export data for any request is through strings? (If so, wow, primative but understandable) Thanks, Peter _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Nov 13, 2005, at 10:48 PM, Peter Michaux wrote:> When ActiveRecord gets any field from the database does it receive > the field as a string regardless of the field''s type in the db? > > And this is why ActiveRecord must subsequently cast the data into a > Ruby type? > > If the answers are yes, then is it correct to say that the only way > databases export data for any request is through strings? (If so, > wow, primative but understandable)The other way around: all data from the web (query and form parameters, cookies, headers, etc) are strings. So foo_before_type_cast gives you the "source" string whereas foo is type-cast according to the database column type. jeremy -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2 (Darwin) iD8DBQFDeEOIAQHALep9HFYRAqbvAKC3ERFDbWljsnMbEys0BcFIXjfauwCfYUzj jAZ8PessmkTbMNEtE680oiU=00+R -----END PGP SIGNATURE-----
Now I''m feeling dense. How does the database send the info to rails when rails makes a request? INT is sent differently then TEXT or DATE? Peter On 11/13/05, Jeremy Kemper <jeremy-w7CzD/W5Ocjk1uMJSBkQmQ@public.gmane.org> wrote:> > > On Nov 13, 2005, at 10:48 PM, Peter Michaux wrote: > > When ActiveRecord gets any field from the database does it receive > > the field as a string regardless of the field''s type in the db? > > > > And this is why ActiveRecord must subsequently cast the data into a > > Ruby type? > > > > If the answers are yes, then is it correct to say that the only way > > databases export data for any request is through strings? (If so, > > wow, primative but understandable) > > The other way around: all data from the web (query and form > parameters, cookies, headers, etc) are strings. So > foo_before_type_cast gives you the "source" string whereas foo is > type-cast according to the database column type. > > jeremy >_______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Nov 14, 2005, at 4:12 AM, Peter Michaux wrote:> Now I''m feeling dense. How does the database send the info to rails > when rails makes a request? INT is sent differently then TEXT or DATE?All the database drivers do it differently. Most have a binary protocol that efficiently encodes each data type. The driver speaks that protocol and spits out numbers, strings, etc. This isn''t enough, though, since we want the all the drivers to operate uniformly, so the connection adapters translate the driver''s results into a standard set of Ruby classes according to the database column types. jeremy -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2 (Darwin) iD8DBQFDeNgAAQHALep9HFYRAsl/AKCYAwr1coU4jIbeNG/6AoudIQYeywCgojDV V74JufdvmK3agYjSqaE02Bw=YgDV -----END PGP SIGNATURE-----