Git Product home page Git Product logo

dbix-class-storage-dbi-mariadb's Introduction

DBIx::Class::Storage::DBI::MariaDB

Storage::DBI class implementing MariaDB specifics

Description

This module adds support for MariaDB in the DBIx::Class ORM. It supports exactly the same parameters as the DBIx::Class::Storage::DBI::mysql module, so check that for further documentation.

Installation

$ cpanm DBIx::Class::Storage::DBI::MariaDB

Usage

Similar to other storage modules that are builtin to DBIx::Class, all you need to do is ensure DBIx::Class::Storage::DBI::MariaDB is loaded and specify MariaDB in the DSN. For example:

package MyApp::Schema;
use base 'DBIx::Class::Schema';

# register classes
# ...
# load mariadb storage
__PACKAGE__->ensure_class_loaded('DBIx::Class::Storage::DBI::MariaDB');

package MyApp;
use MyApp::Schema;

my $dsn = "dbi:MariaDB:database=mydb";
my $user = "noone";
my $pass = "topsecret";
my $schema = MyApp::Schema->connect($dsn, $user, $pass);

Copyright and License

Copyright (C) 2023 Siemplexus

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

dbix-class-storage-dbi-mariadb's People

Contributors

antoniskalou avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

dbix-class-storage-dbi-mariadb's Issues

Missing set_primary_key() from schema files created by DBIx::Class::Schema::Loader

I am not sure if this issue is your responsibility or DBIx::Class's, but here it is:

I have changed DB from MySQL to MariaDB. I am also using DBIx::Class. So, I am using DBIx::Class::Storage::DBI::MariaDB you kindly provided in order to take care of the missing loader for MariaDB.

I have noticed that in the produced schema files with MySQL loader the primary key is set explicitly with this: __PACKAGE__->set_primary_key("id");. But with MariaDB loader the said declaration is missing and now I have:

__PACKAGE__->add_unique_constraint(
  "PRIMARY",

    [
      "id",
    ],
);

The above perhaps are equivalent but DBIx::Class complains with:

Error:  {UNKNOWN}: DBIx::Class::ResultSource::_pri_cols_or_die(): Operation requires a primary key to be declared on 'MyApp::Schema::XYZ' via set_primary_key ...

As if there is no primary key set.

This error disappears when I explicitly add a __PACKAGE__->set_primary_key("id"); in the custom-code section of the schema file.

EDIT after 30mins: Furthermore the primary key set via the constraint is not auto-incremented even if my SQL is something like:

CREATE TABLE IF NOT EXISTS XYZ (
        id mediumint unsigned NOT NULL primary key auto_increment,
        ...
) AUTO_INCREMENT=1;

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.