After some hacking, I don't think this can be solved by writing
SQLiteAdapter::quote. I did however come up with a failing test case
(fails on sqlite, passes on mysql). Still hacking away. Here's the
diff:

Index: base_test.rb
===================================================================
--- base_test.rb        (revision 3321)
+++ base_test.rb        (working copy)
@@ -921,8 +921,14 @@

   def test_quote
     author_name = "\\ \001 ' \n \\n \""
-    topic = Topic.create('author_name' => author_name)
+    topic = Topic.create('author_name' => author_name, 'approved' => false)
     assert_equal author_name, Topic.find(topic.id).author_name
+
+    # Simulates true field from checkbox, needs to be quoted
+    params = {"topic"=>{"approved"=>"1"}}
+
+    Topic.update_all ["approved = ?",params["topic"]["approved"]],
"id = #{topic.id}"
+    assert !Topic.find(:first, :conditions => ['id = ? and approved =
?', topic.id, true]).nil?
   end

   def test_class_level_destroy


On 12/21/05, Kevin Clark <[EMAIL PROTECTED]> wrote:
> After looking at the AR code, I think this can be solved in
> SQLiteAdapter::quote. I'm writing up a patch now.
> Kev
>
> On 12/21/05, Tobias Luetke <[EMAIL PROTECTED]> wrote:
> > maybe we should add connection.false / connection.true methods for
> > such things to AbstractAdapter?
> >
> > On 12/21/05, Kevin Clark <[EMAIL PROTECTED]> wrote:
> > > Replacing the defaults with t and f would work for sqlite, but it
> > > isn't database agnostic. Is there a way to do it and maintain cross db
> > > functionality?
> > >
> > > On 12/21/05, David Rupp <[EMAIL PROTECTED]> wrote:
> > > > Specify a checked_value and unchecked_value in your check_box method
> > > > call. Here's the method signature from the API docs
> > > > (api.rubyonrails.com):
> > > >
> > > > check_box(object, method, options = {}, checked_value = "1",
> > > > unchecked_value = "0")
> > > >
> > > > So you could replace the defaults of "1" and "0" with "t" and "f",
> > > > for example.
> > > >
> > > > Regards,
> > > > David
> > > >
> > > > On Dec 21, 2005, at 1:55 PM, Kevin Clark wrote:
> > > >
> > > > > I'm working on an application using sqlite locally and recently
> > > > > noticed that checkboxes are evaluating to 1 and 0 (not true and false)
> > > > > and thus aren't being sanitized to boolean values in the db ('t' and
> > > > > 'f' in sqlite). This isn't a problem in mysql because 1 and 0 are
> > > > > synonymous to true and false, but there's issues for some.
> > > > >
> > > > > Is this a bug? Is there some way around it that I've missed somewhere?
> > > > >
> > > > > Kev
> > > > > _______________________________________________
> > > > > Rails-core mailing list
> > > > > [email protected]
> > > > > http://lists.rubyonrails.org/mailman/listinfo/rails-core
> > > >
> > > > _______________________________________________
> > > > Rails-core mailing list
> > > > [email protected]
> > > > http://lists.rubyonrails.org/mailman/listinfo/rails-core
> > > >
> > > _______________________________________________
> > > Rails-core mailing list
> > > [email protected]
> > > http://lists.rubyonrails.org/mailman/listinfo/rails-core
> > >
> >
> >
> > --
> > Tobi
> > http://jadedpixel.com    - modern e-commerce software
> > http://typo.leetsoft.com - Open source weblog engine
> > http://blog.leetsoft.com - Technical weblog
> >
>
_______________________________________________
Rails-core mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails-core

Reply via email to