Fun.  none of these work in oracle, TRUE, 't', 'true', 'y', 'yes', '1',
FALSE, 'f', 'false', 'n', 'no', '0'
So we need to take a different approach to the value.to_i and value.to_s

On Mon, Mar 16, 2009 at 9:04 AM, naaano <[email protected]> wrote:

>
> In postgresql is stored as a bit, not numbers, chars or strings. The
> "true/false" is just a representation for input, which are many
> alternatives, as postgresql doc says:
>
>  Valid literal values for the "true" state are:
>
> TRUE
> 't'
> 'true'
> 'y'
> 'yes'
> '1'
>
> For the "false" state, the following values can be used:
>
> FALSE
> 'f'
> 'false'
> 'n'
> 'no'
> '0'
>
> However, that '0' and '1' are read as chars/strings, that is with ""
> or '' which the ["#{column.search_sql} = ?", value.to_i] skips.
>
>
> On Mar 14, 12:22 am, Kenny Ortmann <[email protected]> wrote:
> > Yeah if you use it in conditions like that then it does work but if you
> us
> > it like this
> > ["#{column.search_sql} = ?", value.to_i]
> >
> > then it needs the 1, 0 or sqlite would need 't' or 'f'
> >
> > On Fri, Mar 13, 2009 at 6:17 PM, <[email protected]> wrote:
> >
> > > On Fri, 13 Mar 2009 08:52:27 -0500, Kenny Ortmann <
> [email protected]
> >
> > > wrote:
> > > > I don't think the actual problem was in the search select drop downs.
> >
> > > > Once you pass 0 or 1
> > > > ["#{column.search_sql} = ?", value.to_s] it would evaluate to "column
> =
> > > > '1'"
> > > > or "column = '0'"
> > > > true or false
> > > > ["#{column.search_sql} = ?", value.to_s] it would evaluate to "column
> =
> > > > 'true'" or "column = 'false'" <-- won't work in oracle
> >
> > > > but as Sergio said, rails-2.2 and master branches have
> > > > ["#{column.search_sql} = ?", column.column.type_cast(value)]
> >
> > > > I would hope if you do
> > > > ["#{column.search_sql} = ?", column.column.type_cast(value)]
> > > > with 'true' or 'false' that it will convert it to 1 or 0, if it
> doesn't
> > > > convert it to 1 or 0 then it won't work with oracle.
> >
> > > > I don't know how type_cast works though.
> >
> > > For mysql it's converted to 1 or 0, in sqlite it's converted to 't' or
> 'f'.
> > > In other databases I don't know, but it should work, I think it's used
> in
> > > Model.find :all, :conditions => {:boolean_column => true} for example.
> >
> > > > On Fri, Mar 13, 2009 at 5:04 AM, Sergio Cambra .:: entreCables -
> Symbol
> > > > Servicios Informáticos S.L. ::. <[email protected]> wrote:
> >
> > > >> El Thursday 12 March 2009 18:56:30 naaano escribió:
> > > >> > Acording to SQL ISO standard, boolean types are "CRUDed" as:
> > > >> > TRUE - FALSE
> > > >> > However, Mysql doesn't have real support for boolean types,
> instead
> > > >> > using a patched way of tinyint.
> > > >> > Not surprising that most users use this database engine, the code
> > > >> > developed to interact with databases is first made with Mysql in
> > > >> > mind.
> > > >> > So, AS doesn't have problems with this since most of it is handled
> via
> > > >> > ActiveRecord, but there's some harcoded SQL in it. Particulary,
> this
> > > >> > mistakes reflect on 2 parts/files:
> >
> > > >> > 1.- the search_ui (search_column_helpers.rb: line
> > > >> > 106:active_scaffold_search_boolean)
> > > >> > 2.- the finder constructor (finder.rb: condition_for_column, line
> 39)
> >
> > > >> > However, Mysql supports SQL ISO standard for this, so, switching
> the
> > > >> > code to SQL standard makes it work for all database engines:
> >
> > > >> > in search_column_helpers.rb, lines 109 and 110:
> > > >> >  select_options << [as_(:true), true]
> > > >> >  select_options << [as_(:false), false]
> >
> > > >> I have fixed it, thanks.
> >
> > > >> > in finder.rb, line 39:
> > > >> > ["#{column.search_sql} = ?", value.to_s]
> >
> > > >> In rails-2.2 and master branches is:
> > > >> ["#{column.search_sql} = ?", column.column.type_cast(value)]
> > > >> I think it should be work for postgresql
> > > >> What rails and AS version are you using?
> >
> > > >> --
> > > >> Sergio Cambra .:: entreCables S.L. ::.
> > > >> Nicolás Guillén 6, locales 2 y 3. 50.018 Zaragoza
> > > >> T) 902 021 404 F) 976 52 98 07 E) [email protected]
> >
> >
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"ActiveScaffold : Ruby on Rails plugin" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/activescaffold?hl=en
-~----------~----~----~----~------~----~------~--~---

  • AS... naaano
    • ... Sergio Cambra .:: entreCables - Symbol Servicios Informáticos S.L. ::.
      • ... Kenny Ortmann
        • ... naaano
          • ... Kenny Ortmann
        • ... sergio
          • ... Kenny Ortmann
            • ... naaano
              • ... Kenny Ortmann
                • ... naaano
                • ... Kenny Ortmann
      • ... naaano

Reply via email to