1DBSchema::DBD(3)      User Contributed Perl Documentation     DBSchema::DBD(3)
2
3
4

NAME

6       DBIx::DBSchema::DBD - DBIx::DBSchema Driver Writer's Guide and Base
7       Class
8

SYNOPSIS

10         perldoc DBIx::DBSchema::DBD
11
12         package DBIx::DBSchema::DBD::FooBase
13         use DBIx::DBSchema::DBD;
14         @ISA = qw(DBIx::DBSchema::DBD);
15

DESCRIPTION

17       Drivers should be named DBIx::DBSchema::DBD::DatabaseName, where
18       DatabaseName is the same as the DBD:: driver for this database.
19       Drivers should implement the following class methods:
20
21       columns CLASS DBI_DBH TABLE
22           Given an active DBI database handle, return a listref of listrefs
23           (see perllol), each containing six elements: column name, column
24           type, nullability, column length, column default, and a field
25           reserved for driver-specific use.
26
27       column CLASS DBI_DBH TABLE COLUMN
28           Same as columns above, except return the listref for a single
29           column.  You can inherit from DBIx::DBSchema::DBD to provide this
30           function.
31
32       primary_key CLASS DBI_DBH TABLE
33           Given an active DBI database handle, return the primary key for the
34           specified table.
35
36       unique CLASS DBI_DBH TABLE
37           Deprecated method - see the indices method for new drivers.
38
39           Given an active DBI database handle, return a hashref of unique
40           indices.  The keys of the hashref are index names, and the values
41           are arrayrefs which point a list of column names for each.  See
42           "HASHES OF LISTS" in perldsc and DBIx::DBSchema::Index.
43
44       index CLASS DBI_DBH TABLE
45           Deprecated method - see the indices method for new drivers.
46
47           Given an active DBI database handle, return a hashref of (non-
48           unique) indices.  The keys of the hashref are index names, and the
49           values are arrayrefs which point a list of column names for each.
50           See "HASHES OF LISTS" in perldsc and DBIx::DBSchema::Index.
51
52       indices CLASS DBI_DBH TABLE
53           Given an active DBI database handle, return a hashref of all
54           indices, both unique and non-unique.  The keys of the hashref are
55           index names, and the values are again hashrefs with the following
56           keys:
57
58           name - Index name (redundant)
59           using - Optional index method
60           unique - Boolean indicating whether or not this is a unique index
61           columns - List reference of column names (or expressions)
62
63           (See FS::DBIx::DBSchema::Index)
64
65           New drivers are advised to implement this method, and existing
66           drivers are advised to (eventually) provide this method instead of
67           index and unique.
68
69           For backwards-compatibility with current drivers, the base
70           DBIx::DBSchema::DBD class provides an indices method which uses the
71           old index and unique methods to provide this data.
72
73       default_db_catalog
74           Returns the default database catalog for the DBI table_info
75           command.  Inheriting from DBIx::DBSchema::DBD will provide the
76           default empty string.
77
78       default_db_schema
79           Returns the default database schema for the DBI table_info command.
80           Inheriting from DBIx::DBSchema::DBD will provide the default empty
81           string.
82
83       constraints CLASS DBI_DBH TABLE
84           Given an active DBI database handle, return the constraints
85           (currently, foreign keys) for the specified table, as a list of
86           hash references.
87
88           Each hash reference has the following keys:
89
90           constraint - contraint name
91           columns - List refrence of column names
92           table - Foreign taable name
93           references - List reference of column names in foreign table
94           match -
95           on_delete -
96           on_update -
97       column_callback DBH TABLE_NAME COLUMN_OBJ
98           Optional callback for driver-specific overrides to SQL column
99           definitions.
100
101           Should return a hash reference, empty for no action, or with one or
102           more of the following keys defined:
103
104           effective_type - Optional type override used during column
105           creation.
106
107           explicit_null - Set true to have the column definition declare NULL
108           columns explicitly
109
110           effective_default - Optional default override used during column
111           creation.
112
113           effective_local - Optional local override used during column
114           creation.
115
116       add_column_callback DBH TABLE_NAME COLUMN_OBJ
117           Optional callback for additional SQL statments to be called when
118           adding columns to an existing table.
119
120           Should return a hash reference, empty for no action, or with one or
121           more of the following keys defined:
122
123           effective_type - Optional type override used during column
124           creation.
125
126           effective_null - Optional nullability override used during column
127           creation.
128
129           sql_after - Array reference of SQL statements to be executed after
130           the column is added.
131
132       alter_column_callback DBH TABLE_NAME OLD_COLUMN_OBJ NEW_COLUMN_OBJ
133           Optional callback for overriding the SQL statments to be called
134           when altering columns to an existing table.
135
136           Should return a hash reference, empty for no action, or with one or
137           more of the following keys defined:
138
139           sql_alter - Alter SQL statement(s) for changing everything about a
140           column.  Specifying this overrides processing of individual changes
141           (type, nullability, default, etc.).
142
143           sql_alter_type - Alter SQL statement(s) for changing type and
144           length (there is no default).
145
146           sql_alter_null - Alter SQL statement(s) for changing nullability to
147           be used instead of the default.
148
149       column_value_needs_quoting COLUMN_OBJ
150           Optional callback for determining if a column's default value
151           require quoting.  Returns true if it does, false otherwise.
152

TYPE MAPPING

154       You can define a %typemap array for your driver to map "standard" data
155       types to database-specific types.  For example, the MySQL TIMESTAMP
156       field has non-standard auto-updating semantics; the MySQL DATETIME type
157       is what other databases and the ODBC standard call TIMESTAMP, so one of
158       the entries in the MySQL %typemap is:
159
160         'TIMESTAMP' => 'DATETIME',
161
162       Another example is the Pg %typemap which maps the standard types BLOB
163       and LONG VARBINARY to the Pg-specific BYTEA:
164
165         'BLOB' => 'BYTEA',
166         'LONG VARBINARY' => 'BYTEA',
167
168       Make sure you use all uppercase-keys.
169

AUTHOR

171       Ivan Kohler <ivan-dbix-dbschema@420.am>
172
174       Copyright (c) 2000-2005 Ivan Kohler Copyright (c) 2007-2017 Freeside
175       Internet Services, Inc.  All rights reserved.  This program is free
176       software; you can redistribute it and/or modify it under the same terms
177       as Perl itself.
178

BUGS

SEE ALSO

181       DBIx::DBSchema, DBIx::DBSchema::DBD::mysql, DBIx::DBSchema::DBD::Pg,
182       DBIx::DBSchema::Index, DBI, DBI::DBD, perllol, "HASHES OF LISTS" in
183       perldsc
184
185
186
187perl v5.36.0                      2023-01-20                  DBSchema::DBD(3)
Impressum