On Wed, Aug 10, 2011 at 10:56 PM, Alex Povolotsky <[email protected]> wrote: > Ben Tilly пишет: >> >> Often database schemas have tables that should not be changed at >> runtime in the application. It would be convenient to be able to mark >> this fact in the class. However to avoid accidents you wind up having >> to override methods in both the Row class and the ResultSet class. >> Having to synchronize changes to 2 classes is kind of messy. >> >> The attached patch makes this look much nicer in the client code. >> With this in the Result class you just say: >> >> __PACKAGE__->readonly(1); >> >> and now you won't accidentally update that table from in Perl. It can >> be unset at any time and so doesn't provide any actual security, but >> it is a useful hint. >> >> Is there any possibility that this could be considered for inclusion >> in DBI > > Readonly component (dies on insert/update/delete) seems to me to be much > more reasonable solution. Do not overbloat base class, it is not too thin > already.
In order to be readonly, you have to make both the row and resultset classes behave differently. According to what I heard on IRC there are ideas floating around for how to inject components into the resultset class from the Result class, but currently there are no good solutions for that. If I had found a clean solution for that, I wouldn't be submitting this patch. But that's a bigger problem. _______________________________________________ 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]
