From 41da68b50229976333d62f06033101d6ad8c2277 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Fri, 16 Dec 2016 15:32:45 +0100 Subject: dia2pg: fix unique usage --- dia2pg.rb | 17 ++++++++++++----- 1 file 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/ -- cgit v1.1-2-g2b99