ddl_parser 0.0.10 → 0.0.11

Sign up to get free protection for your applications and to get access to all the features.
@@ -31,11 +31,11 @@ module DDLParser
31
31
 
32
32
  rule(:column_name) { identifier }
33
33
  rule(:constraint_name) { identifier }
34
- rule(:column_sort) { str('ascending') | str('descending')}
34
+ rule(:column_sort) { str('ascending') |str('asc') | str('descending')|str('desc')}
35
35
 
36
36
  rule(:column_definition) { (column_name.as(:field) >> space.repeat >> data_type >> space.repeat >> (column_options.maybe).as(:options)).as(:column)}
37
37
 
38
- rule(:index_column_definition) { column_name.as(:field) >> space.repeat >> (column_sort.as(:sort_id) >> space.repeat).maybe }
38
+ rule(:index_column_definition) { column_name.as(:field) >> (space? >> column_sort.as(:sort_id) >> space.repeat).maybe }
39
39
 
40
40
  rule(:element_list) { (lparen >> space? >> (column_definition | constraint | primary_key) >> space? >>
41
41
  (comma >> space? >> (column_definition | constraint | primary_key) >> space?).repeat >> rparen).as(:elements)
@@ -77,6 +77,10 @@ module DDLParser
77
77
  (identifier.as(:name) >> space? >>
78
78
  lparen >> arglist.as(:arguments) >> rparen).as(:function)
79
79
  }
80
+ # index options
81
+
82
+ rule(:option_reverse_scans) { str('allow reverse scans') }
83
+ rule(:index_option) { (option_reverse_scans).as(:index_option) }
80
84
 
81
85
  rule(:item) { function | identifier | string }
82
86
  rule(:arglist) {
@@ -90,8 +94,19 @@ module DDLParser
90
94
  str('alter table').as(:operation) >> space? >> (identifier).as(:table_name)
91
95
  }
92
96
  rule(:create_index_statement) {
93
- str('create').as(:operation) >> (space? >> str('unique').as(:object_property)).maybe >> space? >> str('index').as(:object_type) >> space? >>
94
- (identifier).as(:index_name) >> space? >> str('on') >> space? >> (identifier).as(:table_name)
97
+ str('create').as(:operation) >> (space? >> str('unique').as(:object_property)).maybe >> space? >> str('index').as(:object_type) >> space? >> (identifier).as(:index_name)
98
+ }
99
+ rule(:create_index_statement_1) {
100
+ str('create').as(:operation) >> (space? >> str('unique').as(:object_property)).maybe
101
+ }
102
+ rule(:create_index_statement_1_a) {
103
+ str('create').as(:operation)
104
+ }
105
+ rule(:create_index_statement_2) {
106
+ str('index').as(:object_type) >> space? >> (identifier).as(:index_name)
107
+ }
108
+ rule(:index_table) {
109
+ space? >> str('on') >> space? >> (identifier).as(:table_name) >> space?
95
110
  }
96
111
  rule(:create_table) {
97
112
  spaces.maybe >> create_table_statement >> spaces >> element_list >> spaces.maybe >> (item >> spaces.maybe).repeat
@@ -100,7 +115,7 @@ module DDLParser
100
115
  spaces.maybe >> alter_table_statement >> spaces >> (alter_table_element.repeat).as(:elements)
101
116
  }
102
117
  rule(:create_index) {
103
- spaces.maybe >> create_index_statement >> spaces >> lparen >> element_list_index >> spaces.maybe >> rparen
118
+ spaces.maybe >> create_index_statement >> spaces >> index_table >> spaces >> lparen >> element_list_index >> spaces.maybe >> rparen >> (space? >> index_option).maybe
104
119
  }
105
120
 
106
121
  rule(:expression) { create_table | alter_table | create_index}
@@ -67,10 +67,6 @@ class DDLParser::Translator::Column
67
67
  @column_hash[:options] if @column_hash[:options].length > 0
