DBSchema::Column(3pm) | User Contributed Perl Documentation | DBSchema::Column(3pm) |
DBIx::DBSchema::Column - Column objects
use DBIx::DBSchema::Column; #named params with a hashref (preferred) $column = new DBIx::DBSchema::Column ( { 'name' => 'column_name', 'type' => 'varchar' 'null' => 'NOT NULL', 'length' => 64, 'default' => '', 'local' => '', } ); #list $column = new DBIx::DBSchema::Column ( $name, $sql_type, $nullability, $length, $default, $local ); $name = $column->name; $column->name( 'name' ); $sql_type = $column->type; $column->type( 'sql_type' ); $null = $column->null; $column->null( 'NULL' ); $column->null( 'NOT NULL' ); $column->null( '' ); $length = $column->length; $column->length( '10' ); $column->length( '8,2' ); $default = $column->default; $column->default( 'Roo' ); $sql_line = $column->line; $sql_line = $column->line($datasrc); $sql_add_column = $column->sql_add_column; $sql_add_column = $column->sql_add_column($datasrc);
DBIx::DBSchema::Column objects represent columns in tables (see DBIx::DBSchema::Table).
Note: If you pass a scalar reference as the default rather than a scalar value, it will be dereferenced and quoting will be forced off. This can be used to pass SQL functions such as "now()" or explicit empty strings as '' as defaults.
The data source can be specified by passing an open DBI database handle, or by passing the DBI data source name, username and password.
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 DBI connection will be opened and the quoting and type mapping will be more reliable.
If passed a DBI 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.
NOTE: This interface has changed in 0.41
Returns two listrefs. The first is a list of column alteration SQL fragments for an ALTER TABLE statement. The second is a list of full SQL statements that should be run after the ALTER TABLE statement.
The data source can be specified by passing an open DBI database handle, or by passing the DBI data source name, username and password.
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 DBI connection will be opened and the quoting and type mapping will be more reliable.
If passed a DBI 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.
NOTE: This interface has changed in 0.41
Returns two listrefs. The first is a list of column alteration SQL fragments for an ALTER TABLE statement. The second is a list of full SQL statements that should be run after the ALTER TABLE statement.
Optionally, the data source can be specified by passing an open DBI database handle, or by passing the DBI data source name, username and password.
If passed a DBI 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.
If not passed a data source (or handle), or if there is no driver for the specified database, will attempt to use generic SQL syntax.
NOTE: This interface has changed in 0.41
Returns a list of column alteration SQL fragments for an ALTER TABLE statement.
The optional database handle or DBI data source/username/password is not yet used.
Ivan Kohler <ivan-dbix-dbschema@420.am>
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.
The new() method should warn that "Old-style $class creation without named parameters is deprecated!"
Better documentation is needed for sql_add_column
sql_alter_column() has database-specific foo that should be abstracted info DBIx::DBSchema::DBD::Pg
nullify_default option should be documented
DBIx::DBSchema::Table, DBIx::DBSchema, DBIx::DBSchema::DBD, DBI
2022-09-10 | perl v5.36.0 |