[Dbix-class] Lazy Columns
moseley at hank.org
Tue May 11 16:26:22 GMT 2010
On Tue, May 11, 2010 at 8:02 AM, Peter Rabbitson
<rabbit+dbic at rabbit.us<rabbit%2Bdbic at rabbit.us>
> > 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
> has been "you get all columns by default" and "every accessor always
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
> 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... ;)
Id =3D 100 Track =3D 1
Id =3D 101 Track =3D 2
Id =3D 102 Track =3D 3
Id =3D 103 Track =3D 4
Id =3D 104 Track =3D 5
Id =3D 105 Track =3D 6
Id =3D 106 Track =3D 7
Id =3D 107 Track =3D 8
Id =3D 108 Track =3D 9
Id =3D 109 Track =3D 10
removing id 103 position 4
SELECT position FROM track me WHERE ( ( position > ? AND ( position !=3D ? =
cd =3D ? ) ) ) ORDER BY position DESC LIMIT 1: '4', '4', '15'
UPDATE track SET position =3D ? WHERE ( id =3D ? ): '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 =3D position - 1 WHERE ( id =3D ? ): '104'
UPDATE track SET position =3D position - 1 WHERE ( id =3D ? ): '105'
UPDATE track SET position =3D position - 1 WHERE ( id =3D ? ): '106'
UPDATE track SET position =3D position - 1 WHERE ( id =3D ? ): '107'
UPDATE track SET position =3D position - 1 WHERE ( id =3D ? ): '108'
UPDATE track SET position =3D position - 1 WHERE ( id =3D ? ): '109'
UPDATE track SET position =3D ? WHERE ( id =3D ? ): '10', '103'
DELETE FROM track WHERE ( id =3D ? ): '103'
moseley at hank.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the DBIx-Class