dbix-class

MySql: transactions don't detect deadlocks?

Consider the following perl code: $schema->txn_begin(); my $r = $schema->resultset('test1')->find({id=>20}); my $n = $r->num; $r->num($n+1); print("updating for $$\n"); $r->update(); print("$$ val: ".$r->num."\n"); sleep(4); $schema->txn_commit(); I'm expecting that since the update is protected by a transaction, then if two proc...

Is there a tool to convert DBIx::Class Schema (or just SQL) to XSD

I am using perl DBIx::Class ORM and would like to be able to dynamically generate an XSD either from the DBIX::Class schema or directly from the SQL DDL. I know it would probably be better that we start with XSD and generate our SQL DDL from the XSD but we are not in a position to do that yet. thanks, Tom ...

How can I tidy DBIx::Class::Schema::Loader's output?

We are currently introducing DBIx::Class in our team and we would like to start out with DBIx::Class::Schema::Loader. However, we have hard requirements on code style, i.e. we've got Perl::Tidy as part of our pre-commit script, since we haven't had any generated code before. Now, we'd have to make sure that the code that Schema::Loader g...

Perl DBIx::Class - Default Values when using new()?

When using the new() method on a DBIx::Class ResultSource to create a (potentially temporary) variable, it doesn't seem to populate attributes with the default values specified in the DBIC schema (which we have specified for creating tables from that schema). Currently, we are creating one default value for one such class (the first cas...

Why does Perl's DBIx::Class $resultset->update fail on complex search queries?

I have a Perl DBIx::Class search the looks like this: my $rs = shift->search( { -and => [ { 'for_revocation' => 1 }, [ { status => { 'not_in' => [ 'revoked', 'revoking'] }, }, { ...

How do I add relationships at runtime using DBIx::Class and Catalyst?

In the application I am building, users can specify relationships between tables. Since I only determine this at runtime, I can't specify has_many or belongs_to relationships in the schema modules for startup. So given two tables; system and place, I would like to add the relationship to join records between them. I have part of the ...

How should I set up my DBIx::Class result classes in this simple case?

Let's suppose I have a the following simplified example database consisting of three tables: CREATE TABLE people ( person_id INTEGER PRIMARY KEY, person_name VARCHAR(100) ); CREATE TABLE events ( event_id INTEGER PRIMARY KEY, event_name VARCHAR(100), event_creator INTEGER CONSTRAINT f...

Is there an easy way to map DBIx::Class results to my custom Moose classes?

It seems kind of a pain to have my Moose classes. Then to use DBIx::Class to get a result set..then to manually map my result set to the moose classes. ...

How do I create a nested has_many or belongs_to relationship with DBIx::Class?

In my code I have three classes as follows: Forum, Forum::Thread and Forum::Post What I want to do is create a belongs_to-relationship from the Forum::Post class to the Forum class and vice versa with a has_many, preferably without creating a custom function for it. (This is admittedly more of an intellectual exercise than a technical l...

Moose Triggers Not Firing When Using DBIX::Class

I am new to Moose and am trying to use it with DBIx::Class. Basic DBIC querying and updating work find, but any trigger I attempt to write does not get executed when I modify an attribute. use Modern::Perl; use Data::Dumper; my $schema = My::Schema->connect(<connect str>, <usr>, <psw>) or die $!; my $rs = $schema->resultset('Isin')->s...

Moving from Class::DBI to DBIx::Class

I'm currently doing some research on DBIx::Class in order to migrate my current application from Class::DBI. Honestly I'm a bit disappointed about the DBIx::Class when it comes to configuring the result classes, with Class::DBI I could setup metadata on models just by calling the on function without a code generator and so on my questio...

Auto Generate Objects in DBIx::Class ORM in Perl

Hello, I started learning DBIx::class and I reach the point where you have to create the Objects that represents tables. Should this classes be created manually ( hard coding all the fields and relationships.....) or there is a way to generate them automatically using the database schema. I read something about loaders, but i did not kn...

Can Perl DBIx::Class override the way a column is retrieved from the database?

I have never used DBIx::Class until today, so I'm completely new at it. I'm not sure if this is possible or not, but basically I have a table in my SQLite database that has a timestamp column in it. The default value for the timestamp column is "CURRENT_TIMESTAMP". SQLite stores this in the GMT timezone, but my server is in the CDT ti...

How can I filter a Perl DBIx recordset with 2 conditions on the same column?

I'm getting my feet wet in DBIx::Class loving it so far. One problem I am running into is that I want to query records, filtering out records that aren't in a certain date range. It took me a while to find out how to do a <= type of match instead of an equality match: my $start_criteria = ">= $start_date"; my $end_criteria = "<= $end...

Injecting relationships in DBIx::Class

I have a handful of DBIx::Class::Core objects that model various database tables. For some of those models (those that have a 'queue' column), I have another class inject subs (basically, to 'move' the model object along it's queue states). I'd like to also have that class inject has_many relationships ala class($name)->has_many('queu...

Why isn't DBIx::Class::Schema::Loader creating my classes?

I am trying to generate static schemas using DBIx::Class in Perl. The command shown below outputs a Schema.pm and no other files. Any idea what I'm doing wrong, or how to to debug this? U:\wohlfarj\Software\PARS>perl -MDBIx::Class::Schema::Loader=make_schema_at,dump_to_dir:.\lib -e "make_schema_at('PARS::Schema',{debug=>1},['dbi:ODBC:P...

DBIC generates an "Invalid precision" error for a primary key

The table stores file names. The primary key is an auto-incrementing integer. A search using the result set works. And calling the delete method generates the following error message: DBIx::Class::Relationship::CascadeActions::delete(): DBI Exception: DBD::ODBC::st execute failed: [Microsoft][ODBC SQL Server Driver]Invalid precision v...

How can I store a DateTime::Duration object in my DBI::Class model on a MySQL database?

I currently use the DBIx::Class::InflateColumn::DateTime plugin to inflate my date columns to DateTime objects and deflate my DateTime objects to MySQL date values. I want to store the age of an individual (I cannot use DOB) and for this the years, months or days values may be 0. Therefore I am using a DateTime::Duration object. Thing i...

Catalyst: How do I make DBIx::Class::Schema::Loader::make_schema_at() static preserve case?

I'd like to be able to force the PACKAGE->add_columns() to not lc everything. I know there's a preserve_case option, but I can't figure out where to put it though. is there a 'myproj_schema.pl' file I can create in /conf ? -Joe ...

When using DBIx::Class Schema Loader, is there a way to maintain custom relationships and methods in separate files?

Currently we use DBIx::Class::Schema::Loader to generate and regenerate (when our db schema changes) a set of Result classes. We add additional relationships and methods to the bottom of these classes and this is causing merge hell when people regenerate or change the schema. We would like to maintain our custom changes in a separate...