Class: MysqlPR::Field
- Inherits:
-
Object
- Object
- MysqlPR::Field
- Defined in:
- lib/mysql-pr.rb,
lib/mysql-pr/constants.rb
Overview
Field class
Constant Summary collapse
- TYPE_DECIMAL =
Field type
0- TYPE_TINY =
1- TYPE_SHORT =
2- TYPE_LONG =
3- TYPE_FLOAT =
4- TYPE_DOUBLE =
5- TYPE_NULL =
6- TYPE_TIMESTAMP =
7- TYPE_LONGLONG =
8- TYPE_INT24 =
9- TYPE_DATE =
10- TYPE_TIME =
11- TYPE_DATETIME =
12- TYPE_YEAR =
13- TYPE_NEWDATE =
14- TYPE_VARCHAR =
15- TYPE_BIT =
16- TYPE_NEWDECIMAL =
246- TYPE_ENUM =
247- TYPE_SET =
248- TYPE_TINY_BLOB =
249- TYPE_MEDIUM_BLOB =
250- TYPE_LONG_BLOB =
251- TYPE_BLOB =
252- TYPE_VAR_STRING =
253- TYPE_STRING =
254- TYPE_GEOMETRY =
255- TYPE_CHAR =
TYPE_TINY- TYPE_INTERVAL =
TYPE_ENUM- NOT_NULL_FLAG =
Flag
1- PRI_KEY_FLAG =
2- UNIQUE_KEY_FLAG =
4- MULTIPLE_KEY_FLAG =
8- BLOB_FLAG =
16- UNSIGNED_FLAG =
32- ZEROFILL_FLAG =
64- BINARY_FLAG =
128- ENUM_FLAG =
256- AUTO_INCREMENT_FLAG =
512- TIMESTAMP_FLAG =
1024- SET_FLAG =
2048- NUM_FLAG =
32_768- PART_KEY_FLAG =
16_384- GROUP_FLAG =
32_768- UNIQUE_FLAG =
65_536- BINCMP_FLAG =
131_072
Instance Attribute Summary collapse
-
#charsetnr ⇒ Integer
readonly
Charset id number.
-
#db ⇒ String
readonly
Database name.
-
#decimals ⇒ Integer
readonly
Number of decimals.
-
#default ⇒ String
(also: #def)
readonly
Default value.
-
#flags ⇒ Integer
readonly
Flag.
-
#length ⇒ Integer
readonly
Field length.
-
#max_length ⇒ Integer
Maximum width of the field for the result set.
-
#name ⇒ String
readonly
Field name.
-
#org_name ⇒ String
readonly
Original field name.
-
#org_table ⇒ String
readonly
Original table name.
-
#result ⇒ Object
Returns the value of attribute result.
-
#table ⇒ String
readonly
Table name.
-
#type ⇒ Integer
readonly
Field type.
Instance Method Summary collapse
-
#initialize(packet) ⇒ Field
constructor
A new instance of Field.
- #inspect ⇒ Object
-
#is_not_null? ⇒ Boolean
True if not null field.
-
#is_num? ⇒ Boolean
True if numeric field.
-
#is_pri_key? ⇒ Boolean
True if primary key field.
-
#to_hash ⇒ Hash
(also: #hash)
Field information.
Constructor Details
#initialize(packet) ⇒ Field
571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 |
# File 'lib/mysql-pr.rb', line 571 def initialize(packet) @db = packet.db @table = packet.table @org_table = packet.org_table @name = packet.name @org_name = packet.org_name @charsetnr = packet.charsetnr @length = packet.length @type = packet.type @flags = packet.flags @decimals = packet.decimals @default = packet.default @flags |= NUM_FLAG if num_type? @max_length = nil @result = nil end |
Instance Attribute Details
#charsetnr ⇒ Integer (readonly)
553 554 555 |
# File 'lib/mysql-pr.rb', line 553 def charsetnr @charsetnr end |
#db ⇒ String (readonly)
543 544 545 |
# File 'lib/mysql-pr.rb', line 543 def db @db end |
#decimals ⇒ Integer (readonly)
561 562 563 |
# File 'lib/mysql-pr.rb', line 561 def decimals @decimals end |
#default ⇒ String (readonly) Also known as: def
563 564 565 |
# File 'lib/mysql-pr.rb', line 563 def default @default end |
#flags ⇒ Integer (readonly)
559 560 561 |
# File 'lib/mysql-pr.rb', line 559 def flags @flags end |
#length ⇒ Integer (readonly)
555 556 557 |
# File 'lib/mysql-pr.rb', line 555 def length @length end |
#max_length ⇒ Integer
623 624 625 626 627 628 629 |
# File 'lib/mysql-pr.rb', line 623 def max_length return @max_length if @max_length @max_length = 0 @result&.calculate_field_max_length @max_length end |
#name ⇒ String (readonly)
549 550 551 |
# File 'lib/mysql-pr.rb', line 549 def name @name end |
#org_name ⇒ String (readonly)
551 552 553 |
# File 'lib/mysql-pr.rb', line 551 def org_name @org_name end |
#org_table ⇒ String (readonly)
547 548 549 |
# File 'lib/mysql-pr.rb', line 547 def org_table @org_table end |
#result ⇒ Object
Returns the value of attribute result.
567 568 569 |
# File 'lib/mysql-pr.rb', line 567 def result @result end |
#table ⇒ String (readonly)
545 546 547 |
# File 'lib/mysql-pr.rb', line 545 def table @table end |
#type ⇒ Integer (readonly)
557 558 559 |
# File 'lib/mysql-pr.rb', line 557 def type @type end |
Instance Method Details
#inspect ⇒ Object
603 604 605 |
# File 'lib/mysql-pr.rb', line 603 def inspect "#<MysqlPR::Field:#{@name}>" end |
#is_not_null? ⇒ Boolean
613 614 615 |
# File 'lib/mysql-pr.rb', line 613 def is_not_null? (@flags & NOT_NULL_FLAG) != 0 end |
#is_num? ⇒ Boolean
608 609 610 |
# File 'lib/mysql-pr.rb', line 608 def is_num? (@flags & NUM_FLAG) != 0 end |
#is_pri_key? ⇒ Boolean
618 619 620 |
# File 'lib/mysql-pr.rb', line 618 def is_pri_key? (@flags & PRI_KEY_FLAG) != 0 end |
#to_hash ⇒ Hash Also known as: hash
589 590 591 592 593 594 595 596 597 598 599 600 |
# File 'lib/mysql-pr.rb', line 589 def to_hash { "name" => @name, "table" => @table, "def" => @default, "type" => @type, "length" => @length, "max_length" => max_length, "flags" => @flags, "decimals" => @decimals } end |