68
68
  end
69
69
 
70
- def option(key)
71
- # return the right option
72
- options.select{|o| o.is_a?(Hash) || o.has_key?(key)}.first
73
- end
74
70
 
75
71
  def not_null
76
72
  if options.nil?
@@ -88,10 +84,10 @@ class DDLParser::Translator::Column
88
84
  default_value[:default_clause].each do |c|
89
85
  # TODO must handle other then integer
90
86
  case c.keys.first
91
- when :integer
92
- return c[:integer].to_i
93
- else
94
- return c[c.keys.first].to_s
87
+ when :integer
88
+ return c[:integer].to_i
89
+ else
90
+ return c[c.keys.first].to_s
95
91
  end
96
92
  end
97
93
  else
@@ -101,32 +97,79 @@ class DDLParser::Translator::Column
101
97
  end
102
98
  end
103
99
 
100
+ def identity_options
101
+ unless options.nil?
102
+ start_value = options.select{|h|h.has_key?(:identity_options)}.first
103
+ if start_value
104
+ if start_value[:identity_options].is_a?(Array)
105
+ start_value[:identity_options].each do |c|
106
+ return c[c.keys.first]
107
+ end
108
+ else
109
+ raise "Unknown identity_options #{start_value.inspect}"
110
+ end
111
+ end
112
+ end
113
+ end
114
+
104
115
  def identity?
105
116
  if options.nil?
106
117
  false
107
118
  else
108
- options.select{|h|h.has_key?(:column_option) && h.has_value?('identity')}.length > 0
119
+ # options.select{|h|h.has_key?(:column_option) && h.has_value?('identity')}.length > 0
120
+ options.select{|h|h.has_key?(:identity)}.length > 0
109
121
  end
110
122
  end
111
123
 
112
- def start_value?
124
+ def option(key)
125
+ return if options.nil?
126
+ options.select{|h|h.has_key?(:column_option)}.length > 0 # return the right option
127
+ options.select{|o| o.is_a?(Hash) && o.has_key?(key)}.first
128
+ end
129
+
130
+ def default_value
131
+ unless option(:default_clause).nil?
132
+ begin
133
+ return option(:default_clause)[:default_clause].first[:string]
134
+ rescue
135
+ end
136
+ else
137
+ return ''
138
+ end
139
+ end
140
+
141
+ def start_value
113
142
  unless option(:identity).nil?
114
- option(:identity)[:start_value][:integer].to_i
143
+ begin
144
+ return option(:identity)[:identity][:start_value][:integer].to_i
145
+ rescue
146
+ end
147
+ else
148
+ return 0
115
149
  end
116
150
  end
117
151
 
118
152
  def increment_value
119
- if options.nil?
120
- false
153
+ unless option(:identity).nil?
154
+ begin
155
+ return option(:identity)[:identity][:increment_value][:integer].to_i
156
+ rescue
157
+ end
121
158
  else
122
- options.select{|h|h.has_key?(:column_option) && h.has_value?('identity')}.length > 0
159
+ return 0
123
160
  end
124
161
  end
162
+
125
163
  def cache_value
126
- if options.nil?
127
- false
164
+ unless option(:identity).nil?
165
+ begin
166
+ return option(:identity)[:identity][:cache_value][:integer].to_i
167
+ rescue
168
+ end
128
169
  else
129
- options.select{|h|h.has_key?(:column_option) && h.has_value?('identity')}.length > 0
170
+ return 0
130
171
  end
131
172
  end
173
+
174
+
132
175
  end
