Class: ColumnInfo
- Inherits:
-
Hash
- Object
- Hash
- ColumnInfo
- Defined in:
- lib/dbi/columninfo.rb
Instance Method Summary collapse
-
#default ⇒ Object
Returns the default value for the column, or nil if not set.
-
#default=(val) ⇒ Object
Sets the default value for the column.
-
#indexed ⇒ Object
(also: #indexed?, #is_indexed?)
Returns whether or not the column is indexed.
-
#indexed=(val) ⇒ Object
Sets whether or not the column is indexed.
-
#initialize(hash = nil) ⇒ ColumnInfo
constructor
Creates and returns a ColumnInfo object.
-
#name ⇒ Object
Returns the column’s name.
-
#name=(val) ⇒ Object
Sets the column’s name.
-
#nullable ⇒ Object
(also: #nullable?, #is_nullable?)
Returns whether or not the column is may contain a NULL.
-
#nullable=(val) ⇒ Object
Sets whether or not the column may contain a NULL.
-
#precision ⇒ Object
(also: #size, #length)
Returns the precision, i.e.
-
#precision=(val) ⇒ Object
(also: #size=, #length=)
Sets the precision, i.e.
-
#primary ⇒ Object
(also: #primary?, #is_primary?)
Returns whether or not the column is a primary key.
-
#primary=(val) ⇒ Object
Sets whether or not the column is a primary key.
-
#scale ⇒ Object
(also: #decimal_digits)
Returns the number of digits from right.
-
#scale=(val) ⇒ Object
(also: #decimal_digits=)
Sets the number of digits from right.
-
#sql_type ⇒ Object
Returns a portable integer representation of the column’s type.
-
#sql_type=(val) ⇒ Object
Sets the integer representation for the column’s type.
-
#type_name ⇒ Object
A string representation of the column’s type, e.g.
-
#type_name=(val) ⇒ Object
Sets the representation for the column’s type.
-
#unique ⇒ Object
(also: #unique?, #is_unique)
Returns whether or not data in the column must be unique.
-
#unique=(val) ⇒ Object
Sets whether or not data in the column must be unique.
Constructor Details
#initialize(hash = nil) ⇒ ColumnInfo
Creates and returns a ColumnInfo object. This represents metadata for columns within a given table, such as the data type, whether or not the the column is a primary key, etc.
ColumnInfo is a subclass of Hash.
9 10 11 |
# File 'lib/dbi/columninfo.rb', line 9 def initialize(hash=nil) self.update(hash) if hash end |
Instance Method Details
#default ⇒ Object
Returns the default value for the column, or nil if not set.
87 88 89 |
# File 'lib/dbi/columninfo.rb', line 87 def default self['default'] end |
#default=(val) ⇒ Object
Sets the default value for the column.
92 93 94 |
# File 'lib/dbi/columninfo.rb', line 92 def default=(val) self['default'] = val end |
#indexed ⇒ Object Also known as: indexed?, is_indexed?
Returns whether or not the column is indexed.
107 108 109 |
# File 'lib/dbi/columninfo.rb', line 107 def indexed self['indexed'] end |
#indexed=(val) ⇒ Object
Sets whether or not the column is indexed.
112 113 114 |
# File 'lib/dbi/columninfo.rb', line 112 def indexed=(val) self['indexed'] = 'val' end |
#name ⇒ Object
Returns the column’s name.
14 15 16 |
# File 'lib/dbi/columninfo.rb', line 14 def name self['name'] end |
#name=(val) ⇒ Object
Sets the column’s name.
19 20 21 |
# File 'lib/dbi/columninfo.rb', line 19 def name=(val) self['name'] = val end |
#nullable ⇒ Object Also known as: nullable?, is_nullable?
Returns whether or not the column is may contain a NULL.
97 98 99 |
# File 'lib/dbi/columninfo.rb', line 97 def nullable self['nullable'] end |
#nullable=(val) ⇒ Object
Sets whether or not the column may contain a NULL.
102 103 104 |
# File 'lib/dbi/columninfo.rb', line 102 def nullable=(val) self['nullable'] = val end |
#precision ⇒ Object Also known as: size, length
Returns the precision, i.e. number of bytes or digits.
67 68 69 |
# File 'lib/dbi/columninfo.rb', line 67 def precision self['precision'] end |
#precision=(val) ⇒ Object Also known as: size=, length=
Sets the precision, i.e. number of bytes or digits.
72 73 74 |
# File 'lib/dbi/columninfo.rb', line 72 def precision=(val) self['precision'] = val end |
#primary ⇒ Object Also known as: primary?, is_primary?
Returns whether or not the column is a primary key.
117 118 119 |
# File 'lib/dbi/columninfo.rb', line 117 def primary self['primary'] end |
#primary=(val) ⇒ Object
Sets whether or not the column is a primary key.
122 123 124 |
# File 'lib/dbi/columninfo.rb', line 122 def primary=(val) self['primary'] = val end |
#scale ⇒ Object Also known as: decimal_digits
Returns the number of digits from right.
77 78 79 |
# File 'lib/dbi/columninfo.rb', line 77 def scale self['scale'] end |
#scale=(val) ⇒ Object Also known as: decimal_digits=
Sets the number of digits from right.
82 83 84 |
# File 'lib/dbi/columninfo.rb', line 82 def scale=(val) self['scale'] = val end |
#sql_type ⇒ Object
Returns a portable integer representation of the column’s type. Here are the constant names (under DBI) and their respective values:
SQL_CHAR = 1 SQL_NUMERIC = 2 SQL_DECIMAL = 3 SQL_INTEGER = 4 SQL_SMALLINT = 5 SQL_FLOAT = 6 SQL_REAL = 7 SQL_DOUBLE = 8 SQL_DATE = 9 SQL_TIME = 10 SQL_TIMESTAMP = 11 SQL_VARCHAR = 12
SQL_LONGVARCHAR = -1 SQL_BINARY = -2 SQL_VARBINARY = -3 SQL_LONGVARBINARY = -4 SQL_BIGINT = -5 SQL_BIT = -7 SQL_TINYINT = -6
47 48 49 |
# File 'lib/dbi/columninfo.rb', line 47 def sql_type self['sql_type'] end |
#sql_type=(val) ⇒ Object
Sets the integer representation for the column’s type.
52 53 54 |
# File 'lib/dbi/columninfo.rb', line 52 def sql_type=(val) self['sql_type'] = val end |
#type_name ⇒ Object
A string representation of the column’s type, e.g. ‘date’.
57 58 59 |
# File 'lib/dbi/columninfo.rb', line 57 def type_name self['type_name'] end |
#type_name=(val) ⇒ Object
Sets the representation for the column’s type.
62 63 64 |
# File 'lib/dbi/columninfo.rb', line 62 def type_name=(val) self['type_name'] = val end |
#unique ⇒ Object Also known as: unique?, is_unique
Returns whether or not data in the column must be unique.
127 128 129 |
# File 'lib/dbi/columninfo.rb', line 127 def unique self['unique'] end |
#unique=(val) ⇒ Object
Sets whether or not data in the column must be unique.
132 133 134 |
# File 'lib/dbi/columninfo.rb', line 132 def unique=(val) self['unique'] = val end |