Skip to content

Commit

Permalink
Merge pull request #225 from javedashraf/master
Browse files Browse the repository at this point in the history
Fix for oracle open cursor and foreign key issue
  • Loading branch information
sue445 authored Aug 15, 2023
2 parents 8e453d6 + 76fd9d2 commit cfb10e8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
5 changes: 5 additions & 0 deletions adapter/oracle/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ func (a *Adapter) GetTable(tableName string) (*db.Table, error) {

var rows []allTabColumns
err = stmt.Select(&rows, tableName)
defer stmt.Close()

if err != nil {
return nil, err
Expand Down Expand Up @@ -127,6 +128,7 @@ func (a *Adapter) getPrimaryKeyColumns(tableName string) (mapset.Set, error) {

var rows []primaryKeys
err = stmt.Select(&rows, tableName)
defer stmt.Close()

if err != nil {
return nil, err
Expand Down Expand Up @@ -168,6 +170,7 @@ func (a *Adapter) getForeignKeys(tableName string) ([]*db.ForeignKey, error) {

var rows []foreignKey
err = stmt.Select(&rows, tableName)
defer stmt.Close()

if err != nil {
return nil, err
Expand Down Expand Up @@ -210,6 +213,7 @@ func (a *Adapter) getIndexes(tableName string) ([]*db.Index, error) {

var rows []allIndexes
err = stmt.Select(&rows, tableName)
defer stmt.Close()

if err != nil {
return nil, err
Expand Down Expand Up @@ -243,6 +247,7 @@ func (a *Adapter) getIndexColumns(indexName string) ([]string, error) {

var rows []allIndColumns
err = stmt.Select(&rows, indexName)
defer stmt.Close()

if err != nil {
return nil, err
Expand Down
10 changes: 6 additions & 4 deletions db/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ func (s *Schema) ToErd(showIndex bool) string {

for _, table := range s.Tables {
for _, foreignKey := range table.ForeignKeys {
if tableNames.Contains(foreignKey.ToTable) {
lines = append(lines, fmt.Sprintf("%s }-- %s", table.Name, foreignKey.ToTable))
toTable := strings.ToLower(foreignKey.ToTable)
if tableNames.Contains(toTable) {
lines = append(lines, fmt.Sprintf("%s }-- %s", table.Name, toTable))
}
}
}
Expand All @@ -51,8 +52,9 @@ func (s *Schema) ToMermaid(showComment bool) string {

for _, table := range s.Tables {
for _, foreignKey := range table.ForeignKeys {
if tableNames.Contains(foreignKey.ToTable) {
lines = append(lines, fmt.Sprintf("%s ||--o{ %s : owns", foreignKey.ToTable, table.Name))
toTable := strings.ToLower(foreignKey.ToTable)
if tableNames.Contains(toTable) {
lines = append(lines, fmt.Sprintf("%s ||--o{ %s : owns", toTable, table.Name))
}
}
}
Expand Down

0 comments on commit cfb10e8

Please sign in to comment.