| 546 | } |
| 547 | |
| 548 | func getTypeString(dataType string, dataLength, dataPrecision, dataScale sql.NullInt64) string { |
| 549 | switch dataType { |
| 550 | case "VARCHAR2", "CHAR": |
| 551 | return fmt.Sprintf("%s(%d BYTE)", dataType, dataLength.Int64) |
| 552 | case "NVARCHAR2", "RAW", "UROWID", "NCHAR": |
| 553 | return fmt.Sprintf("%s(%d)", dataType, dataLength.Int64) |
| 554 | case "NUMBER": |
| 555 | switch { |
| 556 | case !dataPrecision.Valid || dataPrecision.Int64 == 0: |
| 557 | // do nothing |
| 558 | case dataPrecision.Valid && dataPrecision.Int64 > 0 && (!dataScale.Valid || dataScale.Int64 == 0): |
| 559 | return fmt.Sprintf("%s(%d)", dataType, dataPrecision.Int64) |
| 560 | case dataPrecision.Valid && dataPrecision.Int64 > 0 && dataScale.Valid && dataScale.Int64 > 0: |
| 561 | return fmt.Sprintf("%s(%d,%d)", dataType, dataPrecision.Int64, dataScale.Int64) |
| 562 | default: |
| 563 | // do nothing |
| 564 | } |
| 565 | case "FLOAT": |
| 566 | switch { |
| 567 | case !dataPrecision.Valid || dataPrecision.Int64 == 0: |
| 568 | // do nothing |
| 569 | case dataPrecision.Valid && dataPrecision.Int64 > 0: |
| 570 | return fmt.Sprintf("%s(%d)", dataType, dataPrecision.Int64) |
| 571 | default: |
| 572 | // do nothing |
| 573 | } |
| 574 | default: |
| 575 | // return dataType as-is for unhandled types |
| 576 | } |
| 577 | return dataType |
| 578 | } |
| 579 | |
| 580 | func getOuterSchemaRColumns(txn *sql.Tx, outerRTableMap map[db.ConstraintKey]string, outerRColumnMap map[db.ConstraintKey][]string, schemaName, constraintName string) (string, []string, error) { |
| 581 | queryColumns := fmt.Sprintf(` |