Commit a53dd207 authored by sikeda's avatar sikeda
Browse files

[dev] SDM: Double type should be explicitly bound for mysql & Pg. SQLite...

[dev] SDM: Double type should be explicitly bound for mysql & Pg.  SQLite binds double type to real.  Not yet tested by Oracle & Sybase.


git-svn-id: https://subversion.renater.fr/sympa/branches/sympa-6.2-branch@10235 05aa8bb8-cd2b-0410-b1d7-8918dfa770ce
parent e94a612a
......@@ -157,6 +157,12 @@ sub check_key {
# treatment won't be needed.
# * Empty array () if arguments were not given.
# For DOUBLE type.
sub AS_DOUBLE {
return $_[1] if scalar @_ > 1;
return ();
}
# For BLOB types.
sub AS_BLOB {
return $_[1] if scalar @_ > 1;
......
......@@ -433,4 +433,11 @@ sub set_index {
return $report;
}
## For DOUBLE type.
sub AS_DOUBLE {
return ( { 'mysql_type' => DBD::mysql::FIELD_TYPE_DOUBLE() } => $_[1] )
if scalar @_ > 1;
return ();
}
return 1;
......@@ -560,6 +560,13 @@ sub set_index {
return $report;
}
## For DOUBLE types.
sub AS_DOUBLE {
return ( { 'pg_type' => DBD::Pg::PG_FLOAT8() } => $_[1] )
if scalar @_ > 1;
return ();
}
## For BLOB types.
sub AS_BLOB {
return ( { 'pg_type' => DBD::Pg::PG_BYTEA() } => $_[1] )
......
......@@ -584,6 +584,10 @@ sub get_canonical_read_date {
## returns an array ( { sql_type => SQL_type }, value ),
## single scalar or empty array.
##
sub AS_DOUBLE {
return $db_source->AS_DOUBLE(@_);
}
sub AS_BLOB {
return $db_source->AS_BLOB(@_);
}
......
......@@ -1069,6 +1069,22 @@ my %full_db_struct = (
return %full_db_struct;
}
## Conversion of column data types. Basic definitions are based on MySQL.
## Following types are recognized:
## varchar(X) : Text with length upto X. X must be lower than 2^16 - 2.
## int(1): : Boolean, 1 or 0.
## int(11) : Unix time (a.k.a. "epoch").
## int(X) : Integer with columns upto X, -2^31 to 2^31 - 1.
## tinyint : Integer, -2^7 to 2^7 - 1.
## smallint : Integer, -2^15 to 2^15 - 1.
## bigint : Integer, -2^63 to 2^63 - 1.
## double : IEEE floating point number, 8 bytes.
## enum : Keyword with length upto 20 o.
## text : Text with length upto 500 o.
## longtext : Text with length upto 2^32 - 4 o.
## datetime: : Timestamp.
## mediumblob : Binary data with length upto 2^24 - 3 o.
sub db_struct {
my %db_struct;
......@@ -1086,6 +1102,7 @@ sub db_struct {
$trans_o =~ s/^int.*/number/g;
$trans_o =~ s/^bigint.*/number/g;
$trans_o =~ s/^smallint.*/number/g;
$trans_o =~ s/^double/float(24)/g;
$trans_o =~ s/^enum.*/varchar2(20)/g;
$trans_o =~ s/^text.*/varchar2(500)/g;
$trans_o =~ s/^longtext.*/long/g;
......@@ -1097,6 +1114,7 @@ sub db_struct {
$trans_pg =~ s/^smallint.*/int4/g;
$trans_pg =~ s/^tinyint\(.*\)/int2/g;
$trans_pg =~ s/^bigint.*/int8/g;
$trans_pg =~ s/^double/float8/g;
$trans_pg =~ s/^text.*/varchar(500)/g;
$trans_pg =~ s/^longtext.*/text/g;
$trans_pg =~ s/^datetime.*/timestamptz/g;
......@@ -1107,6 +1125,7 @@ sub db_struct {
$trans_syb =~ s/^text.*/varchar(500)/g;
$trans_syb =~ s/^smallint.*/numeric/g;
$trans_syb =~ s/^bigint.*/numeric/g;
$trans_syb =~ s/^double/double precision/g;
$trans_syb =~ s/^longtext.*/text/g;
$trans_syb =~ s/^enum.*/varchar(15)/g;
$trans_syb =~ s/^mediumblob/long binary/g;
......@@ -1117,6 +1136,7 @@ sub db_struct {
$trans_sq =~ s/^tinyint.*/integer/g;
$trans_sq =~ s/^bigint.*/integer/g;
$trans_sq =~ s/^smallint.*/integer/g;
$trans_sq =~ s/^double/real/g;
$trans_sq =~ s/^longtext.*/text/g;
$trans_sq =~ s/^datetime.*/numeric/g;
$trans_sq =~ s/^enum.*/text/g;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment