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

Use DBIx::Class without loading all tables

They say in comments that DBIx::Class can be used without loading all tables. How to use DBIx::Class without loading all tables? (I need this for performance reasons.)
porton
  • 5,214
  • 11
  • 47
  • 95
0
votes
2 answers

DBIx::Class infinite results

Before I describe the details, the problem is, I run a $c->model('ResultName')->search({k=>v}) and when I loop on the results of it's has_many relation, there's only one in the database, yet it loops forever. I've tried googling and found one…
Felix
  • 699
  • 2
  • 9
  • 24
0
votes
1 answer

recursively inflate columns

I have a many to many relationship between 3 tables User, Role and Project. This results in a mapping table User_has_Roles_has_Projects Now In my code I can get to the mapping table by…
vijayvithal
  • 551
  • 1
  • 5
  • 13
0
votes
1 answer

How to determine if a DBIx::Class::Row has a relationship already fetched?

Here's my situation: we have master tables with relationships to attribute tables. Sometimes, we fetch a row all by itself: my $row = $rs->search({ some_key => 'some_value' })->first; and sometimes we join one or more tables: my $row =…
Murwiz
  • 156
  • 1
  • 7
0
votes
1 answer

Automatically updating related rows with DBIx::Class

In the context of a REST API, I've been using DBIx::Class to create related rows, i.e. POST /artist { "name":"Bob Marley", "cds":[{"title":"Exodus"}] } That ultimately calls $artist->new($data)->insert() which creates an Artist AND creates the…
Ryley
  • 21,046
  • 2
  • 67
  • 81
0
votes
1 answer

Mysql function to DBIx::Class translation

I want to convert this mysql/select query with function to DBIx::Class but I can't construct it the right way. Mysql/query with function: mysql> select * from sold_products where date_sub(curdate(), interval 100 day) <= date; Result query…
lupin
  • 1
0
votes
2 answers

Setting DBI LongReadLen in dbicdump

I'm trying to dump my Oracle schema but unfortunately hit with the ORA-24345 error. From my reading it looks like I need to set the LongReadLen option on the database handle. However, I cannot find the way to set this parameter in dbicdump.…
kuronue
  • 306
  • 2
  • 8
0
votes
0 answers

Using Mojolicious: access a perl hash, passed through an ajax call as json, in javascript

How can I access my json hash by key? I have an ajax call function populate_technician_info(public_info_id) { var advantage_id = $('#admin_info').data('advantage_id'); $.ajax({ type: 'POST', url: '/ajax/get_technician_info', data:…
gregnnylf94
  • 370
  • 3
  • 16
0
votes
1 answer

How to reset column value to DEFAULT when updating it with DBIx::Class?

When updating column in postgresql we can reset it value to DEFAULT UPDATE table SET column = DEFAULT Is there analogue in DBIx::Class? Just like this: $schame->result_set( 'table' )->update({ column => DEFAULT })
Eugen Konkov
  • 22,193
  • 17
  • 108
  • 158
0
votes
1 answer

getting error DBI_DRIVER env var not set while running dbicdump

I was testing to dump the DBIx::Class for my sample sqlite database on the windows 7 machine. I have installed DBIx::Class::Schema::Loader , along with DBI and DBD::SQLite module , but when I am using the script dbicdump it giving the below…
made_in_india
  • 2,109
  • 5
  • 40
  • 63
0
votes
1 answer

How can I specify index value order when calling SQL::Translator::Table's add_index function?

I am using DBIx::Class to create tables and their indexes and so calling SQL::Translator::Table add_index() but I'd like to be able to specify a value order on some of the columns, like this: CREATE INDEX myindex ON mytable ( username ASC, …
andymurd
  • 821
  • 8
  • 10
0
votes
3 answers

index is not visible to DBIx::Class

I have this small perl code which is going to add a record to a table but I am confused why DBIC is not able to see the primary key? I am not able to find any answer anywhere. First the names of table and columns were camelCase, which I then changed…
rajeev
  • 1,275
  • 7
  • 27
  • 45
0
votes
1 answer

Why `select` does not replace existing columns?

DOC for select attribute: select indicates which columns should be selected from the storage This works as expected: $rs->search( undef, { select => [ 'me.id', 'me.user_id' ] } ) ->search( undef, { select => [ 'me.role_id' ] } ) $rs->as_query;…
Eugen Konkov
  • 22,193
  • 17
  • 108
  • 158
0
votes
1 answer

Why does JSON say the serialisation hook is missing?

Run cpanm --look DBIx::Class ; cd examples/Schema/ to use the example database. use 5.024; use strictures; use JSON::MaybeXS qw(encode_json); use MyApp::Schema qw(); use Sub::Install qw(); my $s =…
daxim
  • 39,270
  • 4
  • 65
  • 132
0
votes
1 answer

How to ORDER before GROUP with DBIx::Class

I've got a simple temporal table that looks like this: Table: item_approval item user status modified 2 fred approved 2010-12-01 00:00:00 3 fred approved 2010-12-02 00:00:00 4 fred disapproved 2010-12-03…
Sir Robert
  • 4,686
  • 7
  • 41
  • 57