[Dbix-class] Proposed readonly patch for DBIx::Class

Darren Duncan darren at darrenduncan.net
Fri Aug 19 19:55:41 GMT 2011


Ben Tilly wrote:
> 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 DBIx::Class?

A clean solution to this would be to implement it at the DBMS level, either at 
the connection level where you tell the DBMS to fail all write attempts, or at 
the individual table level using privileges, where the application doesn't have 
privileges to write tables, just read. -- Darren Duncan



More information about the DBIx-Class mailing list