ddl_parser 0.0.15 → 0.0.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -32,6 +32,12 @@ class DDLParser::Translator::Column
|
|
32
32
|
rescue
|
33
33
|
raise "DataType CHAR length wrong format #{@column_hash[:data_type].inspect}"
|
34
34
|
end
|
35
|
+
when :varchar
|
36
|
+
begin
|
37
|
+
@column_hash[:data_type][:varchar][:length][:integer].to_i
|
38
|
+
rescue
|
39
|
+
raise "DataType VARCHAR length wrong format #{@column_hash[:data_type].inspect}"
|
40
|
+
end
|
35
41
|
else
|
36
42
|
nil
|
37
43
|
end
|
data/lib/ddl_parser/version.rb
CHANGED
@@ -106,7 +106,7 @@ EOF
|
|
106
106
|
end
|
107
107
|
it 'parses index_option with reverse scans' do
|
108
108
|
sql = 'allow reverse scans'
|
109
|
-
parser.index_option.parse(sql).should include(:
|
109
|
+
parser.index_option.parse(sql)[:index_option].should include(:reverse_scans_property => 'allow reverse scans')
|
110
110
|
end
|
111
111
|
end
|
112
112
|
context 'create_index_statement' do
|
@@ -163,7 +163,7 @@ EOF
|
|
163
163
|
result.should include(:index_name => 'cost_invoice_1')
|
164
164
|
result.should include(:table_name => 'cost_invoice')
|
165
165
|
result.should include(:field => 'doc_no')
|
166
|
-
result.should include(:
|
166
|
+
result[:index_option].should include(:reverse_scans_property => 'allow reverse scans')
|
167
167
|
|
168
168
|
end
|
169
169
|
it 'without reverse scan' do
|
@@ -204,8 +204,7 @@ EOF
|
|
204
204
|
result.should include(:index_name => 'pl_trigger_i2')
|
205
205
|
result.should include(:table_name => 'pl_trigger')
|
206
206
|
result.should include(:field => 'unique_no')
|
207
|
-
result.should include(:
|
208
|
-
|
207
|
+
result[:index_option].should include(:reverse_scans_property => 'allow reverse scans')
|
209
208
|
|
210
209
|
end
|
211
210
|
it 'live example' do
|
@@ -30,6 +30,15 @@ describe 'DDLParser::Translator::Column' do
|
|
30
30
|
)
|
31
31
|
}
|
32
32
|
|
33
|
+
|
34
|
+
let(:varchar_column) {
|
35
|
+
DDLParser::Translator::Column.new(
|
36
|
+
{:field=> 'varchar_field',
|
37
|
+
:data_type=>{:varchar=>{:length=>{:integer=> '255'}}},
|
38
|
+
:options=> [{:default_clause=>[{:string => "'foobar'"}]}]}
|
39
|
+
)
|
40
|
+
}
|
41
|
+
|
33
42
|
let(:decimal_column) {
|
34
43
|
DDLParser::Translator::Column.new(
|
35
44
|
{:field=> 'decimal_field',
|
@@ -70,12 +79,14 @@ describe 'DDLParser::Translator::Column' do
|
|
70
79
|
it 'should return data_type' do
|
71
80
|
int_column.data_type.should == :int
|
72
81
|
char_column.data_type.should == :char
|
82
|
+
varchar_column.data_type.should == :varchar
|
73
83
|
decimal_column.data_type.should == :decimal
|
74
84
|
end
|
75
85
|
|
76
86
|
it 'should return length' do
|
77
87
|
int_column.length.should == nil
|
78
88
|
char_column.length.should == 4
|
89
|
+
varchar_column.length.should == 255
|
79
90
|
decimal_column.length.should == 15.2
|
80
91
|
end
|
81
92
|
|
@@ -9,14 +9,13 @@ describe 'DDLParser::Translator::CreateIndexHeader' do
|
|
9
9
|
:index_table=> 'on test_table',
|
10
10
|
:table_name=> 'test_table',
|
11
11
|
:object_property=> 'unique',
|
12
|
-
:
|
12
|
+
:index_option => {:reverse_scans_property=>'allow reverse scans'}
|
13
13
|
}, {}])
|
14
14
|
}
|
15
15
|
|
16
16
|
let(:index_name_test) {
|
17
17
|
DDLParser::Translator::CreateIndexHeader.new({:field=> 'test_index'})
|
18
18
|
|
19
|
-
# DDLParser::Translator::Column.new({:field=> 'int_field', :data_type=> 'int', :options=> ''})
|
20
19
|
}
|
21
20
|
|
22
21
|
let(:table_name) {
|
@@ -33,7 +32,7 @@ it 'should return name' do
|
|
33
32
|
unique_no_column.index_name.should == 'test_index'
|
34
33
|
unique_no_column.table_name.should == 'test_table'
|
35
34
|
unique_no_column.object_property.should == 'unique'
|
36
|
-
unique_no_column.option_reverse_scans.should == '
|
35
|
+
unique_no_column.option_reverse_scans.should == 'Y'
|
37
36
|
end
|
38
37
|
|
39
38
|
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.
|
4
|
+
version: 0.0.16
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-10-
|
12
|
+
date: 2014-10-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: parslet
|
@@ -158,3 +158,4 @@ test_files:
|
|
158
158
|
- spec/ddl_parser/translator/index_column_spec.rb
|
159
159
|
- spec/ddl_parser/translator/index_header_spec.rb
|
160
160
|
- spec/spec_helper.rb
|
161
|
+
has_rdoc:
|