#101 invalid
Timothy Bennett (lanaer)

Postgresql adapter violates model equality

Reported by Timothy Bennett (lanaer) | December 17th, 2007 @ 10:37 PM

As of r609, simply creating a model and loading it will result in the original being different from what was loaded. Null boolean values are loaded as false (when they were nil in the originally created model), and null integer values are loaded as 0.

Run (assuming you have postgresql):

$ createdb data_mapper_1
$ ADAPTER=postgresql USERNAME=… PASSWORD=… rake dm:spec

(USERNAME & PASSWORD are optional, depending on your postgresql setup)

I get 4 failing specs when running against the postgresql adapter on OS X 10.5.1, do_postgres 0.2.2, postgresql 8.2.4, and DM r609.

The problem I describe relates primarily to "DataMapper::Base should be comparable", and also causes "A tree should work" to fail. I’m not sure what causes the other two failures.

Full failure information:

1)
'A tree should work' FAILED
expected: #<Node:0x1a9dc8c @new_record=false, @parent_id=0, @name="root", @id=1>,
     got: #<Node:0x1aba968 @new_record=false, @parent_id=nil, @name="root", @id=1> (using ==)
./spec/acts_as_tree_spec.rb:51:

2)
'DataMapper::Base should be comparable' FAILED
expected: #<Person:0x1aee81c @new_record=false, @type="Person", @address_city=nil, @age=0, @name="Sam", @address_state=nil, @occupation=nil, @address_street=nil, @date_of_birth=nil, @notes="Lorem ipsum dolor sit amet", @address_zip_code=nil, @id=9, @career_name=nil>,
     got: #<Person:0x1af746c @new_record=false, @type="Person", @address_city=nil, @age=nil, @name="Sam", @address_state=nil, @occupation=nil, @address_street=nil, @date_of_birth=nil, @notes="Lorem ipsum dolor sit amet", @address_zip_code=nil, @id=9, @career_name=nil> (using ==)./spec/base_spec.rb:69:

3) 
DataObject::QueryError in 'DataMapper::Adapters::PostgresqlAdapter::Mappings::Table should s
earch only the specified schema if qualified'
Your query failed.
ERROR:  schema "my_schema" does not exist

QUERY: "CREATE TABLE "my_schema"."cages" ("id" SERIAL PRIMARY KEY, "name" varchar)"
./spec/../lib/data_mapper/adapters/sql/mappings/table.rb:122:in `create!'
./spec/../lib/data_mapper/adapters/data_object_adapter.rb:77:in `connection'
./spec/../lib/data_mapper/support/connection_pool.rb:68:in `hold'
./spec/../lib/data_mapper/adapters/data_object_adapter.rb:77:in `connection'
./spec/../lib/data_mapper/adapters/sql/mappings/table.rb:121:in `create!'
./spec/../lib/data_mapper/adapters/data_object_adapter.rb:187:in `save'./spec/../lib/data_mapper/context.rb:56:in `save'
./spec/postgres_spec.rb:44:
   
4) 
'DataMapper::Adapters::Sql::Mappings::Schema should return all tables from the database sche
ma' FAILED
expected: 13,
     got: 14 (using ==)
./spec/schema_spec.rb:5:

Comments and changes to this ticket

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

Pages