#324 ✓resolved

"''Don't know how to quote''" Object, (marshalled) property type

Reported by hookercookerman | May 29th, 2008 @ 11:11 AM

yes using marshalled object causes a runtime error

data_objects-0.9.1/lib/data_objects/quoting.rb:52:in `quote_value'

data_objects-0.9.1/lib/data_objects/quoting.rb:27:in `escape_sql'

Comments and changes to this ticket

  • Bernerd Schaefer

    Bernerd Schaefer June 9th, 2008 @ 03:41 PM

    • State changed from “new” to “open”

    Could you provide some more information for this?

    In dm-core, now, a property with the type Object gets Marshalled and Base64 encoded, and stores properly in sqlite/mysql/postgres.

    Was this error from DM or from DO itself?

  • hookercookerman

    hookercookerman June 10th, 2008 @ 04:07 AM

    sorry should of put more info in the ticket.

    I am on the latest head of dm and do.

    I have a model with

    property :offer, Object

    -- I am setting offer with my own custom Offer Object

    -- when I try to update the attribute I get,


    /Library/Ruby/Gems/1.8/gems/data_objects-0.9.1/lib/data_objects/quoting.rb:52:in `quote_value'

    /Library/Ruby/Gems/1.8/gems/data_objects-0.9.1/lib/data_objects/quoting.rb:27:in `escape_sql'

    /Library/Ruby/Gems/1.8/gems/data_objects-0.9.1/lib/data_objects/quoting.rb:26:in `gsub!'

    /Library/Ruby/Gems/1.8/gems/data_objects-0.9.1/lib/data_objects/quoting.rb:26:in `escape_sql'

    /Library/Ruby/Gems/1.8/gems/dm-core-0.9.1/lib/dm-core/adapters/data_objects_adapter.rb:225:in `execute_non_query'

    /Library/Ruby/Gems/1.8/gems/dm-core-0.9.1/lib/dm-core/adapters/data_objects_adapter.rb:225:in `execute'

    /Library/Ruby/Gems/1.8/gems/dm-core-0.9.1/lib/dm-core/adapters/data_objects_adapter.rb:350:in `with_connection'

    /Library/Ruby/Gems/1.8/gems/dm-core-0.9.1/lib/dm-core/adapters/data_objects_adapter.rb:223:in `execute'

    /Library/Ruby/Gems/1.8/gems/dm-core-0.9.1/lib/dm-core/adapters/data_objects_adapter.rb:189:in `update'

    /Library/Ruby/Gems/1.8/gems/dm-core-0.9.1/lib/dm-core/repository.rb:117:in `save'

    /Library/Ruby/Gems/1.8/gems/dm-core-0.9.1/lib/dm-core/resource.rb:495:in `update'

    /Library/Ruby/Gems/1.8/gems/dm-core-0.9.1/lib/dm-core/resource.rb:279:in `save'

    /Library/Ruby/Gems/1.8/gems/dm-validations-0.9.1/lib/dm-validations.rb:35:in `save'

    /Library/Ruby/Gems/1.8/gems/dm-core-0.9.1/lib/dm-core/hook.rb:112:in `call'

    /Library/Ruby/Gems/1.8/gems/dm-core-0.9.1/lib/dm-core/hook.rb:112:in `save'

    /Library/Ruby/Gems/1.8/gems/dm-core-0.9.1/lib/dm-core/hook.rb:108:in `catch'

    /Library/Ruby/Gems/1.8/gems/dm-core-0.9.1/lib/dm-core/hook.rb:108:in `save'

    /Library/Ruby/Gems/1.8/gems/dm-core-0.9.1/lib/dm-core/resource.rb:471:in `update_attributes'

    When the sql is being escaped there is no quote value for Object, take a look below.

    module Quoting

    1. Escape a string of SQL with a set of arguments.
    2. The first argument is assumed to be the SQL to escape,
    3. the remaining arguments (if any) are assumed to be
    4. values to escape and interpolate.


    1. ==== Examples
    2. escape_sql("SELECT * FROM zoos")
    3. # => "SELECT * FROM zoos"


    1. escape_sql("SELECT * FROM zoos WHERE name = ?", "Dallas")
    2. # => "SELECT * FROM zoos WHERE name = `Dallas`"


    1. escape_sql("SELECT * FROM zoos WHERE name = ? AND acreage > ?", "Dallas", 40)
    2. # => "SELECT * FROM zoos WHERE name = `Dallas` AND acreage > 40"


    1. ==== Warning
    2. This method is meant mostly for adapters that don't support
    3. bind-parameters.

    def escape_sql(args)

    sql = @text.dup

    unless args.empty?

    sql.gsub!(/\?/) do |x|






    def quote_value(value)

    return 'NULL' if value.nil?

    case value

    when Numeric then quote_numeric(value)

    when String then quote_string(value)

    when Class then quote_class(value)

    when Time then quote_time(value)

    when DateTime then quote_datetime(value)

    when Date then quote_date(value)

    when TrueClass, FalseClass then quote_boolean(value)

    when Array then quote_array(value)

    when Range then quote_range(value)

    when Symbol then quote_symbol(value)


    if value.respond_to?(:to_sql)



    raise "Don't know how to quote #{value.inspect}"




    hope this helps.

  • Bernerd Schaefer

    Bernerd Schaefer June 10th, 2008 @ 10:42 AM

    • State changed from “open” to “hold”

    This is fixed in the latest git version of dm-core (http://www.github.com/sam/). We'll be pushing out a new public release (0.9.2) soon.

    In the meantime, you can add this code (http://github.com/sam/dm-core/tr...) to your project, and should get the proper functionality.

  • Bernerd Schaefer

    Bernerd Schaefer June 10th, 2008 @ 11:14 AM

    • State changed from “hold” to “resolved”

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

People watching this ticket