[Catalyst] Using Catalyst on MS SQL DB that has tables with no primary keys

Brian Katzung briank at kappacs.com
Sat Sep 15 00:29:09 GMT 2012


If I recall correctly, I read in a cookbook somewhere (can't seem to 
find it now) that for rows with no primary key, you can use:

__PACKAGE__->set_primary_key(__PACKAGE__->columns);

(making the entire row be a multi-column primary key).

   - Brian

On 2012-09-14 14:53, Derek W wrote:
> Ah, you meant just on Catalyst side, to tell it that the id column is
> the primary.  I didn't think of that.  Thanks!  I'll give that a shot.
>
> On Fri, Sep 14, 2012 at 11:40 AM, Robert Wohlfarth
> <rbwohlfarth at gmail.com> wrote:
>> On Fri, Sep 14, 2012 at 1:31 PM, Derek W <derekwrobel at gmail.com> wrote:
>>> Thanks, I figured that would probably fix it, but the problem is I am
>>> not allowed to make any changes to the DB structure itself.  I suppose
>>> I need to convince them why it's in the best interest to have a
>>> primary key...
>>>
>> You can set the primary key in the schema file. For example, add a line like
>> __PACKAGE__->set_primary_key( "id" ); to lib/MyApp/Schema/Result/MyTable.pm.
>> You do not need to change the database. DBIx::Class will then use id
>> whenever it wants a primary key.
>>
>> --
>> Robert Wohlfarth
>>
>>
>> _______________________________________________
>> List: Catalyst at lists.scsys.co.uk
>> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
>> Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
>> Dev site: http://dev.catalyst.perl.org/
>>
>
>

-- 
Brian Katzung, Kappa Computer Solutions, LLC
Leveraging UNIX, GNU/Linux, open source, and custom
software solutions for business and beyond
Phone: 847.412.0713  http://www.kappacs.com




More information about the Catalyst mailing list