Questions tagged [dbix-class]

DBIx::Class is a Perl object-relational mapping (ORM) module. It aims to make representing queries in your code as perl-ish as possible while still providing access to as many of the capabilities of the database as possible, including retrieving related records from multiple tables in a single query, JOIN, LEFT JOIN, COUNT, DISTINCT, GROUP BY, ORDER BY and HAVING support.

from the description on CPAN:

This is an SQL to OO mapper with an object API inspired by Class::DBI (with a compatibility layer as a springboard for porting) and a resultset API that allows abstract encapsulation of database operations. It aims to make representing queries in your code as perl-ish as possible while still providing access to as many of the capabilities of the database as possible, including retrieving related records from multiple tables in a single query, JOIN, LEFT JOIN, COUNT, DISTINCT, GROUP BY, ORDER BY and HAVING support.

DBIx::Class can handle multi-column primary and foreign keys, complex queries and database-level paging, and does its best to only query the database in order to return something you've directly asked for. If a resultset is used as an iterator it only fetches rows off the statement handle as requested in order to minimise memory usage. It has auto-increment support for SQLite, MySQL, PostgreSQL, Oracle, SQL Server and DB2 and is known to be used in production on at least the first four, and is fork- and thread-safe out of the box (although your DBD may not be).

377 questions
0
votes
1 answer

Setting up a Many-to-Many relation of a table with itself with DBIx::Class

I am porting an application from Class::DBI to DBIx::Class and need help. I have a table T with a primary key tid and another table ChildT that relates a row of T to multiple (child) rows of T itself. How can I setup the relations between T and…
Gurunandan Bhat
  • 3,544
  • 3
  • 31
  • 43
0
votes
1 answer

dbix might_have and prefetch it's relationships on first access?

Example I have a table that might_have an expansion board; an expansion board has_many locks Is it possible to when the might_have is first accessed to prefetch the locks? (Yes I know that when I get the table I can prefetch the board and it's…
melutovich
  • 372
  • 1
  • 3
  • 15
0
votes
1 answer

Catalyst Plugin Session deleting session before it is used

I'm using Catalyst::Plugin::Session along with Catalyst::Plugin::Session::Store::DBIC and CatalystX::SimpleLogin. I've used these multiple times before, but I'm getting some strange behavior currently. What I'm seeing is that once I login the…
srchulo
  • 5,143
  • 4
  • 43
  • 72
0
votes
1 answer

Simple DBIx::Class query with DISTINCT and WHERE clause

My table, speakers: id | type | speaker | updated_on The MySQL query I'm trying to replicate in DBIx::Class is: "SELECT DISTINCT speaker FROM speakers WHERE type = "motivational" The following is returning all records in the table and should only…
breadwild
  • 327
  • 2
  • 4
  • 13
0
votes
1 answer

How does DBIx::Class::Storage::DBI's connect_info work?

The docs for connect_info: connect_info This method is normally called by "connection" in DBIx::Class::Schema, which encapsulates its argument list in an arrayref before passing them here. The argument list may contain: The same 4-element…
Evan Carroll
  • 78,363
  • 46
  • 261
  • 468
0
votes
1 answer

DBIx::Class Find or Create objects

I'm using DBIx::Class to model the following: A Recipe with many Tags. The Tag is shared with other Recipe objects. While creating a Recipe object I want to create a set of Tag objects and associate them with the newly created Recipe object. (The…
Sandeep Chayapathi
  • 1,490
  • 2
  • 13
  • 31
0
votes
1 answer

Extracting date parts using DBIC while keeping queries database agnostic

I use a MySQL database in production and a SQLite database for running tests. One part of my application is used to gather monthly statistics for a year. I've successfully done this, however it came at a cost of not being able to automate tests…
a7omiton
  • 1,597
  • 4
  • 34
  • 61
0
votes
3 answers

Perl DBIx::Class encounterd Object Json

I'm new to Perl and DBIx::Class. This is how I get my meaning_ids from the table translation where language = 5: my $translations = $schema -> resultset('Translation')->search({ language => '5'}); After it I'm trying to push my data from the…
Hansanho
  • 295
  • 1
  • 3
  • 13
0
votes
1 answer

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. Is there a 'myproj_schema.pl' file I can create in /conf ?
Joe
  • 61
  • 2
0
votes
3 answers

How do I create a Catalyst::Model::DBIC::Schema from a DBIC::Schema?

Total lack of documentation makes this difficult.. Essentially, I have package MyApp::Schema; sub new_schema { __PACKAGE__->connect(...) } Then I have package MyCatApp::Model::MyApp; use Moose; extends 'Catalyst::Model::DBIC::Schema'; ## what…
Evan Carroll
  • 78,363
  • 46
  • 261
  • 468
0
votes
1 answer

How much magic can DBIx::Class::Row::set_columns do?

Is DBIx::Class::Row::set_columns clever enough to update prefetched child rows? I've tried it, and it doesn't seem to be. I'm probably expecting too much magic. I did something like this: my $data = { id => 1, date => '2015-06-27', #…
Chris Dennis
  • 995
  • 7
  • 16
0
votes
1 answer

Dbix::Class slow response

I have a DBIx::Class query that's taking too long to complete. All SQL below were generated by DBIx::Class. First scenario (DBIx Simple select): SELECT me.pf_id, me.origin_id, me.event_time, me.proto_id FROM pf me ORDER BY event_time DESC LIMIT…
Nilson Morais
  • 821
  • 1
  • 7
  • 6
0
votes
1 answer

Why Manual prefetch (via select/columns) not supported with accessor 'multi'?

When I run code: return $self->result_source->schema->resultset('Locality')->search( { 'addresses_view.usage' => 0 ,'me.id' => $self->id } ,{ join => { servers => 'addresses_view' } } ); The…
Eugen Konkov
  • 22,193
  • 17
  • 108
  • 158
0
votes
1 answer

Retrieving related data from Result object

I have the following relationship on my Entry result class: package Schema::Result::Entry; __PACKAGE__->has_many( "entry_i18ns", "Schema::Result::EntryI18n", { "foreign.entry_id" => "self.id" }, { cascade_copy => 0, cascade_delete => 0…
romel
  • 97
  • 5
0
votes
2 answers

DBIx::Class has_one <-> might_have relationship

I'm trying to set up a database, the relevant bits of which are shown below. I'm using SQLite3 (3.8.8.3-1) on Arch Linux, with DBIx::Class 0.082820. It's part of a simple book-keeping system. An invoice line has_one transaction, but a transaction…
Chris Dennis
  • 995
  • 7
  • 16