From cfe2fc7fad382f4d20d7369dec4c104223e01314 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Thu, 5 Jun 2014 16:17:56 +0200 Subject: [PATCH] Rose-Model-Generator: Foreign-Key-Namens-Mapping auf Datenbank beziehen --- scripts/rose_auto_create_model.pl | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/scripts/rose_auto_create_model.pl b/scripts/rose_auto_create_model.pl index 104492cd7..fb589c610 100755 --- a/scripts/rose_auto_create_model.pl +++ b/scripts/rose_auto_create_model.pl @@ -47,17 +47,19 @@ our $manager_path = "SL/DB/Manager"; my %config; -our %foreign_key_name_map = ( - oe => { payment => 'payment_terms', }, - ar => { payment => 'payment_terms', }, - ap => { payment => 'payment_terms', }, - - orderitems => { parts => 'part', trans => 'order', }, - delivery_order_items => { parts => 'part' }, - invoice => { parts => 'part' }, - follow_ups => { 'employee_obj' => 'created_for' }, - - periodic_invoices_configs => { oe => 'order' }, +our %foreign_key_name_map = ( + KIVITENDO => { + oe => { payment => 'payment_terms', }, + ar => { payment => 'payment_terms', }, + ap => { payment => 'payment_terms', }, + + orderitems => { parts => 'part', trans => 'order', }, + delivery_order_items => { parts => 'part' }, + invoice => { parts => 'part' }, + follow_ups => { 'employee_obj' => 'created_for' }, + + periodic_invoices_configs => { oe => 'order' }, + }, ); sub setup { @@ -139,7 +141,8 @@ CODE if ($foreign_key_definition && ($definition =~ /\Q$foreign_key_definition\E/)) { my ($start, $end) = ($-[0], $+[0]); - while (my ($auto_generated_name, $desired_name) = each %{ $foreign_key_name_map{$table} || {} }) { + my %changes = map { %{$_} } grep { $_ } ($foreign_key_name_map{$domain}->{ALL}, $foreign_key_name_map{$domain}->{$table}); + while (my ($auto_generated_name, $desired_name) = each %changes) { $foreign_key_definition =~ s/^ \s \s ${auto_generated_name} \b/ ${desired_name}/msx; } -- 2.20.1