@@ -1,28 +1,29 @@
1
- class DDLParser::Translator::CreateIndex
2
-
3
- attr_accessor :parse_tree
4
- def initialize(parse_tree)
5
- @parse_tree=parse_tree
6
- end
7
-
8
- def elements
9
- [@parse_tree[:elements]].flatten
10
- end
11
-
12
- def table_name
13
- @parse_tree.first[:table_name].to_s
14
- end
15
-
16
- def index_name
17
- @parse_tree.first[:index_name].to_s
18
- end
19
-
20
- def fields
21
- @parse_tree.select{|e|e.has_key?(:field)}.compact
22
- end
23
-
24
- def primary_key
25
- elements.map{|e| e[:primary_key]}.compact.first[:item]
26
- end
27
-
1
+ class DDLParser::Translator::CreateIndex
2
+
3
+ attr_accessor :parse_tree
4
+
5
+ def initialize(parse_tree)
6
+ @parse_tree=parse_tree
7
+ end
8
+
9
+ def elements
10
+ [@parse_tree[:elements]].flatten
11
+ end
12
+
13
+ def table_name
14
+ @parse_tree.first[:table_name].to_s
15
+ end
16
+
17
+ def index_name
18
+ @parse_tree.first[:index_name].to_s
19
+ end
20
+
21
+ def fields
22
+ @parse_tree.select{|e|e.has_key?(:field)}.compact
23
+ end
24
+
25
+ def primary_key
26
+ elements.map{|e| e[:primary_key]}.compact.first[:item]
27
+ end
28
+
28
29
  end
@@ -1,27 +1,29 @@
1
- class DDLParser::Translator::CreateTable
2
- attr_accessor :parse_tree
3
- def initialize(parse_tree)
4
- @parse_tree=parse_tree
5
- end
6
-
7
- def elements
8
- [@parse_tree[:elements]].flatten
9
- end
10
-
11
- def table_name
12
- @parse_tree[:table_name].to_s
13
- end
14
-
15
- def columns
16
- elements.map{|e|e[:column]}.compact.map{|e|DDLParser::Translator::Column.new(e)}
17
- end
18
-
19
- def primary_key
20
- elements.map{|e| e[:primary_key]}.compact.first[:item]
21
- end
22
-
23
- def constraints
24
- elements.map{|e|e[:constraint]}.compact
25
- end
26
-
1
+ class DDLParser::Translator::CreateTable
2
+
3
+ attr_accessor :parse_tree
4
+
5
+ def initialize(parse_tree)
6
+ @parse_tree=parse_tree
7
+ end
8
+
9
+ def elements
10
+ [@parse_tree[:elements]].flatten
11
+ end
12
+
13
+ def table_name
14
+ @parse_tree[:table_name].to_s
15
+ end
16
+
17
+ def columns
18
+ elements.map{|e|e[:column]}.compact.map{|e|DDLParser::Translator::Column.new(e)}
19
+ end
20
+
21
+ def primary_key
22
+ elements.map{|e| e[:primary_key]}.compact.first[:item]
23
+ end
24
+
25
+ def constraints
26
+ elements.map{|e|e[:constraint]}.compact
27
+ end
28
+
27
29
  end
@@ -1,3 +1,3 @@
1
- module DDLParser
2
- VERSION = '0.0.10'
3
- end
1
+ module DDLParser
2
+ VERSION = '0.0.11'
3
+ end
@@ -1,26 +1,154 @@
1
- require_relative '../../../../spec/spec_helper'
2
-
3
- describe 'Create index parsing' do
4
- let(:parser) { DDLParser::DDL::DB2::Parser.new }
5
- it 'parses create_unique_index' do
6
- sql = <<EOF
7
- CREATE UNIQUE INDEX REPLAN_ADDR_1 ON REPLAN_ADDR
8
- (CONSIGNMENT ASCENDING, COLLI DESCENDING )
9
- EOF
10
- begin
11
- result = parser.parse(sql.downcase)
12
- rescue Parslet::ParseFailed => error
13
- puts error.cause.ascii_tree
14
- end
15
-
16
- result.count.should == 3
17
- result[0].should include(:operation, :object_property, :object_type, :index_name)
18
- result[0].should include(:operation => 'create')
19
- result[0].should include(:object_property => 'unique')
20
- result[0].should include(:object_type => 'index')
21
- result[1].should include(:field)
22
- result[1].should include(:sort_id)
23
- result[2].should include(:field)
24
- result[2].should include(:sort_id)
25
- end
1
+ require_relative '../../../../spec/spec_helper'
2
+
3
+ describe 'Create index parsing' do
4
+ let(:parser) { DDLParser::DDL::DB2::Parser.new }
5
+ context 'create index 1' do
6
+ it 'parses create_unique_index' do
7
+ sql = <<EOF
8
+ CREATE UNIQUE INDEX COST_INVOICE_1 ON COST_INVOICE
9
+ (DOC_NO, DOC_NO_2 )
10
+ EOF
11
+ begin
12
+ result = parser.parse(sql.downcase)
13
+ rescue Parslet::ParseFailed => error
14
+ puts error.cause.ascii_tree
15
+ end
16
+
17
+ result.count.should == 3
18
+ result[0].should include(:operation, :object_property, :object_type, :index_name)
19
+ result[0].should include(:operation => 'create')
20
+ result[0].should include(:object_property => 'unique')
21
+ result[0].should include(:object_type => 'index')
22
+ result[1].should include(:field)
23
+ end
24
+ it 'parses create_unique_index with one column' do
25
+ sql = <<EOF
26
+ CREATE UNIQUE INDEX COST_INVOICE_1 ON COST_INVOICE
27
+ (DOC_NO)
28
+ EOF
29
+ begin
30
+ result = parser.parse(sql.downcase)
31
+ rescue Parslet::ParseFailed => error
32
+ puts error.cause.ascii_tree
33
+ end
34
+
35
+ result.count.should == 6
36
+ result.should include(:operation => 'create')
37
+ result.should include(:object_property => 'unique')
38
+ result.should include(:object_type => 'index')
39
+ result.should include(:index_name => 'cost_invoice_1')
40
+ result.should include(:table_name => 'cost_invoice')
41
+ result.should include(:field => 'doc_no')
42
+ end
43
+ end
44
+ context 'element list index' do
45
+ it 'parses one element', pending:true do
46
+ sql = 'deptno asc'
47
+ parser.element_list_index.parse(sql).should == {:elements => {:column=>{:field=> 'deptno',
48
+ :data_type=>{:char=>{:length=>{:integer=> '3'}}},
49
+ :options=>[{:column_option=> 'not null'}]}}}
50
+ end
51
+ it 'parses two element' do
52
+ sql = 'field1, field2'
53
+ parser.element_list_index.parse(sql).should == [{:field=> 'field1'},
54
+ {:field=> 'field2'}]
55
+
56
+ end
57
+
58
+ it 'parses with new lines' do
59
+ sql = <<EOF
60
+ DEPTNO desc,
61
+ DEPTNAME asc
62
+ EOF
63
+ parser.element_list_index.parse(sql.downcase).should == [{:field=> 'deptno',:sort_id=> 'desc'},
64
+ {:field=> 'deptname',:sort_id=> 'asc'}]
65
+ end
66
+ end
67
+ context 'index column definition' do
68
+ it 'parses two element' do
69
+ sql = 'field1'
70
+ parser.index_column_definition.parse(sql).should == {:field=> 'field1'}
71
+
72
+
73
+ end
74
+
75
+ it 'parses with new lines' do
76
+ sql = <<EOF
77
+ DEPTNO descending
78
+ EOF
79
+ parser.index_column_definition.parse(sql.downcase).should == {:field=> 'deptno',:sort_id=> 'descending'}
80
+
81
+ end
82
+ end
83
+ context 'reverse scan' do
84
+ it 'parses reverse scans option' do
85
+ sql = 'allow reverse scans'
86
+ end
87
+ it 'parses index_option with reverse scans' do
88
+ sql = 'allow reverse scans'
89
+ parser.index_option.parse(sql).should == {:index_option => 'allow reverse scans'}
90
+ end
91
+ end
92
+ context 'create_index_statement' do
93
+ it 'create_index_statement_unique_1', :pending => true do
94
+ sql = <<EOF
95
+ CREATE
96
+ EOF
97
+ parser.create_index_statement_1.parse(sql.downcase).should == {:operation=>'create',:object_property=>'unique'}
98
+
99
+ end
100
+ it 'create_index_statement_unique_1_a', :pending => true do
101
+ sql = <<EOF
102
+ CREATE
103
+ EOF
104
+ parser.create_index_statement_1_a.parse(sql.downcase).should == {:operation=>'create',:object_property=>'unique'}
105
+
106
+ end
107
+ it 'create_index_statement_unique_2', pending:true do
108
+ sql = <<EOF
109
+ INDEX COST_INVOICE_1
110
+ EOF
111
+ parser.create_index_statement_2.parse(sql.downcase).should == {:object_type=>'index',:index_name=>'cost_invoice_1'}
112
+
113
+ end
114
+ it 'create_index_statement_unique', pending:true do
115
+ sql = <<EOF
116
+ CREATE UNIQUE INDEX COST_INVOICE_1
117
+ EOF
118
+ parser.create_index_statement.parse(sql.downcase).should == {:operation=>'create',:object_property=>'unique',:object_type=>'index',:index_name=>'cost_invoice_1'}
119
+
120
+ end
121
+ end
122
+ context 'index_table' do
123
+ it 'index_table_example' do
124
+ sql = <<EOF
125
+ ON COST_INVOICE
126
+ EOF
127
+ parser.index_table.parse(sql.downcase).should == {:table_name => 'cost_invoice'}
128
+
129
+ end
130
+ end
131
+ context 'full index example with reverse scan option' do
132
+ it 'with reverse scan', pending:true do
133
+ sql = <<EOF
134
+ CREATE UNIQUE INDEX COST_INVOICE_1
135
+ ON COST_INVOICE
136
+ (DOC_NO)
137
+ ALLOW REVERSE SCANS
138
+ EOF
139
+ begin
140
+ result = parser.parse(sql.downcase)
141
+ rescue Parslet::ParseFailed => error
142
+ puts error.cause.ascii_tree
143
+ end
144
+ result.count.should == 6
145
+ result.should include(:operation => 'create')
146
+ result.should include(:object_property => 'unique')
147
+ result.should include(:object_type => 'index')
148
+ result.should include(:index_name => 'cost_invoice_1')
149
+ result.should include(:table_name => 'cost_invoice')
150
+ result.should include(:field => 'doc_no')
151
+
152
+ end
153
+ end
26
154
  end
@@ -42,7 +42,7 @@ describe DDLParser::DDL::DB2::Parser do
42
42
  :cache_value=>{:integer=> '20'}}}]
43
43
  end
44
44
 
45
- it 'parses generated by' do
45
+ it 'parses 1 generated by 1' do
46
46
  sql = 'generated by default as identity (start with 1, increment by 1, cache 20 )'
47
47
  begin
48
48
  result = parser.column_options.parse(sql.downcase)
@@ -254,31 +254,6 @@ EOF
254
254
  expect(parser).to parse(sql.downcase)
255
255
  end
256
256
 
257
- it 'parses Example 6' do
258
- pending 'we do not support CHECK statements'
259
- sql = <<EOF
260
- CREATE TABLE EMPLOYEE
261
- (ID SMALLINT NOT NULL,
262
- NAME VARCHAR(9),
263
- DEPT SMALLINT CHECK (DEPT BETWEEN 10 AND 100),
264
- JOB CHAR(5) CHECK (JOB IN ('Sales','Mgr','Clerk')),
265
- HIREDATE DATE,
266
- SALARY DECIMAL(7,2),
267
- COMM DECIMAL(7,2),
268
- PRIMARY KEY (ID),
269
- CONSTRAINT YEARSAL CHECK (YEAR(HIREDATE) > 1986
270
- OR SALARY > 40500)
271
- )
272
- IN HUMRES
273
- EOF
274
- begin
275
- result = parser.parse(sql.downcase)
276
- # rescue Parslet::ParseFailed => error
277
- # puts error.cause.ascii_tree
278
- end
279
- result.should == [{:operation=> 'create table', :table_name=> 'emp_act'}]
280
- end
281
-
282
257
  it 'parses Example 11' do
