Showing 10 changed files with 145 additions and 15 deletions
+4 -2
lib/DBIx/Custom.pm
... ...
@@ -1,7 +1,7 @@
1 1
 package DBIx::Custom;
2 2
 use Object::Simple -base;
3 3
 
4
-our $VERSION = '0.1715';
4
+our $VERSION = '0.1716';
5 5
 use 5.008001;
6 6
 
7 7
 use Carp 'croak';
... ...
@@ -196,7 +196,7 @@ sub dbh {
196 196
         
197 197
         # Quote
198 198
         if (!defined $self->reserved_word_quote && !defined $self->quote) {
199
-            my $driver = lc $self->{dbh}->{Driver}->{Name};
199
+            my $driver = $self->_driver;
200 200
             my $quote = $driver eq 'odbc' ? '[]'
201 201
                        :$driver eq 'mysql' ? '`'
202 202
                        : '"';
... ...
@@ -1318,6 +1318,8 @@ sub _croak {
1318 1318
     }
1319 1319
 }
1320 1320
 
1321
+sub _driver { lc shift->{dbh}->{Driver}->{Name} }
1322
+
1321 1323
 sub _need_tables {
1322 1324
     my ($self, $tree, $need_tables, $tables) = @_;
1323 1325
     
-2
t/common-mysql.t
... ...
@@ -22,8 +22,6 @@ use DBIx::Custom;
22 22
     sub date_datatype { lc $date_datatype }
23 23
     sub datetime_datatype { lc $datetime_datatype }
24 24
 
25
-    has datetime_suffix => '';
26
-
27 25
     no warnings 'redefine';
28 26
     has dsn => "dbi:mysql:database=dbix_custom";
29 27
     has user => 'dbix_custom';
+76
t/common-oracle.t
... ...
@@ -0,0 +1,76 @@
1
+use strict;
2
+use warnings;
3
+
4
+use FindBin;
5
+$ENV{DBIX_CUSTOM_TEST_RUN} = 1
6
+  if -f "$FindBin::Bin/run/common-oracle.run";
7
+$ENV{DBIX_CUSTOM_SKIP_MESSAGE} = 'oracle private test';
8
+
9
+use DBIx::Custom;
10
+{
11
+    package DBIx::Custom;
12
+    no warnings 'redefine';
13
+
14
+    my $date_typename = 'CHAR(10)';
15
+    my $datetime_typename = 'DATE';
16
+
17
+    sub date_typename { lc 'CHAR' }
18
+    sub datetime_typename { lc $datetime_typename }
19
+
20
+    my $date_datatype = 91;
21
+    my $datetime_datatype = 11;
22
+
23
+    sub date_datatype { lc $date_datatype }
24
+    sub datetime_datatype { lc $datetime_datatype }
25
+    
26
+    has datetime_suffix => '';
27
+
28
+    has dsn => 'dbi:Oracle:host=localhost;port=1521;sid=XE';
29
+    has user  => 'dbix_custom';
30
+    has password => 'dbix_custom';
31
+    has exclude_table => sub {
32
+
33
+        return qr/^(
34
+            pg_|column_|role_|view_|sql_
35
+            |applicable_roles
36
+            |check_constraints
37
+            |columns
38
+            |constraint_column_usage
39
+            |constraint_table_usage
40
+            |data_type_privileges
41
+            |domain_constraints
42
+            |domain_udt_usage
43
+            |domains
44
+            |element_types
45
+            |enabled_roles
46
+            |information_schema
47
+            |information_schema_catalog_name
48
+            |key_column_usage
49
+            |parameters
50
+            |referential_constraints
51
+            |routine_privileges
52
+            |routines
53
+            |schemata
54
+            |table_constraints
55
+            |table_privileges
56
+            |tables
57
+            |triggered_update_columns
58
+            |triggers
59
+            |usage_privileges
60
+            |views
61
+        )/x
62
+    };
63
+    
64
+    sub create_table1 { 'create table table1 (key1 varchar2(255), key2 varchar2(255));' }
65
+    sub create_table1_2 {'create table table1 (key1 varchar2(255), key2 varchar2(255), '
66
+     . 'key3 varchar2(255), key4 varchar2(255), key5 varchar2(255));' }
67
+    sub create_table1_type { "create table table1 (key1 $date_typename, key2 $datetime_typename);" }
68
+    sub create_table1_highperformance { "create table table1 (ab varchar2(255), bc varchar2(255), "
69
+      . "ik varchar2(255), hi varchar2(255), ui varchar2(255), pq varchar2(255), dc varchar2(255));" }
70
+    sub create_table2 { 'create table table2 (key1 varchar2(255), key3 varchar2(255));' }
71
+    sub create_table2_2 { "create table table2 (key1 varchar2(255), key2 varchar2(255), key3 varchar2(255))" }
72
+    sub create_table3 { "create table table3 (key1 varchar2(255), key2 varchar2(255), key3 varchar2(255))" }
73
+    sub create_table_reserved { 'create table "table" ("select" varchar2(255), "update" varchar2(255))' }
74
+}
75
+
76
+require "$FindBin::Bin/common.t";
-2
t/common-postgresql.t
... ...
@@ -22,8 +22,6 @@ use DBIx::Custom;
22 22
 
23 23
     sub date_datatype { lc $date_datatype }
24 24
     sub datetime_datatype { lc $datetime_datatype }
25
-    
26
-    has datetime_suffix => '';
27 25
 
28 26
     has dsn => "dbi:Pg:dbname=dbix_custom";
29 27
     has user  => 'dbix_custom';
-2
t/common-sqlite-quote.t
... ...
@@ -21,8 +21,6 @@ use DBIx::Custom;
21 21
     sub date_datatype { lc $date_datatype }
22 22
     sub datetime_datatype { lc $datetime_datatype }
23 23
 
24
-    has datetime_suffix => '';
25
-
26 24
     has dsn => 'dbi:SQLite:dbname=:memory:';
27 25
     sub quote { '""' }
28 26
     sub create_table1 { 'create table table1 (key1 varchar, key2 varchar);' }
-2
t/common-sqlite.t
... ...
@@ -21,8 +21,6 @@ use DBIx::Custom;
21 21
     sub date_datatype { lc $date_datatype }
22 22
     sub datetime_datatype { lc $datetime_datatype }
23 23
 
24
-    has datetime_suffix => '';
25
-    
26 24
     has dsn => 'dbi:SQLite:dbname=:memory:';
27 25
     sub create_table1 { 'create table table1 (key1 varchar, key2 varchar);' }
28 26
     sub create_table1_2 {'create table table1 (key1 varchar, key2 varchar, key3 varchar, key4 varchar, key5 varchar);' }
+2 -3
t/common-sqlserver.t
... ...
@@ -3,8 +3,8 @@ use warnings;
3 3
 
4 4
 use FindBin;
5 5
 $ENV{DBIX_CUSTOM_TEST_RUN} = 1
6
-  if -f "$FindBin::Bin/run/common-postgresql.run";
7
-$ENV{DBIX_CUSTOM_SKIP_MESSAGE} = 'postgresql private test';
6
+  if -f "$FindBin::Bin/run/common-sqlserver.run";
7
+$ENV{DBIX_CUSTOM_SKIP_MESSAGE} = 'sqlserver private test';
8 8
 
9 9
 use DBIx::Custom;
10 10
 {
... ...
@@ -23,7 +23,6 @@ use DBIx::Custom;
23 23
     sub date_datatype { lc $date_datatype }
24 24
     sub datetime_datatype { lc $datetime_datatype }
25 25
 
26
-    has datetime_suffix => '.000';
27 26
     has exclude_table => sub {
28 27
         return qr/^(
29 28
           CHECK_CONSTRAINTS
+1 -1
t/common.t
... ...
@@ -158,7 +158,6 @@ my $date_typename = $dbi->date_typename;
158 158
 my $datetime_typename = $dbi->datetime_typename;
159 159
 my $date_datatype = $dbi->date_datatype;
160 160
 my $datetime_datatype = $dbi->datetime_datatype;
161
-my $datetime_suffix = $dbi->datetime_suffix;
162 161
 
163 162
 # Variable
164 163
 # Variables
... ...
@@ -199,6 +198,7 @@ eval { $dbi->execute('drop table table1') };
199 198
 test 'type_rule into';
200 199
 $dbi = DBIx::Custom->connect;
201 200
 eval { $dbi->execute('drop table table1') };
201
+$DB::single = 1;
202 202
 $dbi->execute($create_table1_type);
203 203
 $dbi->type_rule(
204 204
     into1 => {
+55
t/run/common-oracle.run
... ...
@@ -0,0 +1,55 @@
1
+# Download
2
+http://download.oracle.com/otn/linux/oracle10g/xe/10201/oracle-xe-univ-10.2.0.1-1.0.i386.rpm
3
+
4
+# Install
5
+rpm -ivh oracle-xe-univ-10.2.0.1-1.0.i386.rpm
6
+/etc/init.d/oracle-xe configure
7
+
8
+# Note
9
+Port number is set to 8090
10
+
11
+# HTTP access
12
+http://127.0.0.1:8090/apex
13
+
14
+# Create user
15
+id: dbix_custom
16
+password: dbix_custom
17
+
18
+Add all privirage
19
+
20
+# DBD::Oracle
21
+You must be install install client
22
+oracle-instantclient11.2-basic-11.2.0.2.0.i386.rpm
23
+oracle-instantclient11.2-devel-11.2.0.2.0.i386.rpm
24
+oracle-instantclient11.2-sqlplus-11.2.0.2.0.i386.rpm
25
+
26
+rpm -hiv oracle-instantclient11.2-basic-11.2.0.2.0.i386.rpm
27
+rpm -hiv oracle-instantclient11.2-devel-11.2.0.2.0.i386.rpm
28
+rpm -hiv oracle-instantclient11.2-sqlplus-11.2.0.2.0.i386.rpm
29
+
30
+vi /etc/profile.d/oracle.sh
31
+export ORACLE_HOME='/usr/lib/oracle/11.2/client'
32
+export C_INCLUDE_PATH='/usr/include/oracle/11.2/client'
33
+export LD_LIBRARY_PATH='/usr/lib/oracle/11.2/client/lib'
34
+
35
+vi /etc/ld.so.conf.d/oracle.conf
36
+/usr/lib/oracle/11.2/client/lib
37
+
38
+cpan DBD::Oracle
39
+
40
+sqlplus dbix_custom/dbix_custom@localhost:1521/XE
41
+
42
+mkdir -p $ORACLE_HOME/network/admin/
43
+vi $ORACLE_HOME/network/admin/tnsnames.ora
44
+
45
+XE =
46
+  (DESCRIPTION =
47
+    (ADDRESS_LIST =
48
+      (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
49
+    )
50
+    (CONNECT_DATA =
51
+      (SID = orcl)
52
+    )
53
+  )
54
+
55
+
+7 -1
t/run/common-sqlserver.run
... ...
@@ -4,4 +4,10 @@ http://awoni.net/fc/sql-server-2008-express/
4 4
 
5 5
 # Install
6 6
 http://www.microsoft.com/downloads/ja-jp/details.aspx?displaylang=ja&FamilyID=967225eb-207b-4950-91df-eeb5f35a80ee
7
-http://www.microsoft.com/downloads/ja-jp/details.aspx?familyid=E08766CE-FC9D-448F-9E98-FE84AD61F135&displaylang=ja
7
+
8
+
9
+# Note
10
+You enable SQL Server authentication.
11
+You create user "dbix_custom", password "dbix_custom"
12
+You give create_table, insert, update, delete, select authority to user "dbix_custom".
13
+