#151 invalid
jmoses

[Patch] Spec breakage on Leopard/sqlite3-ruby

Reported by jmoses | February 11th, 2008 @ 10:02 AM

I get a failure on:

DataMapper::Adapters::Sql::Mappings::Schema

  • should return all tables from the database schema (FAILED - 1)

And:

1)

'DataMapper::Adapters::Sql::Mappings::Schema should return all tables from the database schema' FAILED

expected: 16,

got: 22 (using ==)

./spec/schema_spec.rb:6:

The tables in my sqllite DB are:

["applications_candidates", "candidates", "chains_chains", "chains", "fences", "jobs", "tasks_tasks", "exhibits", "fruit", "animals_exhibits", "animals", "tasks", "projects", "posts", "comments", "sections", "users", "tomatoes", "serializers", "people", "careers", "zoos"]

Which include some relationship tables. The expected count(16) is coming from just counting the YAML files, which will never work when there's associations.

Is this just a spec that should be updated, or is it an artifact of Leopard/sqllite?

Comments and changes to this ticket

  • asceth

    asceth February 11th, 2008 @ 03:55 PM

    This spec fails on all DB's because of how its defined. There are two specs that fail for me and are expected... the one you listed and one about AutoMigration.

    They fail because they haven't been updated while various things are fixed/refactored.

  • jmoses

    jmoses February 11th, 2008 @ 03:46 PM

    So a patch to update the spec would be the way to fix this?

  • jmoses

    jmoses February 11th, 2008 @ 05:50 PM

    • Title changed from “Spec breakage on Leopard/sqlite3-ruby” to “[Patch] Spec breakage on Leopard/sqlite3-ruby”

    Attached is a patch to update the `spec/schema.rb` spec to parse through all the testing models and count the HABTM relationships and add them into the expected table count.

    It should work in most cases.

  • asceth

    asceth February 11th, 2008 @ 11:06 PM

    You probably need to divide the habtm count by 2 because the habtm relationship is defined in two models to link them together and only creates 1 table.

  • jmoses

    jmoses February 12th, 2008 @ 06:31 AM

    Ah. I have to do other things too. It's pure luck that the spec passes. I'll submit an updated patch later.

  • jmoses

    jmoses February 12th, 2008 @ 08:28 AM

    Attached new patch which handles this the "right" way.

    Removes all tables, iterates through all models, re-creating tables. Actually iterates through the association list that DM has and picks up the actual HABTM associations and table names. The count will mirror what DM thinks should be in the DB, which is much more accurate that counting fixtures.

    This should work even with radical model changes either in the .rb files, or with dynamic changes in the specs.

  • Dan Kubb (dkubb)
  • Sam Smoot

    Sam Smoot April 28th, 2008 @ 12:44 PM

    • State changed from “new” to “invalid”

    Does not apply to 0.9.0.

  • Sam Smoot

    Sam Smoot April 28th, 2008 @ 12:45 PM

    Does not apply to 0.9.0.

  • Sam Smoot

    Sam Smoot April 28th, 2008 @ 12:49 PM

    Does not apply to 0.9.0.

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

Attachments

Pages