283
258
  sql = <<EOF
284
259
  CREATE TABLE EMP_ACT
@@ -515,4 +490,46 @@ EOF
515
490
  end
516
491
 
517
492
  end
493
+ context 'create table one column' do
494
+ it 'parses Example 19' do
495
+ sql = <<EOF
496
+ CREATE TABLE COSTINVOICEX
497
+ (DOC_NO CHARACTER(8) NOT NULL DEFAULT 'TEST DEFAULT')
498
+
499
+ EOF
500
+
501
+ begin
502
+ result = parser.parse(sql.downcase)
503
+ rescue Parslet::ParseFailed => error
504
+ puts error.cause.ascii_tree
505
+ end
506
+
507
+ result.should == {:operation=>"create table",
508
+ :table_name=>"costinvoicex",
509
+ :elements=>{:column=>{:field=>"doc_no",
510
+ :data_type=>{:char=>{:length=>{:integer=>"8"}}},
511
+ :options=>[{:column_option=>"not null"},
512
+ {:default_clause=>[{:string=>"'test default'"}]}]}}}
513
+ end
514
+
515
+ it 'parses Example 19 1 simple column' do
516
+ sql = <<EOF
517
+ CREATE TABLE COSTINVOICEX
518
+ (DOC_NO INTEGER)
519
+
520
+ EOF
521
+
522
+ begin
523
+ result = parser.parse(sql.downcase)
524
+ rescue Parslet::ParseFailed => error
525
+ puts error.cause.ascii_tree
526
+ end
527
+
528
+ result.should == {:operation=>"create table",
529
+ :table_name=>"costinvoicex",
530
+ :elements=>{:column=>{:field=>"doc_no",
531
+ :data_type=> 'integer', :options=>""}}}
532
+ end
533
+
534
+ end
518
535
  end
@@ -4,7 +4,18 @@ require_relative '../../../lib/ddl_parser/translator/column'
4
4
  describe 'DDLParser::Translator::Column' do
5
5
 
6
6
  let(:unique_no_column) {
7
- DDLParser::Translator::Column.new({:field=> 'unique_no', :data_type=> 'integer', :options=>[{:column_option=> 'identity'}, {:identity=>{:start_value=>{:integer=> '1'}, :increment_value=>{:integer=> '1'}, :cache_value=>{:integer=> '20'}}}]})
7
+ DDLParser::Translator::Column.new(
8
+ {:field=> 'unique_no',
9
+ :data_type=> 'integer',
10
+ :options=>
11
+ [{:column_option=> 'identity'},
12
+ {:identity=>
13
+ {:start_value=>{:integer=> '1'},
14
+ :increment_value=>{:integer=> '1'},
15
+ :cache_value=>{:integer=> '20'}
16
+ }
17
+ }]
18
+ })
8
19
  }
9
20
 
10
21
  let(:int_column) {
@@ -43,6 +54,8 @@ describe 'DDLParser::Translator::Column' do
43
54
  })
44
55
  }
45
56
 
57
+
58
+
46
59
  it 'must receive hash' do
47
60
  DDLParser::Translator::Column.new('').to_hash.should == {}
48
61
  DDLParser::Translator::Column.new({:foo => :bar}).to_hash.should == {:foo => :bar}
