Hi Jim,

It looks like we've run up against a problem in the Mayfly subselect 
functionality.

The following test case fails:

        @Test
        public void subselect() {
                Database database = TestDatabase.makeDatabase();
                database.execute("create table first(first_id integer, 
first_value integer)");
                database.execute("insert into first(first_id, first_value) 
values(5, 55)");
                database.execute("insert into first(first_id, first_value) 
values(3, 33)");
                database.execute("create table second(second_id integer, 
reference_to_first_id integer)");
                database.execute("insert into second(second_id, 
reference_to_first_id) values(3, 5)");

                database.execute("update first set first_value = 88 where 
first_id in" +
                                " (select reference_to_first_id from second 
where second_id = 3)");
                
                String updatedDump = new SqlDumper().dump(database.dataStore());

                database = TestDatabase.makeDatabase();
                database.execute("create table first(first_id integer, 
first_value integer)");
                database.execute("insert into first(first_id, first_value) 
values(5, 88)");
                database.execute("insert into first(first_id, first_value) 
values(3, 33)");
                database.execute("create table second(second_id integer, 
reference_to_first_id integer)");
                database.execute("insert into second(second_id, 
reference_to_first_id) values(3, 5)");
                String expectedDump = new 
SqlDumper().dump(database.dataStore());
                
                assertEquals(expectedDump, updatedDump);
                
        }

(using either "in" or "=" in the update statement yields the same result)

In this case, I am attempting to update the row with first_id = 5 in the first 
table by selecting that idea from the second table. Instead of using the 
selected value of 5, the value of 3 that is in the subselect is used instead.  
So the result of the update operation is to replace 33 by 88 instead of 
replacing 55 by 88.

It would be great if we could get a fix for this since it is blocking our 
current work.

Thanks,
--Van

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

Reply via email to