Revision ea502a0b
Von Moritz Bunkus vor fast 14 Jahren hinzugefügt
SL/DB.pm | ||
---|---|---|
21 | 21 |
|
22 | 22 |
my $db = __PACKAGE__->new_or_cached(domain => $domain, type => $type); |
23 | 23 |
|
24 |
_execute_initial_sql($db); |
|
25 |
|
|
24 | 26 |
return $db; |
25 | 27 |
} |
26 | 28 |
|
29 |
my %_dateformats = ( 'yy-mm-dd' => 'ISO', |
|
30 |
'yyyy-mm-dd' => 'ISO', |
|
31 |
'mm/dd/yy' => 'SQL, US', |
|
32 |
'mm-dd-yy' => 'POSTGRES, US', |
|
33 |
'dd/mm/yy' => 'SQL, EUROPEAN', |
|
34 |
'dd-mm-yy' => 'POSTGRES, EUROPEAN', |
|
35 |
'dd.mm.yy' => 'GERMAN' |
|
36 |
); |
|
37 |
|
|
27 | 38 |
sub _register_db { |
28 | 39 |
my $domain = shift; |
29 | 40 |
my $type = shift; |
30 | 41 |
|
31 | 42 |
my %connect_settings; |
43 |
my $initial_sql; |
|
32 | 44 |
|
33 | 45 |
if (!%::myconfig) { |
34 | 46 |
$type = 'LXOFFICE_EMPTY'; |
... | ... | |
44 | 56 |
connect_options => { pg_enable_utf8 => $::locale && $::locale->is_utf8, |
45 | 57 |
}); |
46 | 58 |
} else { |
59 |
my $european_dates = 0; |
|
60 |
if ($::myconfig{dateformat}) { |
|
61 |
$european_dates = 1 if $_dateformats{ $::myconfig{dateformat} } =~ m/european/i; |
|
62 |
} |
|
63 |
|
|
47 | 64 |
%connect_settings = ( driver => $::myconfig{dbdriver} || 'Pg', |
48 | 65 |
database => $::myconfig{dbname}, |
49 | 66 |
host => $::myconfig{dbhost}, |
... | ... | |
51 | 68 |
username => $::myconfig{dbuser}, |
52 | 69 |
password => $::myconfig{dbpasswd}, |
53 | 70 |
connect_options => { pg_enable_utf8 => $::locale && $::locale->is_utf8, |
54 |
}); |
|
71 |
}, |
|
72 |
european_dates => $european_dates); |
|
55 | 73 |
} |
56 | 74 |
|
57 | 75 |
my %flattened_settings = _flatten_settings(%connect_settings); |
... | ... | |
72 | 90 |
return ($domain, $type); |
73 | 91 |
} |
74 | 92 |
|
93 |
sub _execute_initial_sql { |
|
94 |
my ($db) = @_; |
|
95 |
|
|
96 |
return if $_initial_sql_executed{$db} || !%::myconfig || !$::myconfig{dateformat}; |
|
97 |
|
|
98 |
$_initial_sql_executed{$db} = 1; |
|
99 |
|
|
100 |
# Don't rely on dboptions being set properly. Chose them from |
|
101 |
# dateformat instead. |
|
102 |
my $pg_dateformat = $_dateformats{ $::myconfig{dateformat} }; |
|
103 |
$db->dbh->do("set DateStyle to '${pg_dateformat}'") if $pg_dateformat; |
|
104 |
} |
|
105 |
|
|
75 | 106 |
sub _flatten_settings { |
76 | 107 |
my %settings = @_; |
77 | 108 |
my %flattened = (); |
Auch abrufbar als: Unified diff
Datumsformat für RDBO auf dasselbe wie für den Benutzer setzen