.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.42) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "DBSchema::Column 3pm" .TH DBSchema::Column 3pm "2022-09-10" "perl v5.34.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" DBIx::DBSchema::Column \- Column objects .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use DBIx::DBSchema::Column; \& \& #named params with a hashref (preferred) \& $column = new DBIx::DBSchema::Column ( { \& \*(Aqname\*(Aq => \*(Aqcolumn_name\*(Aq, \& \*(Aqtype\*(Aq => \*(Aqvarchar\*(Aq \& \*(Aqnull\*(Aq => \*(AqNOT NULL\*(Aq, \& \*(Aqlength\*(Aq => 64, \& \*(Aqdefault\*(Aq => \*(Aq\*(Aq, \& \*(Aqlocal\*(Aq => \*(Aq\*(Aq, \& } ); \& \& #list \& $column = new DBIx::DBSchema::Column ( $name, $sql_type, $nullability, $length, $default, $local ); \& \& $name = $column\->name; \& $column\->name( \*(Aqname\*(Aq ); \& \& $sql_type = $column\->type; \& $column\->type( \*(Aqsql_type\*(Aq ); \& \& $null = $column\->null; \& $column\->null( \*(AqNULL\*(Aq ); \& $column\->null( \*(AqNOT NULL\*(Aq ); \& $column\->null( \*(Aq\*(Aq ); \& \& $length = $column\->length; \& $column\->length( \*(Aq10\*(Aq ); \& $column\->length( \*(Aq8,2\*(Aq ); \& \& $default = $column\->default; \& $column\->default( \*(AqRoo\*(Aq ); \& \& $sql_line = $column\->line; \& $sql_line = $column\->line($datasrc); \& \& $sql_add_column = $column\->sql_add_column; \& $sql_add_column = $column\->sql_add_column($datasrc); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" DBIx::DBSchema::Column objects represent columns in tables (see DBIx::DBSchema::Table). .SH "METHODS" .IX Header "METHODS" .IP "new \s-1HASHREF\s0" 4 .IX Item "new HASHREF" .PD 0 .IP "new [ name [ , type [ , null [ , length [ , default [ , local ] ] ] ] ] ]" 4 .IX Item "new [ name [ , type [ , null [ , length [ , default [ , local ] ] ] ] ] ]" .PD Creates a new DBIx::DBSchema::Column object. Takes a hashref of named parameters, or a list. \fBname\fR is the name of the column. \fBtype\fR is the \s-1SQL\s0 data type. \fBnull\fR is the nullability of the column (intrepreted using Perl's rules for truth, with one exception: `\s-1NOT NULL\s0' is false). \fBlength\fR is the \&\s-1SQL\s0 length of the column. \fBdefault\fR is the default value of the column. \&\fBlocal\fR is reserved for database-specific information. .Sp Note: If you pass a scalar reference as the \fBdefault\fR rather than a scalar value, it will be dereferenced and quoting will be forced off. This can be used to pass \s-1SQL\s0 functions such as \f(CW\*(C`now()\*(C'\fR or explicit empty strings as \f(CW\*(Aq\*(Aq\fR as defaults. .IP "name [ \s-1NAME\s0 ]" 4 .IX Item "name [ NAME ]" Returns or sets the column name. .IP "type [ \s-1TYPE\s0 ]" 4 .IX Item "type [ TYPE ]" Returns or sets the column type. .IP "null [ \s-1NULL\s0 ]" 4 .IX Item "null [ NULL ]" Returns or sets the column null flag (the empty string is equivalent to `\s-1NOT NULL\s0') .IP "length [ \s-1LENGTH\s0 ]" 4 .IX Item "length [ LENGTH ]" Returns or sets the column length. .IP "default [ \s-1LOCAL\s0 ]" 4 .IX Item "default [ LOCAL ]" Returns or sets the default value. .IP "local [ \s-1LOCAL\s0 ]" 4 .IX Item "local [ LOCAL ]" Returns or sets the database-specific field. .IP "table_obj [ \s-1TABLE_OBJ\s0 ]" 4 .IX Item "table_obj [ TABLE_OBJ ]" Returns or sets the table object (see DBIx::DBSchema::Table). Typically set internally when a column object is added to a table object. .IP "table_name" 4 .IX Item "table_name" Returns the table name, or the empty string if this column has not yet been assigned to a table. .IP "line [ \s-1DATABASE_HANDLE\s0 | \s-1DATA_SOURCE\s0 [ \s-1USERNAME PASSWORD\s0 [ \s-1ATTR\s0 ] ] ]" 4 .IX Item "line [ DATABASE_HANDLE | DATA_SOURCE [ USERNAME PASSWORD [ ATTR ] ] ]" Returns an \s-1SQL\s0 column definition. .Sp The data source can be specified by passing an open \s-1DBI\s0 database handle, or by passing the \s-1DBI\s0 data source name, username and password. .Sp Although the username and password are optional, it is best to call this method with a database handle or data source including a valid username and password \- a \s-1DBI\s0 connection will be opened and the quoting and type mapping will be more reliable. .Sp If passed a \s-1DBI\s0 data source (or handle) such as `DBI:mysql:database' or `DBI:Pg:dbname=database', will use syntax specific to that database engine. Currently supported databases are MySQL and PostgreSQL. Non-standard syntax for other engines (if applicable) may also be supported in the future. .IP "quoted_default \s-1DATABASE_HANDLE\s0" 4 .IX Item "quoted_default DATABASE_HANDLE" Returns this column's default value quoted for the database. .IP "sql_add_column [ \s-1DBH\s0 ]" 4 .IX Item "sql_add_column [ DBH ]" Returns \s-1SQL\s0 to add this column to an existing table. (To create a new table, see \*(L"sql_create_table\*(R" in DBIx::DBSchema::Table instead.) .Sp \&\s-1NOTE:\s0 This interface has changed in 0.41 .Sp Returns two listrefs. The first is a list of column alteration \s-1SQL\s0 fragments for an \s-1ALTER TABLE\s0 statement. The second is a list of full \s-1SQL\s0 statements that should be run after the \s-1ALTER TABLE\s0 statement. .Sp The data source can be specified by passing an open \s-1DBI\s0 database handle, or by passing the \s-1DBI\s0 data source name, username and password. .Sp Although the username and password are optional, it is best to call this method with a database handle or data source including a valid username and password \- a \s-1DBI\s0 connection will be opened and the quoting and type mapping will be more reliable. .Sp If passed a \s-1DBI\s0 data source (or handle) such as `DBI:Pg:dbname=database', will use PostgreSQL-specific syntax. Non-standard syntax for other engines (if applicable) may also be supported in the future. .IP "sql_alter_column \s-1PROTOTYPE_COLUMN\s0 [ \s-1DATABASE_HANDLE\s0 | \s-1DATA_SOURCE\s0 [ \s-1USERNAME PASSWORD\s0 [ \s-1ATTR\s0 ] ] ]" 4 .IX Item "sql_alter_column PROTOTYPE_COLUMN [ DATABASE_HANDLE | DATA_SOURCE [ USERNAME PASSWORD [ ATTR ] ] ]" Returns \s-1SQL\s0 to alter this column so that it is identical to the provided prototype column, also a DBIx::DBSchema::Column object. .Sp \&\s-1NOTE:\s0 This interface has changed in 0.41 .Sp Returns two listrefs. The first is a list of column alteration \s-1SQL\s0 fragments for an \s-1ALTER TABLE\s0 statement. The second is a list of full \s-1SQL\s0 statements that should be run after the \s-1ALTER TABLE\s0 statement. .Sp Optionally, the data source can be specified by passing an open \s-1DBI\s0 database handle, or by passing the \s-1DBI\s0 data source name, username and password. .Sp If passed a \s-1DBI\s0 data source (or handle) such as `DBI:Pg:dbname=database', will use PostgreSQL-specific syntax. Non-standard syntax for other engines (if applicable) may also be supported in the future. .Sp If not passed a data source (or handle), or if there is no driver for the specified database, will attempt to use generic \s-1SQL\s0 syntax. .IP "sql_drop_column [ \s-1DBH\s0 ]" 4 .IX Item "sql_drop_column [ DBH ]" Returns \s-1SQL\s0 to drop this column from an existing table. .Sp \&\s-1NOTE:\s0 This interface has changed in 0.41 .Sp Returns a list of column alteration \s-1SQL\s0 fragments for an \s-1ALTER TABLE\s0 statement. .Sp The optional database handle or \s-1DBI\s0 data source/username/password is not yet used. .SH "AUTHOR" .IX Header "AUTHOR" Ivan Kohler .SH "COPYRIGHT" .IX Header "COPYRIGHT" Copyright (c) 2000\-2006 Ivan Kohler Copyright (c) 2007\-2013 Freeside Internet Services, Inc. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. .SH "BUGS" .IX Header "BUGS" The \fBnew()\fR method should warn that \&\*(L"Old-style \f(CW$class\fR creation without named parameters is deprecated!\*(R" .PP Better documentation is needed for sql_add_column .PP \&\fBsql_alter_column()\fR has database-specific foo that should be abstracted info DBIx::DBSchema::DBD::Pg .PP nullify_default option should be documented .SH "SEE ALSO" .IX Header "SEE ALSO" DBIx::DBSchema::Table, DBIx::DBSchema, DBIx::DBSchema::DBD, \s-1DBI\s0