No subject


Sun Nov 20 20:48:46 GMT 2022


```
Schema Loader version 0.07049
Database: postgresql/jammy 14+238
OS: Linux ubuntu-jammy 5.15.0-25-generic
Example script: See below
Table schema:  See below

Issue: repeated warnings that the perhaps I " forgot to set its 'is_auto_increment' attribute during add_columns()?"
But Schema Loader doesn't recognise uuid_generate_v4() as setting the primary key when analysing existing table

How do I get Schema Loader to recognise that there is a default value for the primary key?


Example warning:

DBIx::Class::Storage::DBI::insert(): Missing value for primary key column 'id' on POSTGRES_TABLE - perhaps you forgot to set its 'is_auto_increment' attribute during add_columns()? Treating 'id' implicitly as an autoinc, and attempting value retrieval at PERL_CODE_LINE


Postgres Schema for Table "Invoice"

                               Table "public.invoice"
  Column  |            Type             | Collation | Nullable |      Default
----------+-----------------------------+-----------+----------+--------------------
 id       | uuid                        |           | not null | uuid_generate_v4()
 created  | timestamp without time zone |           | not null | now()
 modified | timestamp without time zone |           | not null | now()
 amount   | money                       |           | not null |
 currency | character varying(3)        |           | not null |
 is_paid  | boolean                     |           | not null | false
 user_id  | integer                     |           | not null |
Indexes:
    "invoice_pkey" PRIMARY KEY, btree (id)
    "invoice_unique_id" UNIQUE CONSTRAINT, btree (id)





Calling script (functional part).

use DBIx::Class::Schema::Loader qw/ make_schema_at /;
make_schema_at(
    'Series::Schema',
    {   components     => ["InflateColumn::DateTime"],
        debug          => 0,
        dump_directory => './lib',
        moniker_map    => \&moniker,

    },
    [ $sql_db->{db_dsn}, $sql_db->{db_username}, $sql_db->{db_password}, {} ],
);

sub moniker {
    my $table = shift;
    my $result;
    if ( $table eq 'user_table' ) {
        $result = 'User';
    }
    elsif ( $table eq 'group_table' ) {
        $result = 'Group';
    }
    else {
        $result = join q{}, map {ucfirst} split /_/, $table;
    }
    return $result;
} ## end sub moniker
```


-- 
Reply to this email directly or view it on GitHub:
https://github.com/dbsrgits/dbix-class-schema-loader/issues/28
You are receiving this because you are subscribed to this thread.

Message ID: <dbsrgits/dbix-class-schema-loader/issues/28 at github.com>
----==_mimepart_637a92a8ee177_9167c6701800544
Content-Type: text/html;
 charset=UTF-8
Content-Transfer-Encoding: 7bit

<p></p>
<p dir="auto">Migrated from <a href="https://rt.cpan.org/Ticket/Display.html?id=143291" rel="nofollow">rt.cpan.org#143291</a> (status was 'new')</p>
<p dir="auto">Requestors:</p>
<ul dir="auto">
<li><a href="mailto:bruins at hal9000.net.au">bruins at hal9000.net.au</a></li>
</ul>
<p dir="auto">From <a href="mailto:bruins at hal9000.net.au">bruins at hal9000.net.au</a> on 2022-06-14 10:40:43<br>
:</p>
<pre class="notranslate"><code class="notranslate">Schema Loader version 0.07049
Database: postgresql/jammy 14+238
OS: Linux ubuntu-jammy 5.15.0-25-generic
Example script: See below
Table schema:  See below

Issue: repeated warnings that the perhaps I " forgot to set its 'is_auto_increment' attribute during add_columns()?"
But Schema Loader doesn't recognise uuid_generate_v4() as setting the primary key when analysing existing table

How do I get Schema Loader to recognise that there is a default value for the primary key?


Example warning:

DBIx::Class::Storage::DBI::insert(): Missing value for primary key column 'id' on POSTGRES_TABLE - perhaps you forgot to set its 'is_auto_increment' attribute during add_columns()? Treating 'id' implicitly as an autoinc, and attempting value retrieval at PERL_CODE_LINE


Postgres Schema for Table "Invoice"

                               Table "public.invoice"
  Column  |            Type             | Collation | Nullable |      Default
----------+-----------------------------+-----------+----------+--------------------
 id       | uuid                        |           | not null | uuid_generate_v4()
 created  | timestamp without time zone |           | not null | now()
 modified | timestamp without time zone |           | not null | now()
 amount   | money                       |           | not null |
 currency | character varying(3)        |           | not null |
 is_paid  | boolean                     |           | not null | false
 user_id  | integer                     |           | not null |
Indexes:
    "invoice_pkey" PRIMARY KEY, btree (id)
    "invoice_unique_id" UNIQUE CONSTRAINT, btree (id)





Calling script (functional part).

use DBIx::Class::Schema::Loader qw/ make_schema_at /;
make_schema_at(
    'Series::Schema',
    {   components     =&gt; ["InflateColumn::DateTime"],
        debug          =&gt; 0,
        dump_directory =&gt; './lib',
        moniker_map    =&gt; \&amp;moniker,

    },
    [ $sql_db-&gt;{db_dsn}, $sql_db-&gt;{db_username}, $sql_db-&gt;{db_password}, {} ],
);

sub moniker {
    my $table = shift;
    my $result;
    if ( $table eq 'user_table' ) {
        $result = 'User';
    }
    elsif ( $table eq 'group_table' ) {
        $result = 'Group';
    }
    else {
        $result = join q{}, map {ucfirst} split /_/, $table;
    }
    return $result;
} ## end sub moniker
</code></pre>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">&mdash;<br />Reply to this email directly, <a href="https://github.com/dbsrgits/dbix-class-schema-loader/issues/28">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AACJ4AXBG2RM2QKPYWGFUDDWJKFCRANCNFSM6AAAAAASGAU3KI">unsubscribe</a>.<br />You are receiving this because you are subscribed to this thread.<img src="https://github.com/notifications/beacon/AACJ4AVYRSWGBWJC3FCUVE3WJKFCRA5CNFSM6AAAAAASGAU3KKWGG33NNVSW45C7OR4XAZNFJFZXG5LFVJRW63LNMVXHIX3JMTHFNWFO4I.gif" height="1" width="1" alt="" /><span style="color: transparent; font-size: 0; display: none; visibility: hidden; overflow: hidden; opacity: 0; width: 0; height: 0; max-width: 0; max-height: 0; mso-hide: all">Message ID: <span>&lt;dbsrgits/dbix-class-schema-loader/issues/28</span><span>@</span><span>github</span><span>.</span><span>com&gt;</span></span></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/dbsrgits/dbix-class-schema-loader/issues/28",
"url": "https://github.com/dbsrgits/dbix-class-schema-loader/issues/28",
"name": "View Issue"
},
"description": "View this Issue on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>
----==_mimepart_637a92a8ee177_9167c6701800544--



More information about the DBIx-Class-Devel mailing list