Skip to content

Commit

Permalink
#59129 corrigindo bug no bee
Browse files Browse the repository at this point in the history
  • Loading branch information
antonioedirane committed Feb 20, 2014
1 parent ccbdd41 commit 3bb3636
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ class BeeOracleSchemaCreator extends BeeSchemaCreator {
super.createCoreData(file, schema, dataFolderPath)
}

void createTables(def file, def schema) {
def tables = schema.tables.sort()
tables.each( { file << createTable(it.value) })
}

def createTable(def table) {
def columns = []
table.columns.each({
Expand All @@ -19,14 +24,8 @@ class BeeOracleSchemaCreator extends BeeSchemaCreator {
def temp = table.temporary ? " global temporary" : ""
def result = "create${temp} table ${table.name} (\n" + columns.join(",\n") + "\n);\n\n"
}

void createTables(def file, def schema) {
def tables = schema.tables.sort()
tables.each( { file << createTable(it.value) })
}

def createColumn(def column) {
println "create Colummn Oracle"
def result = " ${column.name} ${column.type}"
if(column.type in ['char', 'varchar'])
if(column.sizeType != null)
Expand All @@ -35,10 +34,9 @@ class BeeOracleSchemaCreator extends BeeSchemaCreator {
result += "(${column.size})"

if(column.type == 'number')
println column
if (column.scale > 0) {
result += "(${column.size}, ${column.scale})"
} else if (column.data_precision != null && column.data_lenght != 22) {
} else if (column.scale != null && column.size != null && column.size != 22) {
result += "(${column.size})"
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ class OracleDatabaseReader implements DatabaseReader {
def table = tables[it.table_name.toLowerCase()]
def column = new TableColumn()
column.name = it.column_name.toLowerCase()
column.scale = getScale(it)
column.scale = it.data_scale == null ? 0 : it.data_scale
column.type = getColumnType(it.data_type)
column.size = getColumnSize(it)
column.sizeType = getColumnSizeType(it.size_type)
Expand Down Expand Up @@ -160,22 +160,17 @@ class OracleDatabaseReader implements DatabaseReader {
}

private def getColumnSize(iterator) {
if (iterator.data_type.toUpperCase() == 'NUMBER' && iterator.data_precision == null && iterator.data_scale == 0 && iterator.data_length == '22') {
if (isNumericWithoutSizeEspecified(iterator)) {
return null
} else {
return iterator.data_size
}
}

private def getScale(iterator) {
if (iterator.data_type.toUpperCase() == 'NUMBER' && iterator.data_precision == null && iterator.data_scale == 0 && iterator.data_length == '22') {
return null
} else {
iterator.data_scale == null ? 0 : iterator.data_scale
}
private def isNumericWithoutSizeEspecified(iterator){
return iterator.data_type.toUpperCase() == 'NUMBER' && iterator.data_precision == null && iterator.data_scale == 0 && iterator.data_length == 22
}


final static def INDEXES_QUERY = '''
select ui.table_name, ui.index_name, ui.index_type, uniqueness
from user_indexes ui
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public class OracleDatabaseReaderTableTest {
void 'it shouldnt set the data size and scale when data type is number without data_scale'() {
def tables = reader.getTables()
assertEquals null, tables['pessoa'].columns['vendas'].size
assertEquals null, tables['pessoa'].columns['vendas'].scale
assertEquals 0, tables['pessoa'].columns['vendas'].scale
}

@Test
Expand Down Expand Up @@ -247,7 +247,7 @@ public class OracleDatabaseReaderTableTest {
data_type:"NUMBER",
data_size:22,
data_scale:0,
data_length:"22",
data_length:22,
nullable:"N",
data_default:"null"]

Expand Down

0 comments on commit 3bb3636

Please sign in to comment.