File: map-record-name-conflict.pl

package info (click to toggle)
librose-db-object-perl 1%3A0.815-1%2Bdeb10u1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 5,048 kB
  • sloc: perl: 79,670; sql: 28; makefile: 7
file content (93 lines) | stat: -rwxr-xr-x 1,353 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/usr/bin/perl

use Rose::DB;

Rose::DB->register_db(driver => 'sqlite');

package JCS::A;
use base 'Rose::DB::Object';

__PACKAGE__->meta->setup
(
  columns => [ qw(id a) ],

  relationships =>
  [
    bs =>
    {
      type => 'many to many',
      map_class => 'JCS::AtoB',
      manager_args => { with_map_records => 1 },
    },
  ],
);

package JCS::B;
use base 'Rose::DB::Object';

__PACKAGE__->meta->setup
(
  columns => [ qw(id b) ],
);

package JCS::C;
use base 'Rose::DB::Object';

__PACKAGE__->meta->setup
(
  columns => [ qw(id c) ],

  relationships =>
  [
    bs =>
    {
      type => 'many to many',
      map_class => 'JCS::CtoB',
      manager_args => { with_map_records => 1 },
    },
  ],
);

package JCS::AtoB;
use base 'Rose::DB::Object';

__PACKAGE__->meta->setup
(
  columns => [ qw(id a_id b_id) ],
  foreign_keys =>
  [
    a_id =>
    {
      class => 'JCS::A',
      key_columns => { a_id => 'id' },
    },

    b_id =>
    {
      class => 'JCS::B',
      key_columns => { b_id => 'id' },
    }
  ],
);

package JCS::CtoB;
use base 'Rose::DB::Object';

__PACKAGE__->meta->setup
(
  columns => [ qw(id c_id b_id) ],
  foreign_keys =>
  [
    a_id =>
    {
      class => 'JCS::C',
      key_columns => { c_id => 'id' },
    },

    b_id =>
    {
      class => 'JCS::B',
      key_columns => { b_id => 'id' },
    }
  ],
);