@@ -88,24 +101,82 @@ describe 'DDLParser::Translator::Column' do
88
101
  decimal_column.options.should == [{:column_option=> 'not null'}, {:default_clause=>[{:integer=> '0'}]}]
89
102
  end
90
103
 
91
- it 'should return not null' do
92
- int_column.not_null.should == false
93
- char_column.not_null.should == false
94
- decimal_column.not_null.should == true
95
- end
104
+ it 'should return not null' do
105
+ int_column.not_null.should == false
106
+ char_column.not_null.should == false
107
+ decimal_column.not_null.should == true
108
+ end
96
109
 
97
- it 'should return default clause' do
98
- int_column.default_clause.should == nil
99
- char_column.default_clause.should == "'foobar'"
100
- decimal_column.default_clause.should == 0
101
- end
110
+ it 'should return default clause' do
111
+ int_column.default_clause.should == nil
112
+ char_column.default_clause.should == "'foobar'"
113
+ decimal_column.default_clause.should == 0
114
+ end
102
115
 
103
- it 'should return identity flag' do
104
- unique_no_column.identity?.should == true
105
- end
106
116
 
107
- it 'should return start value for identity' do
108
- unique_no_column.start_value?.should == 1
109
- end
117
+ it 'should return default value' do
118
+ char_column.default_value.should == "'foobar'"
119
+ end
120
+
121
+ it 'should return identity flag' do
122
+ unique_no_column.identity?.should == true
123
+ end
124
+
125
+ it 'should return start value for identity' do
126
+ unique_no_column.start_value.should == 1
127
+ end
128
+
129
+
130
+ it 'should return start value 0 for int_column' do
131
+ int_column.start_value.should == 0
132
+ end
133
+
134
+ it 'should return start value 0 for decimal_column' do
135
+ decimal_column.start_value.should == 0
136
+ end
137
+
138
+ it 'should return increment value for identity' do
139
+ unique_no_column.increment_value.should == 1
140
+ end
141
+
142
+ it 'should return cache value for identity' do
143
+ unique_no_column.cache_value.should == 20
144
+ end
145
+
146
+ it 'should return name via int_column_identity' do
147
+ int_column_identity.name.should == 'identity_field'
148
+ end
149
+
150
+ it 'should return data_type via int_column_identity' do
151
+ int_column_identity.data_type.should == :integer
152
+ end
153
+
154
+ it 'should return length via int_column_identity' do
155
+ int_column_identity.length.should == nil
156
+ end
157
+
158
+ it 'should return precision via int_column_identity' do
159
+ int_column_identity.precision.should == nil
160
+ end
161
+
162
+ it 'should return scale via int_column_identity' do
163
+ int_column_identity.scale.should == nil
164
+ end
165
+
166
+ let(:int_column_identity) {
167
+ DDLParser::Translator::Column.new(
168
+ {:field=> 'identity_field',
169
+ :data_type=>{:integer=> '1'},
170
+ :options=>[{:column_option=> 'identity'}, {:identity_options=>[{:start_value=>[{:integer=> '1'},{:increment_value=>[{:integer=> '1'}]},{:cache_value=>[{:integer=> '20'}]}]}]
171
+ }]})
172
+ }
173
+
174
+ it 'should return options via int_column_identity' do
175
+ int_column_identity.options.should == [{:column_option=> 'identity'}, {:identity_options=>[{:start_value=>[{:integer=> '1'},{:increment_value=>[{:integer=> '1'}]},{:cache_value=>[{:integer=> '20'}]}]}]}]
176
+ end
177
+
178
+ it 'should return options alt via int_column_identity' do
179
+ int_column_identity.identity_options.should == [{:integer=>'1'},{:increment_value=>[{:integer=>'1'}]},{:cache_value=>[{:integer=>'20'}]}]
180
+ end
110
181
 
111
- end
182
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ddl_parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.10
4
+ version: 0.0.11
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: