summaryrefslogtreecommitdiffstats
path: root/dia2pg.rb
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2016-12-16 15:32:45 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2016-12-16 15:32:45 +0100
commit41da68b50229976333d62f06033101d6ad8c2277 (patch)
tree999b0f17a4c5538403293bfc14528e5308853faf /dia2pg.rb
parenta9b984021af0544e2bb2ef082ba0c119f38b4460 (diff)
downloadbin-41da68b50229976333d62f06033101d6ad8c2277.zip
bin-41da68b50229976333d62f06033101d6ad8c2277.tar.gz
dia2pg: fix unique usage
Diffstat (limited to 'dia2pg.rb')
-rwxr-xr-xdia2pg.rb17
1 files changed, 12 insertions, 5 deletions
diff --git a/dia2pg.rb b/dia2pg.rb
index 2179305..e741272 100755
--- a/dia2pg.rb
+++ b/dia2pg.rb
@@ -140,11 +140,12 @@ class Table
idx[xi] << attr.real_name
end
pk << attr.real_name if attr.primary_key
- if attr.unique and not attr.primary_key
- if attr.comment=~/U./
- uq[attr.comment] ||= []
- uq[attr.comment]<< attr.real_name
- else
+ if attr.unique
+ ug = attr.unique_group
+ if not ug.nil?
+ uq[ug] ||= []
+ uq[ug]<< attr.real_name
+ elsif not attr.primary_key
uq[:all] << attr.real_name
end
end
@@ -187,6 +188,12 @@ class Attribute
$1
end
#
+ def unique_group
+ return nil if @comment.nil?
+ return nil if not @comment=~/unique=(\w+)/
+ $1
+ end
+ #
def no_rename?
return false if @comment.nil?
@comment=~/no_rename/