1 package FS::dbdef_column;
12 FS::dbdef_column - Column object
18 $column_object = new FS::dbdef_column ( $name, $sql_type, '' );
19 $column_object = new FS::dbdef_column ( $name, $sql_type, 'NULL' );
20 $column_object = new FS::dbdef_column ( $name, $sql_type, '', $length );
21 $column_object = new FS::dbdef_column ( $name, $sql_type, 'NULL', $length );
23 $name = $column_object->name;
24 $column_object->name ( 'name' );
26 $name = $column_object->type;
27 $column_object->name ( 'sql_type' );
29 $name = $column_object->null;
30 $column_object->name ( 'NOT NULL' );
32 $name = $column_object->length;
33 $column_object->name ( $length );
35 $sql_line = $column->line;
36 $sql_line = $column->line $datasrc;
40 FS::dbdef::column objects represend columns in tables (see L<FS::dbdef_table>).
48 Creates a new FS::dbdef_column object.
53 my($proto,$name,$type,$null,$length)=@_;
55 #croak "Illegal name: $name" if grep $name eq $_, @reserved_words;
57 $null =~ s/^NOT NULL$//i;
59 my $class = ref($proto) || $proto;
67 bless ($self, $class);
73 Returns or sets the column name.
79 if ( defined($value) ) {
80 #croak "Illegal name: $name" if grep $name eq $_, @reserved_words;
81 $self->{'name'} = $value;
89 Returns or sets the column type.
95 if ( defined($value) ) {
96 $self->{'type'} = $value;
104 Returns or sets the column null flag.
110 if ( defined($value) ) {
111 $value =~ s/^NOT NULL$//i;
112 $self->{'null'} = $value;
120 Returns or sets the column length.
126 if ( defined($value) ) {
127 $self->{'length'} = $value;
133 =item line [ $datasrc ]
135 Returns an SQL column definition.
137 If passed a DBI $datasrc specifying L<DBD::mysql>, will use MySQL-specific
138 syntax. Non-standard syntax for other engines (if applicable) may also be
139 supported in the future.
144 my($self,$datasrc)=@_;
145 my($null)=$self->null;
146 $null ||= "NOT NULL" if $datasrc =~ /mysql/; #yucky mysql hack
149 $self->type. ( $self->length ? '('.$self->length.')' : '' ),
160 L<FS::dbdef_table>, L<FS::dbdef>, L<DBI>
164 class for dealing with column definitions
166 ivan@sisd.com 98-apr-17
168 now methods can be used to get or set data ivan@sisd.com 98-may-11
170 mySQL-specific hack for null (what should be default?) ivan@sisd.com 98-jun-2