On Dec 17, 2007, at 8:59 AM, Lele Gaifax wrote:

> A. some tests do a textual comparison against an expected
>    statement; this breaks on FB, because the dialect inserts an
>    explicit PK field::
>
>      AssertionError: Testing for query 'INSERT INTO users (user_name)
>      VALUES (?)' params [{'user_name': 'thesub'}], received
>      'INSERT INTO users (user_id, user_name) VALUES (?, ?)'
>       with params [{'user_name': 'thesub', 'user_id': 1}]
>
>    five of the above seven failures are of this kind :)

there are two varieties to those types of test, one with sequence and  
one without.   you shuld change line 433 of test/testlib/testing.py to  
include "firebird" in the list of dbs that use sequences.


> B. many other tests insert an explicit NULL in a PK field, not
>    allowed under Firebird (because PK fields *must* be NOT NULL)
>
>    most of the above 187 errors fall in this category.

all those tests must be given a Sequence object with the  
"optional=True" flag on the first integer primary key column, and  
Firebird must use sequences that are marked as "optional" (since they  
arent optional with FB).  One way we can do this in an automated  
fashion would be to complete the Column implementation in test/testlib/ 
schema.py to automatically gen a Sequence for primary-key integer cols  
that do not already have a sequence (though this might have side  
effects for some tests).

> C. a few tests don't use an explicit ordering, and assume that the
>    result of a select without an "ORDER BY" matches the insert order;
>    under Firebird I notice an intermittent behaviour, and in some
>    cases (expecially under load) this is not true. The following
>    fixes one of those points to explain::
>
>      Index: test/engine/execute.py
>       
> ===================================================================
>      --- test/engine/execute.py      (revisione 3952)
>      +++ test/engine/execute.py      (copia locale)
>      @@ -26,7 +26,7 @@
>                   conn.execute("insert into users (user_id,  
> user_name) values (?, ?)", [3,"ed"], [4,"horse"])
>                   conn.execute("insert into users (user_id,  
> user_name) values (?, ?)", (5,"barney"), (6,"donkey"))
>                   conn.execute("insert into users (user_id,  
> user_name) values (?, ?)", 7, 'sally')
>      -            res = conn.execute("select * from users")
>      +            res = conn.execute("select * from users order by  
> user_id")
>                   assert res.fetchall() == [(1, "jack"), (2,  
> "fred"), (3, "ed"), (4, "horse"), (5, "barney"), (6, "donkey"), (7,  
> 'sally')]
>                   conn.execute("delete from users")

explicit orderings can be added as needed to suit result set  
comparisons; we have to add these all the time for postgres.

> D. to my surprise, a self-reference foreign key on a table needs
>    either "ON DELETE CASCADE" or "ON DELETE SET NULL" to allow the
>    testsuite to delete its content in the tearDown step with a simple
>    "DELETE FROM table" statement; one spot of this is fixed by the
>    following::
>
>      Index: test/orm/eager_relations.py
>       
> ===================================================================
>      --- test/orm/eager_relations.py (revisione 3952)
>      +++ test/orm/eager_relations.py (copia locale)
>      @@ -650,7 +650,7 @@
>               global nodes
>               nodes = Table('nodes', metadata,
>                   Column('id', Integer, Sequence('node_id_seq',  
> optional=True), primary_key=True),
>      -            Column('parent_id', Integer,  
> ForeignKey('nodes.id')),
>      +            Column('parent_id', Integer,  
> ForeignKey('nodes.id', onupdate="CASCADE", ondelete="CASCADE")),
>                   Column('data', String(30)))

I was wondering the other day if any DB's would have this issue.  Im  
not comfortable adding CASCADE rules in every case, although in  
eager_relations is probably OK, since sometimes we are testing that  
SQLA explicitly deletes things properly.  I think for this we might  
look at adding a ForeignKey construct to test/testlib/schema.py which  
adds the CASCADE rules for the firebird dialect only.



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to