On Tue, May 11, 2010 at 8:02 AM, Peter Rabbitson <[email protected]<rabbit%[email protected]> > wrote:
> > I didn't see this as a bug in Ordered. Ordered asked for the column > > data and got an undefined value and assumed it was null. Seemed more > > like an example of why might be good for DBIC to throw an exception if a > > column is accessed w/o being fetched. > > It may or may not be - this is beyond the point. The public API from day > one > has been "you get all columns by default" and "every accessor always > works". > But part of the API is also passing in "columns", correct? > If you alter the selector, and then do not check that you are asking for > something that *you* did not bring back from the db - you get to keep the > pieces. In this case Ordered is clearly misusing the API, thus the problem > is with Ordered, and it will be fixed sooner or later (sooner if we get a > test case contribution). > Guess I still don't follow. I've *given* Ordered an item I fetched w/o including the position column. It's really my fault for doing that. Ordered has no way of knowing that the object passed to it didn't fetch the column it needs, right? Is there currently a way to inspect a row object and determine what columns were fetched from the store? > ^^ nowhere do you inform DBIC that there is in fact a unique constraint > on the source/table. The moment you do the appropriate > add_unique_constraint > the SQL will magically change to being correct :) > Well, that makes sense. Any exactly why I posted the full example. Although now the database takes more of a beating... ;) :!perl /home/moseley/dbic_music/test.pl Id = 100 Track = 1 Id = 101 Track = 2 Id = 102 Track = 3 Id = 103 Track = 4 Id = 104 Track = 5 Id = 105 Track = 6 Id = 106 Track = 7 Id = 107 Track = 8 Id = 108 Track = 9 Id = 109 Track = 10 removing id 103 position 4 SELECT position FROM track me WHERE ( ( position > ? AND ( position != ? AND cd = ? ) ) ) ORDER BY position DESC LIMIT 1: '4', '4', '15' UPDATE track SET position = ? WHERE ( id = ? ): '0', '103' SELECT me.id FROM track me WHERE ( ( ( position BETWEEN ? AND ? ) AND cd = ? ) ) ORDER BY position ASC: '5', '10', '15' UPDATE track SET position = position - 1 WHERE ( id = ? ): '104' UPDATE track SET position = position - 1 WHERE ( id = ? ): '105' UPDATE track SET position = position - 1 WHERE ( id = ? ): '106' UPDATE track SET position = position - 1 WHERE ( id = ? ): '107' UPDATE track SET position = position - 1 WHERE ( id = ? ): '108' UPDATE track SET position = position - 1 WHERE ( id = ? ): '109' UPDATE track SET position = ? WHERE ( id = ? ): '10', '103' DELETE FROM track WHERE ( id = ? ): '103' -- Bill Moseley [email protected]
_______________________________________________ List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class IRC: irc.perl.org#dbix-class SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/ Searchable Archive: http://www.grokbase.com/group/[email protected]
